카멜 단위 테스트가 있으며 경로의 첫 번째 지점에서 Exchange에 설정된 헤더 값에 액세스하려고합니다.카멜 테스트 : 경로에 설정된 헤더에 액세스하는 방법
경로 예 ...이 사용되는
<route id="VCM001_incoming">
<from uri="file:{{InLocation}}" />
<convertBodyTo type="java.lang.String"/>
<setHeader headerName="FileNameWithoutExtension">
<simple>${file:onlyname.noext}</simple>
</setHeader>
<to uri="direct:splitFile" />
</route>
자바 코드 ...이 시점에 따라서 모든 좋은
public List<String> createList(Exchange exchange) {
String fileName = (String) exchange.getIn().getHeader("FileNameWithoutExtension");
.
이제 내 테스트에서 어떤 헤더 값이 "FileNameWithoutExtension"인지 알고 싶습니다.
@Produce(uri = "file:{{InLocation}}")
private ProducerTemplate inputEndpoint;
@EndpointInject(uri = "mock:output1")
private MockEndpoint outputEndpointRPR;
@Test
public void testCamelRoute() throws Exception
{
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:{{OutLocation}}").to(outputEndpoint);
}
inputEndpoint.sendBody("test-message");
Object[] expectedBodies = new Object[]{"Success: filename=xxx"};
// At this point I need the header 'FileNameWithoutExtension' to setup the correct 'expectedBodies'
outputEndpoint.expectedBodiesReceivedInAnyOrder(expectedBodies);
assertMockEndpointsSatisfied();
}