camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frankiboy <mail.to.fra...@gmail.com>
Subject Re: Test a single Bean with CamelTestSupport ?
Date Thu, 19 Jun 2014 09:36:58 GMT
Now i tried this way

public class FilterTest extends CamelTestSupport {   
    
     // @EndpointInject(uri = "mock:result") 
    protected MockEndpoint resultEndpoint;   
    
   // @Produce(uri = "direct:start")   
    protected ProducerTemplate template;    
    
    @Test    public void testSendMatchingMessage() throws Exception {   
        resultEndpoint = getMockEndpoint("mock:result");
        template = context.createProducerTemplate();
        String expectedBody = "<matched/>";       
        resultEndpoint.expectedBodiesReceived(expectedBody);      
        template.sendBodyAndHeader(expectedBody, "foo", "bar");     
        resultEndpoint.assertIsSatisfied();    
     } 
  
    @Override    protected RouteBuilder createRouteBuilder() {    
             
        return new RouteBuilder() {            public void configure() {      
            from("direct:start").bean(AddIpBean.class).to("mock:result");    
            }  
        };  
      
    }
    
}

But back to the same excemption when this line executes:

template.sendBodyAndHeader(expectedBody, "foo", "bar");     

I got :

java.lang.IllegalArgumentException: defaultEndpoint must be specified
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:296)
	at
org.apache.camel.impl.DefaultProducerTemplate.getMandatoryDefaultEndpoint(DefaultProducerTemplate.java:458)
	at
org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:367)
	at
dk.bankconnect.hub.unittest.FilterTest.testSendMatchingMessage(FilterTest.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:611)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at org.apache.camel.test.TestSupport.runBare(TestSupport.java:65)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


Frank



--
View this message in context: http://camel.465427.n5.nabble.com/Test-a-single-Bean-with-CamelTestSupport-tp5752563p5752572.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message