Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
SWARM-806: JPA+JAX-RS+CDI+JTA examples have wrong assertions (#103)
Browse files Browse the repository at this point in the history
Motivation
----------
Both the JPA+JAX-RS+CDI+JTA examples have the following exceptions
in the log:

    Could not find MessageBodyWriter for response object of type:
    java.lang.Integer of media type: text/html

yet the tests don't fail. This is because the FEST Assert API
is used wrongly and no assertions are actually made.

Modifications
-------------
Fix usage of the FEST Assert API so that asserts are actually made.
This itself makes the tests fail, but that is easy to fix: just
make the int-returning JAX-RS methods @produces("text/plain"),
so that java.lang.Integer marshaller is found.

Result
------
More test coverage, less exceptions in the log, tests still pass.
  • Loading branch information
Ladicek authored and kenfinnigan committed Nov 7, 2016
1 parent e6f1680 commit d6b7337
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public void testRollBack() {
assertThat(browser.getPageSource()).contains("*** On purpose failure during removal to test Rollback ***");

browser.navigate().to("http://localhost:8080/rollbackMsg");
assertThat(browser.getPageSource().contains("5"));
assertThat(browser.getPageSource()).contains("5");

browser.navigate().to("http://localhost:8080/commitMsg");
assertThat(browser.getPageSource().contains("0"));
assertThat(browser.getPageSource()).contains("0");


testAll();
Expand All @@ -81,9 +81,9 @@ public void testWithoutRollBack() {
}
assertThat(browser.getPageSource()).contains("*** On purpose failure during removal to test Rollback ***");
browser.navigate().to("http://localhost:8080/rollbackMsg");
assertThat(browser.getPageSource().contains("0"));
assertThat(browser.getPageSource()).contains("0");
browser.navigate().to("http://localhost:8080/commitMsg");
assertThat(browser.getPageSource().contains("3"));
assertThat(browser.getPageSource()).contains("3");
browser.navigate().to("http://localhost:8080/all");
assertThat(browser.getPageSource()).doesNotContain("{\"id\":1,\"name\":\"Penny\"}");
assertThat(browser.getPageSource()).doesNotContain("{\"id\":2,\"name\":\"Sheldon\"}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ public String remTxWithNoRollbackOnISE() {

@GET
@Path("rollbackMsg")
@Produces("text/plain")
public int getRollBackMsg() {

return service.getRollbackMsg().size();
}

@GET
@Path("commitMsg")
@Produces("text/plain")
public int getCommitMsg() {

return service.getCommitMsg().size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public void testRollBack() {
assertThat(browser.getPageSource()).contains("*** On purpose failure during removal to test Rollback ***");

browser.navigate().to("http://localhost:8080/rollbackMsg");
assertThat(browser.getPageSource().contains("5"));
assertThat(browser.getPageSource()).contains("5");

browser.navigate().to("http://localhost:8080/commitMsg");
assertThat(browser.getPageSource().contains("0"));
assertThat(browser.getPageSource()).contains("0");


testAll();
Expand All @@ -80,9 +80,9 @@ public void testWithoutRollBack() {
}
assertThat(browser.getPageSource()).contains("*** On purpose failure during removal to test Rollback ***");
browser.navigate().to("http://localhost:8080/rollbackMsg");
assertThat(browser.getPageSource().contains("0"));
assertThat(browser.getPageSource()).contains("0");
browser.navigate().to("http://localhost:8080/commitMsg");
assertThat(browser.getPageSource().contains("3"));
assertThat(browser.getPageSource()).contains("3");
browser.navigate().to("http://localhost:8080/all");
assertThat(browser.getPageSource()).doesNotContain("{\"id\":1,\"name\":\"Penny\"}");
assertThat(browser.getPageSource()).doesNotContain("{\"id\":2,\"name\":\"Sheldon\"}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ public String remTxWithNoRollbackOnISE() {

@GET
@Path("rollbackMsg")
@Produces("text/plain")
public int getRollBackMsg() {

return service.getRollbackMsg().size();
}

@GET
@Path("commitMsg")
@Produces("text/plain")
public int getCommitMsg() {

return service.getCommitMsg().size();
Expand Down

0 comments on commit d6b7337

Please sign in to comment.