Not sure whether this is related to your problem, but
getMockEndpoint("file://target/outbox").expectedMessageCount(1);
is wrong.
You have to use the consumer template to consume from an endpoint which is
not a mock endpoint:
ConsumerTemplate consumer = context.createConsumerTemplate();
Exchange exchange = consumer.receive("file://target/outbox");
or extend your route so that your message is also send to an mock endpoint.
Than you could use:
getMockEndpoint("mock://target/outbox").expectedMessageCount(1);
Best,
Christian
On Tue, Jul 24, 2012 at 1:03 AM, [email protected] <[email protected]>wrote:
> I am trying to test a simple blueprint route, but I am getting
> java.lang.RuntimeException: Gave up waiting for service
> (objectClass=org.apache.camel.CamelContext) .
>
> Below are my blueprint and Unit test case, I am not sure what I am doing
> wrong. Need help with this issue.
>
> *Blueprint *
>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
>
> <camelContext xmlns="http://camel.apache.org/schema/blueprint">
> <route id="route">
> <from uri="file://target/inbox"/>
> <to uri="file://target/outbox"/>
> </route>
> </camelContext>
>
> </blueprint>
>
> *Unit Test Case using camel-test-blueprint*
>
>
> public class BluePrintRouteTest extends CamelBlueprintTestSupport {
>
> // override this method, and return the location of our Blueprint
> XML file
> to be used for testing
> @Override
> protected String getBlueprintDescriptor() {
> return "OSGI-INF/blueprint/camel-context.xml";
> }
>
> @Test
> public void testRoute() throws Exception {
> // set mock expectations
> getMockEndpoint("file://target/outbox").expectedMessageCount(1);
>
> // send a message
> template.sendBodyAndHeader("file://target/inbox",
> "John|lastName|city|Zip|0000", Exchange.FILE_NAME, "myTestFile.txt");
>
> // assert mocks
> assertMockEndpointsSatisfied();
> }
>
> }
>
> *Exception*
>
> java.lang.RuntimeException: Gave up waiting for service
> (objectClass=org.apache.camel.CamelContext)
> at
>
> org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:177)
> at
>
> org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:139)
> at
>
> org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:100)
> at
>
> org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:247)
> at
>
> org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
> at
>
> org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:50)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
>
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
> at
>
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
>
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
> at
>
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
> at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
> at org.junit.rules.RunRules.evaluate(RunRules.java:18)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at
>
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
> at
>
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at
> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at
>
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 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)
>
>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/java-lang-RuntimeException-Gave-up-waiting-for-service-tp5716371.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>