First, is this the recommended way to do this type of test?
I don't know the "official words", but it's used in official unit tests and
also introduced in Camel in Action.
Second, can the createRouteBuilder be the one in the actual prod route or do I
have to copy my prod route into it?
You'd load your prod spring XML route via CamelSpringTestSupport, retrieve the
RouteDefinition from context by its name and adviceWith() like this test case
https://github.com/apache/camel/blob/master/components/camel-test-spring/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java#L44
Another option would be to use @MockEndpointsAndSkip
https://github.com/apache/camel/blob/master/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerMockEndpointsAndSkipTest.java#L29
Thanks,
Tomo
On 10/12/2016 10:15 PM, Ryan Tracy wrote:
Tomo,
That looks like what I am looking for. Two questions. First, is this the
recommended way to do this type of test?Second, can the createRouteBuilder be
the one in the actual prod route or do I have to copy my prod route into it?
Ryan
Sent from Yahoo Mail on Android
On Wed, Oct 12, 2016 at 12:54 AM, Tomohisa Igarashi<tm.igara...@gmail.com>
wrote: Hi,
Is this what you're looking for as an example?
interceptSendToEndpoint()&skipSendToOriginalEndpoint() via
AdviceWithRouteBuilder intercepts sending to the actual endpoint defined in spring
XML and forwarding it to the mock endpoint for testing purpose.
https://github.com/apache/camel/blob/master/components/camel-http/src/test/java/org/apache/camel/component/http/HttpInterceptSendToEndpointTest.java#L35
Thanks,
Tomo
On 10/12/2016 05:54 AM, catequil wrote:
Background
I'm a newbie to Apache Camel. (3 months)
I have read the testing section to Camel in Action MEAP version.
I have read http://camel.apache.org/testing.html and
http://camel.apache.org/spring-testing.html
I have searched this forum, google and stackoverflow for answers.
I've tried using the adviceWith, but that is confusing too.
Current versions are Camel 2.16.2 and Spring 4.0.6 and Junit 4.12
Dependencies loaded: {camel-core, camel-spring, camel-cxf, camel-jackson,
camel-test, camel-test-spring40, camel-kafka, spring-test}
Criteria
DRY (No identical code in testing)
Cannot modify production code.
Must use Mocks as integration tests would take too long to run.
Must use CamelSpringTestSupport (The only configuration I can get to work in
my environment that supports spring and camel)
Question
The part I am struggling with the most, for a week now, is the Mocks. They
do not make sense to me on how they work in relation to the production
version of the route.
Can some one please help me to create a unit test that works having all this
criteria and help me understand the Mocking for Endpoints?
--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-Spring-Unit-Testing-with-Mocks-tp5788635.html
Sent from the Camel - Users mailing list archive at Nabble.com.