package com.github.davidmarquis.redisscheduler.lib;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import redis.embedded.RedisServer;

public class StartRedis implements TestRule {
    @Override
    public Statement apply(Statement base, Description description) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                RedisServer server = new RedisServer();
                server.start();

                try {
                    base.evaluate();
                } finally {
                    server.stop();
                }
            }
        };
    }
}

@@ -73,95 +73,24 @@
 les.
-TestRule;%0Aimport org.junit.runner.Description;%0Aimport org.junit.runners.model.Statement
+ExternalResource
 ;%0Aim
@@ -151,200 +151,107 @@
 dis 
-implements TestRule %7B%0A    @Override%0A    public Statement apply(Statement base, Description description) %7B%0A        return new Statement() %7B%0A            @Override%0A            public void evaluat
+extends ExternalResource %7B%0A%0A    private RedisServer server;%0A%0A    @Override%0A    protected void befor
 e() 
@@ -281,28 +281,8 @@
     
-        RedisServer 
 serv
@@ -309,32 +309,24 @@
 ();%0A        
-        
 server.start
@@ -333,172 +333,79 @@
 ();%0A
-%0A   
     
+%7D%0A%0A
     
-     try %7B%0A                    base.evalua
+@Override%0A    protected void af
 te
+r
 ()
-;%0A                %7D finally %7B%0A                    server.stop();%0A                %7D%0A            %7D%0A        %7D
+ %7B%0A        server.stop()
 ;%0A  

Convert `StartRedis` rule to external resource