camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paramjyotsingh <paramjyotsi...@gmail.com>
Subject Re: Camel Velocity Template throwing error
Date Thu, 05 Jul 2012 16:55:11 GMT
Hi Henryk,

I tried JUnit sample to test velocity in camel given by Claus at
http://camel.apache.org/velocity.html

	private Exchange createLetter() {
	    Exchange exchange = context.getEndpoint("direct:a").createExchange();
	    Message msg = exchange.getIn();
	    msg.setHeader("firstName", "Claus");
	    msg.setHeader("lastName", "Ibsen");
	    msg.setHeader("item", "Camel in Action");
	    msg.setBody("PS: Next beer is on me, James");
	    return exchange;
	}

	@Test
	public void testVelocityLetter() throws Exception {
	    MockEndpoint mock = getMockEndpoint("mock:result");
	    mock.expectedMessageCount(1);
	    mock.expectedBodiesReceived("Dear Ibsen, Claus\n\nThanks for the order
of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on
me, James");

	    template.send("direct:a", createLetter());

	    mock.assertIsSatisfied();
	}

	protected RouteBuilder createRouteBuilder() throws Exception {
	    return new RouteBuilder() {
	        public void configure() throws Exception {
	           
from("direct:a").to("velocity:com/test/letter.vm").to("mock:result");
	        }
	    };
	}


And it is failing for me. I am getting following AssertionError:

java.lang.AssertionError: mock://result Received message count. Expected:
<1> but was: <0>
	at
org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:1172)
	at
org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:1154)
	at
org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(MockEndpoint.java:369)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:348)
	at
org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:336)
	at
com.test.TestVelocityTemplate.testVelocityLetter(TestVelocityTemplate.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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.InvokeMethod.evaluate(InvokeMethod.java:20)
	at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	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)

Let me know if this helps.


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Velocity-Template-throwing-error-tp5715388p5715561.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message