@Test public void testSendBuilderWithEndpointName() { reset(applicationContextMock); when(applicationContextMock.getBean(TestActionListeners.class)) .thenReturn(new TestActionListeners()); when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)) .thenReturn(new HashMap<String, SequenceBeforeTest>()); when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)) .thenReturn(new HashMap<String, SequenceAfterTest>()); MockTestDesigner builder = new MockTestDesigner(applicationContextMock) { @Override public void configure() { send("fooMessageEndpoint") .payload("<TestRequest><Message>Hello World!</Message></TestRequest>"); } }; builder.configure(); TestCase test = builder.getTestCase(); Assert.assertEquals(test.getActionCount(), 1); Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class); SendMessageAction action = ((SendMessageAction) test.getActions().get(0)); Assert.assertEquals(action.getName(), "send"); Assert.assertEquals(action.getEndpointUri(), "fooMessageEndpoint"); }
@Test( expectedExceptions = CitrusRuntimeException.class, expectedExceptionsMessageRegExp = "Invalid use of http and soap action builder") public void testSendBuilderWithSoapAndHttpMixed() { reset(applicationContextMock); when(applicationContextMock.getBean(TestActionListeners.class)) .thenReturn(new TestActionListeners()); when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)) .thenReturn(new HashMap<String, SequenceBeforeTest>()); when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)) .thenReturn(new HashMap<String, SequenceAfterTest>()); MockTestDesigner builder = new MockTestDesigner(applicationContextMock) { @Override public void configure() { send("httpClient") .http() .payload("<TestRequest><Message>Hello World!</Message></TestRequest>") .header("operation", "soapOperation") .soap(); } }; builder.configure(); TestCase test = builder.getTestCase(); Assert.assertEquals(test.getActionCount(), 1); Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class); SendMessageAction action = ((SendMessageAction) test.getActions().get(0)); Assert.assertEquals(action.getName(), "send"); Assert.assertEquals(action.getEndpointUri(), "httpClient"); Assert.assertEquals(action.getMessageType(), MessageType.XML.name()); }