camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Minh Tran <minh.t...@winning.com.au>
Subject spring boot test mocks
Date Mon, 16 Nov 2015 01:40:00 GMT
Hi

I’m trying to write unit tests in camel 2.16.0 and spring boot.

My route looks like

from(“direct:start”).to(“direct:end”)

My unit test looks like

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Config.class)
@MockEndpoints
public class MyUnitTest {

  @Produce(uri=“direct:start”)
  private ProducerTemplate producer;

  @EndpointInject(uri=“mock:direct:end”)
  private MockEndpoint end;

	@Test
	public void testMock() throws InterruptedException {
		end.expectedBodiesReceived("blah");
		producerTemplate.sendBody("blah");
		end.assertIsSatisfied();
	}

}

It looks like the direct:end bit is never mocked so the assertion fails. It’s like @MockEndpoints
is completely ignored. 

Is this the correct way to mock existing components when using spring boot? Thanks.
Mime
View raw message