Created
October 21, 2014 20:04
-
-
Save altfatterz/e62c303dce3b2ad4378f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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