Skip to content

Instantly share code, notes, and snippets.

@rschumm
Last active December 31, 2015 15:39
Show Gist options
  • Save rschumm/8008240 to your computer and use it in GitHub Desktop.
Save rschumm/8008240 to your computer and use it in GitHub Desktop.
restfuse einfacher Integrationstest für RESTful Services
<dependency>
<groupId>com.restfuse</groupId>
<artifactId>com.eclipsesource.restfuse</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
package ch.lepeit.brain2;
import org.junit.Rule;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import static com.eclipsesource.restfuse.Assert.*;
import com.eclipsesource.restfuse.Destination;
import com.eclipsesource.restfuse.HttpJUnitRunner;
import com.eclipsesource.restfuse.Method;
import com.eclipsesource.restfuse.Response;
import com.eclipsesource.restfuse.annotation.Context;
import com.eclipsesource.restfuse.annotation.HttpTest;
@RunWith(HttpJUnitRunner.class)
public class RestServerTest {
@Rule
public Destination destination = new Destination(this, "http://localhost:8080");
@Context
private Response response; // will be injected after every request
@HttpTest(method = Method.GET, path = "/brain2/rest/brain2/stages")
public void checkRestfuseOnlineStatus() {
String erwAntwort = "[{\"name\":\"Development\",\"kurzName\":\"dev\",\"stage_ID\":1},{\"name\":\"Acceptance\",\"kurzName\":\"acc\",\"stage_ID\":2},{\"name\":\"Production\",\"kurzName\":\"prod\",\"stage_ID\":3}]";
assertOk(response);
String body = response.getBody();
assertEquals(erwAntwort, body);
}
}
@rschumm
Copy link
Author

rschumm commented Dec 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment