Skip to content

Commit

Permalink
Test ExchangeProperty and Header languages apache#2613
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed May 18, 2021
1 parent fbe0e9d commit 1186965
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ public String resource(String body, @PathParam("route") String route, @PathParam
}
}

@Path("/exchangeProperty/{route}/{key}/{value}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String exchangeProperty(String body, @PathParam("route") String route, @PathParam("key") String key,
@PathParam("value") String value) {
return template.request("direct:" + route, e -> e.getProperties().put(key, value)).getMessage().getBody(String.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public void configure() {

from("direct:bodyIs-simple").filter().simple("${body} is 'java.nio.ByteBuffer'").setBody(constant("BYTE_BUFFER"));

from("direct:exchangeProperty")
from("direct:myExchangePropertyRoute")
.setBody().exchangeProperty("myExchangeProperty");

from("direct:myHeaderRoute")
.setBody().header("myHeader");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,18 @@ public void byteBufferBodyShouldPassThroughBodyIsFilter() {
given().body("A body of type ByteBuffer").when().post("/simple/route/bodyIs-simple/ByteBuffer").then().statusCode(200)
.body(is("BYTE_BUFFER"));
}

@Test
public void exchangeProperty() {
given().body("foo").post("/simple/exchangeProperty/myExchangePropertyRoute/myExchangeProperty/1234").then()
.statusCode(200)
.body(is("1234"));
}

@Test
public void header() {
given().body("foo").post("/simple/header/myHeaderRoute/myHeader/barbaz").then().statusCode(200)
.body(is("barbaz"));
}

}

0 comments on commit 1186965

Please sign in to comment.