Skip to content

Instantly share code, notes, and snippets.

@altfatterz
Created October 21, 2014 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altfatterz/e62c303dce3b2ad4378f to your computer and use it in GitHub Desktop.
Save altfatterz/e62c303dce3b2ad4378f to your computer and use it in GitHub Desktop.
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest("server.port:0")
public class PageControllerTest {
@Autowired
PageRepository pageRepository;
@Value("${local.server.port}")
int port;
@Before
public void setUp() {
RestAssured.port = port;
}
@Test
public void links() {
when().get("/").then()
.statusCode(HttpStatus.SC_OK)
.contentType(JSON)
.body("_links.pages.href", Matchers.is("http://localhost:" + port + "/pages"))
.body("_links.portals.href", Matchers.is("http://localhost:" + port + "/portals"));
}
@Test
public void findPage( ) {
when().get("/pages/1").then().statusCode(HttpStatus.SC_OK).body("name", Matchers.is("login"));
}
@Test
public void deleteExistingPage() {
when().delete("/pages/2").then().statusCode(HttpStatus.SC_NO_CONTENT);
}
@Test
public void deleteNonExistingPage() {
when().delete("/pages/6").then().statusCode(HttpStatus.SC_NOT_FOUND);
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment