226.3. 간단한 예
다음은 사용 중인 Mock 엔드 포인트의 간단한 예입니다. 먼저 컨텍스트에서 끝점이 확인됩니다. 그런 다음 테스트가 실행된 후 기대치를 설정하며, 당사의 기대치가 충족되었다고 주장합니다.
MockEndpoint resultEndpoint = context.resolveEndpoint("mock:foo", MockEndpoint.class);
// set expectations
resultEndpoint.expectedMessageCount(2);
// send some messages
// now lets assert that the mock:foo endpoint received 2 messages
resultEndpoint.assertIsSatisfied();
일반적으로는 항상 assertIsSatisfied() 메서드를 호출하여 테스트를 실행한 후 기대치가 충족되었는지 테스트합니다.
Camel은 assertIsSatisfied() 가 호출될 때 기본적으로 10초 정도 기다립니다. setResultWaitTime(millis) 메서드를 설정하여 구성할 수 있습니다.