Skip to content

Commit

Permalink
chore(test): add test for bean(class, method)
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Feb 19, 2020
1 parent 3ba3c24 commit 393e73e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public String named(String statement) {
return template.requestBody("direct:named", statement, String.class);
}

@Path("/method")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String method(String statement) {
return template.requestBody("direct:method", statement, String.class);
}

@Path("/increment")
@GET
@Produces(MediaType.TEXT_PLAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public void configure() {
.to("bean:namedBean?method=hello")
.to("log:named");

from("direct:method")
.bean(MyBean.class, "sayHello")
.to("log:named");

}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -145,4 +149,13 @@ public Map<String, Object> buildCombinedResponse(List<String> lines) {
}
}

@RegisterForReflection
public static class MyBean {
/**
* Just return an hello message.
*/
public static String sayHello(String body) {
return "Hello " + body + " from the MyBean";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public void named() {
.body(equalTo("Hello Kermit from the NamedBean"));
}

@Test
public void method() {
RestAssured.given()
.contentType(ContentType.TEXT)
.body("Kermit")
.post("/bean/method")
.then()
.body(equalTo("Hello Kermit from the MyBean"));
}

@Test
public void inject() {

Expand Down

0 comments on commit 393e73e

Please sign in to comment.