camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavan <pavan.m...@gmail.com>
Subject Help on Mock for Async calls
Date Mon, 10 Sep 2012 07:58:41 GMT
Hi,

I am new to Camel.

I am trying to simulate the endpoint using MockEndPoints. The objective is
the mock the endpoint and verify the headers received.

Following is my code: -

import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.CamelTestSupport;

public class TestAsyncCalls extends CamelTestSupport {
	
	@Override
    public String isMockEndpoints() {
        return "ahc*";
    }
	
	public void testmakeAsyncNSApiLoginCall() {
		try {
			getMockEndpoint("mock:result").expectedHeaderReceived("username",
"admin123");
			DefaultExchange dfex = new DefaultExchange(context);
			dfex.getIn().setHeader("username", "admin");
			dfex.getIn().setHeader("password", "admin");
			template.asyncSend("ahc:<some uri>", dfex);
			Thread.sleep(5000);
			assertMockEndpointsSatisfied();
			System.out.println(context.getEndpoints());
		} catch (Exception e) {
			e.printStackTrace();
			Assert.assertTrue("Failed to make async call to nsapi login", false);
		}
	}
}

I was expecting the "expectedHeaderReceived()" to fail, since the username
set in the exchange differs. But when I run it, it does not fail. What else
need I be doing to get it to work? Please help.




--
View this message in context: http://camel.465427.n5.nabble.com/Help-on-Mock-for-Async-calls-tp5719008.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message