eclipsesource/restfuse — pull request #58 by redrezo (2014-04-09 17:52:37+00:00)
Title: execute @Before annotated methods before REST requests

patched HttpJUnitRunner to support this
added @HttpConfig annotation and RuleStrategy enum to configure behavior
default behavior is unchanged

example:
```java
@RunWith(HttpJUnitRunner.class)
@HttpConfig(ruleStrategy=RuleStrategy.HTTP_CALL_AFTER_BEFORE)
public class MyTest {
@Rule
public Destination destination = new Destination(this, "http://localhost:" + System.getProperty( "org.osgi.service.http.port" ));

@Context
private Response response;

@Before
public void before() {
System.err.println("Test#before()");
Bundle bundle = FrameworkUtil.getBundle(Test.class);
BundleContext bundleContext = bundle.getBundleContext();
ServiceReference serviceReference = bundleContext.getServiceReference(WebService.class);
WebService service = bundleContext.getService(serviceReference);
service.setName("Foo");
}

@org.junit.Test
@HttpTest(method=Method.GET, path="/services/hello")
public void testServiceCall() {
System.err.println("Test#testServiceCall()");
assertOk(response);
assertEquals("Hello Foo", response.getBody());
}
}

@Path("/")
public class WebService {

private String name = "World";

@GET
@Path("/hello")
public String helloWorld() {
System.err.println("WebService#helloWorld()");
return "Hello " + name;
}

public void setName(String name) {
this.name = name;
}
}
```