Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): add test for bean(class, method) #737

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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