How to use getFaultString method of com.consol.citrus.ws.actions.SendSoapFaultAction class

Best Citrus code snippet using com.consol.citrus.ws.actions.SendSoapFaultAction.getFaultString

Source:SendSoapFaultTestRunnerTest.java Github

copy

Full Screen

...60 doAnswer(invocation -> {61 SoapFault message = (SoapFault) invocation.getArguments()[0];62 Assert.assertEquals(message.getFaultActor(), "faultActor");63 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);64 Assert.assertEquals(message.getFaultString(), FAULT_STRING);65 return null;66 }).when(messageProducer).send(any(Message.class), any(TestContext.class));67 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {68 @Override69 public void execute() {70 soap(builder -> builder.server(soapServer)71 .sendFault()72 .faultActor("faultActor")73 .faultCode(FAULT_CODE)74 .faultString(FAULT_STRING));75 }76 };77 TestCase test = builder.getTestCase();78 Assert.assertEquals(test.getActionCount(), 1);79 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);80 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();81 Assert.assertEquals(action.getName(), "send");82 Assert.assertEquals(action.getEndpoint(), soapServer);83 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);84 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();85 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");86 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);87 Assert.assertEquals(action.getFaultActor(), "faultActor");88 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);89 Assert.assertEquals(action.getFaultString(), FAULT_STRING);90 }91 @Test92 public void testSendSoapFaultByEndpointName() {93 TestContext context = applicationContext.getBean(TestContext.class);94 context.setApplicationContext(applicationContextMock);95 reset(applicationContextMock, soapServer, messageProducer);96 when(soapServer.createProducer()).thenReturn(messageProducer);97 when(soapServer.getActor()).thenReturn(null);98 doAnswer(invocation -> {99 SoapFault message = (SoapFault) invocation.getArguments()[0];100 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);101 Assert.assertEquals(message.getFaultString(), FAULT_STRING);102 return null;103 }).when(messageProducer).send(any(Message.class), any(TestContext.class));104 when(applicationContextMock.getBean(TestContext.class)).thenReturn(context);105 when(applicationContextMock.getBean("soapServer", Endpoint.class)).thenReturn(soapServer);106 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());107 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());108 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());109 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) {110 @Override111 public void execute() {112 soap(builder -> builder.server("soapServer")113 .sendFault()114 .faultCode(FAULT_CODE)115 .faultString(FAULT_STRING));116 }117 };118 TestCase test = builder.getTestCase();119 Assert.assertEquals(test.getActionCount(), 1);120 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);121 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();122 Assert.assertEquals(action.getName(), "send");123 Assert.assertEquals(action.getEndpoint(), soapServer);124 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);125 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();126 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");127 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);128 Assert.assertNull(action.getFaultActor());129 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);130 Assert.assertEquals(action.getFaultString(), FAULT_STRING);131 }132 @Test133 public void testSendSoapFaultWithDetailResource() throws IOException {134 reset(resource, soapServer, messageProducer);135 when(soapServer.createProducer()).thenReturn(messageProducer);136 when(soapServer.getActor()).thenReturn(null);137 doAnswer(invocation -> {138 SoapFault message = (SoapFault) invocation.getArguments()[0];139 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);140 Assert.assertEquals(message.getFaultString(), FAULT_STRING);141 Assert.assertEquals(message.getFaultDetails().size(), 1L);142 Assert.assertEquals(message.getFaultDetails().get(0), ERROR_DETAIL);143 return null;144 }).when(messageProducer).send(any(Message.class), any(TestContext.class));145 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream(ERROR_DETAIL.getBytes()));146 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {147 @Override148 public void execute() {149 soap(builder -> builder.server(soapServer)150 .sendFault()151 .faultCode(FAULT_CODE)152 .faultDetailResource(resource)153 .faultString(FAULT_STRING));154 }155 };156 TestCase test = builder.getTestCase();157 Assert.assertEquals(test.getActionCount(), 1);158 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);159 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();160 Assert.assertEquals(action.getName(), "send");161 Assert.assertEquals(action.getEndpoint(), soapServer);162 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);163 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();164 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");165 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);166 Assert.assertEquals(action.getFaultDetails().size(), 1L);167 Assert.assertEquals(action.getFaultDetails().get(0), ERROR_DETAIL);168 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);169 Assert.assertEquals(action.getFaultString(), FAULT_STRING);170 }171 @Test172 public void testSendSoapFaultWithDetail() {173 reset(soapServer, messageProducer);174 when(soapServer.createProducer()).thenReturn(messageProducer);175 when(soapServer.getActor()).thenReturn(null);176 doAnswer(invocation -> {177 SoapFault message = (SoapFault) invocation.getArguments()[0];178 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);179 Assert.assertEquals(message.getFaultString(), FAULT_STRING);180 Assert.assertEquals(message.getFaultDetails().size(), 1L);181 Assert.assertEquals(message.getFaultDetails().get(0), "DETAIL");182 return null;183 }).when(messageProducer).send(any(Message.class), any(TestContext.class));184 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {185 @Override186 public void execute() {187 soap(builder -> builder.server(soapServer)188 .sendFault()189 .faultCode(FAULT_CODE)190 .faultDetail("DETAIL")191 .faultString(FAULT_STRING));192 }193 };194 TestCase test = builder.getTestCase();195 Assert.assertEquals(test.getActionCount(), 1);196 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);197 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();198 Assert.assertEquals(action.getName(), "send");199 Assert.assertEquals(action.getEndpoint(), soapServer);200 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);201 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();202 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");203 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);204 Assert.assertEquals(action.getFaultDetails().size(), 1L);205 Assert.assertEquals(action.getFaultDetails().get(0), "DETAIL");206 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);207 Assert.assertEquals(action.getFaultString(), FAULT_STRING);208 }209 @Test210 public void testSendSoapFaultWithDetailResourcePath() {211 reset(soapServer, messageProducer);212 when(soapServer.createProducer()).thenReturn(messageProducer);213 when(soapServer.getActor()).thenReturn(null);214 doAnswer(invocation -> {215 SoapFault message = (SoapFault) invocation.getArguments()[0];216 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);217 Assert.assertEquals(message.getFaultString(), FAULT_STRING);218 Assert.assertEquals(message.getFaultDetails().size(), 1L);219 Assert.assertEquals(message.getFaultDetails().get(0), ERROR_DETAIL);220 return null;221 }).when(messageProducer).send(any(Message.class), any(TestContext.class));222 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {223 @Override224 public void execute() {225 soap(builder -> builder.server(soapServer)226 .sendFault()227 .faultCode(FAULT_CODE)228 .faultDetailResource("classpath:com/consol/citrus/dsl/runner/soap-fault-detail.xml")229 .faultString(FAULT_STRING));230 }231 };232 TestCase test = builder.getTestCase();233 Assert.assertEquals(test.getActionCount(), 1);234 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);235 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();236 Assert.assertEquals(action.getName(), "send");237 Assert.assertEquals(action.getEndpoint(), soapServer);238 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);239 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();240 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");241 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);242 Assert.assertEquals(action.getFaultDetails().size(), 0L);243 Assert.assertEquals(action.getFaultDetailResourcePaths().size(), 1L);244 Assert.assertEquals(action.getFaultDetailResourcePaths().get(0), "classpath:com/consol/citrus/dsl/runner/soap-fault-detail.xml");245 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);246 Assert.assertEquals(action.getFaultString(), FAULT_STRING);247 }248 @Test249 public void testSendSoapFaultWithMultipleDetail() {250 reset(soapServer, messageProducer);251 when(soapServer.createProducer()).thenReturn(messageProducer);252 when(soapServer.getActor()).thenReturn(null);253 doAnswer(invocation -> {254 SoapFault message = (SoapFault) invocation.getArguments()[0];255 Assert.assertEquals(message.getFaultCode(), FAULT_CODE);256 Assert.assertEquals(message.getFaultString(), FAULT_STRING);257 Assert.assertEquals(message.getFaultDetails().size(), 2L);258 Assert.assertEquals(message.getFaultDetails().get(0), "DETAIL1");259 Assert.assertEquals(message.getFaultDetails().get(1), "DETAIL2");260 return null;261 }).when(messageProducer).send(any(Message.class), any(TestContext.class));262 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {263 @Override264 public void execute() {265 soap(builder -> builder.server(soapServer)266 .sendFault()267 .faultCode(FAULT_CODE)268 .faultDetail("DETAIL1")269 .faultDetail("DETAIL2")270 .faultString(FAULT_STRING));271 }272 };273 TestCase test = builder.getTestCase();274 Assert.assertEquals(test.getActionCount(), 1);275 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);276 SendSoapFaultAction action = (SendSoapFaultAction)((DelegatingTestAction)test.getActions().get(0)).getDelegate();277 Assert.assertEquals(action.getName(), "send");278 Assert.assertEquals(action.getEndpoint(), soapServer);279 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);280 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();281 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");282 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);283 Assert.assertEquals(action.getFaultDetails().size(), 2L);284 Assert.assertEquals(action.getFaultDetails().get(0), "DETAIL1");285 Assert.assertEquals(action.getFaultDetails().get(1), "DETAIL2");286 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);287 Assert.assertEquals(action.getFaultString(), FAULT_STRING);288 }289}...

Full Screen

Full Screen

Source:SendSoapFaultTestDesignerTest.java Github

copy

Full Screen

...68 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");69 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);70 Assert.assertEquals(action.getFaultActor(), "faultActor");71 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);72 Assert.assertEquals(action.getFaultString(), FAULT_STRING);73 }74 @Test75 public void testSendSoapFaultByEndpointName() {76 reset(applicationContextMock);77 when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners());78 when(applicationContextMock.getBean("soapServer", Endpoint.class)).thenReturn(soapServer);79 when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)).thenReturn(new HashMap<String, SequenceBeforeTest>());80 when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)).thenReturn(new HashMap<String, SequenceAfterTest>());81 MockTestDesigner builder = new MockTestDesigner(applicationContextMock, context) {82 @Override83 public void configure() {84 soap().server("soapServer")85 .sendFault()86 .faultCode(FAULT_CODE)87 .faultString(FAULT_STRING);88 }89 };90 builder.configure();91 TestCase test = builder.getTestCase();92 Assert.assertEquals(test.getActionCount(), 1);93 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);94 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendSoapFaultAction.class);95 SendSoapFaultAction action = (SendSoapFaultAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();96 Assert.assertEquals(action.getName(), "send");97 Assert.assertEquals(action.getEndpoint(), soapServer);98 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);99 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();100 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");101 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);102 Assert.assertNull(action.getFaultActor());103 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);104 Assert.assertEquals(action.getFaultString(), FAULT_STRING);105 }106 @Test107 public void testSendSoapFaultWithDetailResource() throws IOException {108 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {109 @Override110 public void configure() {111 soap().server(soapServer)112 .sendFault()113 .faultCode(FAULT_CODE)114 .faultDetailResource(resource)115 .faultString(FAULT_STRING);116 }117 };118 reset(resource);119 when(resource.getInputStream()).thenReturn(new ByteArrayInputStream("someDetailData".getBytes()));120 builder.configure();121 TestCase test = builder.getTestCase();122 Assert.assertEquals(test.getActionCount(), 1);123 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);124 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendSoapFaultAction.class);125 SendSoapFaultAction action = (SendSoapFaultAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();126 Assert.assertEquals(action.getName(), "send");127 Assert.assertEquals(action.getEndpoint(), soapServer);128 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);129 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();130 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");131 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);132 Assert.assertEquals(action.getFaultDetails().size(), 1L);133 Assert.assertEquals(action.getFaultDetails().get(0), "someDetailData");134 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);135 Assert.assertEquals(action.getFaultString(), FAULT_STRING);136 }137 @Test138 public void testSendSoapFaultWithDetail() {139 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {140 @Override141 public void configure() {142 soap().server(soapServer)143 .sendFault()144 .faultCode(FAULT_CODE)145 .faultDetail("DETAIL")146 .faultString(FAULT_STRING);147 }148 };149 builder.configure();150 TestCase test = builder.getTestCase();151 Assert.assertEquals(test.getActionCount(), 1);152 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);153 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendSoapFaultAction.class);154 SendSoapFaultAction action = (SendSoapFaultAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();155 Assert.assertEquals(action.getName(), "send");156 Assert.assertEquals(action.getEndpoint(), soapServer);157 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);158 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();159 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");160 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);161 Assert.assertEquals(action.getFaultDetails().size(), 1L);162 Assert.assertEquals(action.getFaultDetails().get(0), "DETAIL");163 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);164 Assert.assertEquals(action.getFaultString(), FAULT_STRING);165 }166 @Test167 public void testSendSoapFaultWithDetailResourcePath() {168 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {169 @Override170 public void configure() {171 soap().server(soapServer)172 .sendFault()173 .faultCode(FAULT_CODE)174 .faultDetailResource("com/consol/citrus/soap/fault.xml")175 .faultString(FAULT_STRING);176 }177 };178 builder.configure();179 TestCase test = builder.getTestCase();180 Assert.assertEquals(test.getActionCount(), 1);181 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);182 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendSoapFaultAction.class);183 SendSoapFaultAction action = (SendSoapFaultAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();184 Assert.assertEquals(action.getName(), "send");185 Assert.assertEquals(action.getEndpoint(), soapServer);186 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);187 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();188 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");189 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);190 Assert.assertEquals(action.getFaultDetails().size(), 0L);191 Assert.assertEquals(action.getFaultDetailResourcePaths().size(), 1L);192 Assert.assertEquals(action.getFaultDetailResourcePaths().get(0), "com/consol/citrus/soap/fault.xml");193 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);194 Assert.assertEquals(action.getFaultString(), FAULT_STRING);195 }196 @Test197 public void testSendSoapFaultWithMultipleDetail() {198 MockTestDesigner builder = new MockTestDesigner(applicationContext, context) {199 @Override200 public void configure() {201 soap().server(soapServer)202 .sendFault()203 .faultCode(FAULT_CODE)204 .faultDetail("DETAIL1")205 .faultDetail("DETAIL2")206 .faultString(FAULT_STRING);207 }208 };209 builder.configure();210 TestCase test = builder.getTestCase();211 Assert.assertEquals(test.getActionCount(), 1);212 Assert.assertEquals(test.getActions().get(0).getClass(), DelegatingTestAction.class);213 Assert.assertEquals(((DelegatingTestAction)test.getActions().get(0)).getDelegate().getClass(), SendSoapFaultAction.class);214 SendSoapFaultAction action = (SendSoapFaultAction) ((DelegatingTestAction)test.getActions().get(0)).getDelegate();215 Assert.assertEquals(action.getName(), "send");216 Assert.assertEquals(action.getEndpoint(), soapServer);217 Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);218 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();219 Assert.assertEquals(messageBuilder.getMessage().getPayload(), "");220 Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 0L);221 Assert.assertEquals(action.getFaultDetails().size(), 2L);222 Assert.assertEquals(action.getFaultDetails().get(0), "DETAIL1");223 Assert.assertEquals(action.getFaultDetails().get(1), "DETAIL2");224 Assert.assertEquals(action.getFaultCode(), FAULT_CODE);225 Assert.assertEquals(action.getFaultString(), FAULT_STRING);226 }227}...

Full Screen

Full Screen

Source:SendSoapFaultActionTest.java Github

copy

Full Screen

...55 Message sentMessage = (Message)invocation.getArguments()[0];56 Assert.assertTrue(sentMessage instanceof SoapFault);57 SoapFault soapFault = (SoapFault) sentMessage;58 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");59 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");60 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);61 return null;62 }63 }).when(producer).send(any(Message.class), any(TestContext.class));64 when(endpoint.getActor()).thenReturn(null);65 66 sendSoapFaultAction.execute(context);67 }68 69 @Test70 @SuppressWarnings("rawtypes")71 public void testSendSoapFaultWithActor() {72 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();73 sendSoapFaultAction.setEndpoint(endpoint);74 75 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");76 sendSoapFaultAction.setFaultString("Internal server error");77 sendSoapFaultAction.setFaultActor("SERVER");78 79 reset(endpoint, producer, endpointConfiguration);80 when(endpoint.createProducer()).thenReturn(producer);81 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);82 when(endpointConfiguration.getTimeout()).thenReturn(5000L);83 doAnswer(new Answer() {84 @Override85 public Object answer(InvocationOnMock invocation) throws Throwable {86 Message sentMessage = (Message)invocation.getArguments()[0];87 Assert.assertTrue(sentMessage instanceof SoapFault);88 SoapFault soapFault = (SoapFault) sentMessage;89 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");90 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");91 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);92 Assert.assertEquals(soapFault.getFaultActor(), "SERVER");93 return null;94 }95 }).when(producer).send(any(Message.class), any(TestContext.class));96 when(endpoint.getActor()).thenReturn(null);97 98 sendSoapFaultAction.execute(context);99 }100 101 @Test102 @SuppressWarnings("rawtypes")103 public void testSendSoapFaultMissingFaultString() {104 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();105 sendSoapFaultAction.setEndpoint(endpoint);106 107 sendSoapFaultAction.setFaultCode("{http://citrusframework.org}ws:TEC-1000");108 109 reset(endpoint, producer, endpointConfiguration);110 when(endpoint.createProducer()).thenReturn(producer);111 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);112 when(endpointConfiguration.getTimeout()).thenReturn(5000L);113 doAnswer(new Answer() {114 @Override115 public Object answer(InvocationOnMock invocation) throws Throwable {116 Message sentMessage = (Message)invocation.getArguments()[0];117 Assert.assertTrue(sentMessage instanceof SoapFault);118 SoapFault soapFault = (SoapFault) sentMessage;119 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");120 Assert.assertNull(soapFault.getFaultString());121 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);122 return null;123 }124 }).when(producer).send(any(Message.class), any(TestContext.class));125 when(endpoint.getActor()).thenReturn(null);126 127 sendSoapFaultAction.execute(context);128 }129 130 @Test131 @SuppressWarnings("rawtypes")132 public void testSendSoapFaultWithVariableSupport() {133 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();134 sendSoapFaultAction.setEndpoint(endpoint);135 136 sendSoapFaultAction.setFaultCode("citrus:concat('{http://citrusframework.org}ws:', ${faultCode})");137 sendSoapFaultAction.setFaultString("${faultString}");138 139 context.setVariable("faultCode", "TEC-1000");140 context.setVariable("faultString", "Internal server error");141 reset(endpoint, producer, endpointConfiguration);142 when(endpoint.createProducer()).thenReturn(producer);143 when(endpoint.getEndpointConfiguration()).thenReturn(endpointConfiguration);144 when(endpointConfiguration.getTimeout()).thenReturn(5000L);145 doAnswer(new Answer() {146 @Override147 public Object answer(InvocationOnMock invocation) throws Throwable {148 Message sentMessage = (Message)invocation.getArguments()[0];149 Assert.assertTrue(sentMessage instanceof SoapFault);150 SoapFault soapFault = (SoapFault) sentMessage;151 Assert.assertEquals(soapFault.getFaultCode(), "{http://citrusframework.org}ws:TEC-1000");152 Assert.assertEquals(soapFault.getFaultString(), "Internal server error");153 Assert.assertEquals(soapFault.getLocale(), Locale.ENGLISH);154 return null;155 }156 }).when(producer).send(any(Message.class), any(TestContext.class));157 when(endpoint.getActor()).thenReturn(null);158 159 sendSoapFaultAction.execute(context);160 }161 162 @Test163 public void testSendSoapFaultMissingFaultCode() {164 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();165 sendSoapFaultAction.setEndpoint(endpoint);166 ...

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.exceptions.CitrusRuntimeException;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import com.consol.citrus.ws.message.SoapFault;5import org.easymock.EasyMock;6import org.springframework.ws.soap.SoapFaultDetail;7import org.springframework.ws.soap.SoapFaultDetailElement;8import org.springframework.ws.soap.SoapFaultDetailElementName;9import org.springframework.ws.soap.SoapFaultDetailException;10import org.testng.Assert;11import org.testng.annotations.Test;12import javax.xml.namespace.QName;13import java.util.HashMap;14import java.util.Map;15public class SendSoapFaultActionTest extends AbstractTestNGUnitTest {16 public void testGetFaultString() {17 SoapFaultDetailException exception = EasyMock.createMock(SoapFaultDetailException.class);18 SoapFaultDetail detail = EasyMock.createMock(SoapFaultDetail.class);19 SoapFaultDetailElement detailElement = EasyMock.createMock(SoapFaultDetailElement.class);20 SoapFaultDetailElementName detailElementName = EasyMock.createMock(SoapFaultDetailElementName.class);21 EasyMock.expect(exception.getFaultDetail()).andReturn(detail).anyTimes();22 EasyMock.expect(detail.getDetailEntries()).andReturn(new SoapFaultDetailElement[]{detailElement}).anyTimes();23 EasyMock.expect(detailElement.getName()).andReturn(detailElementName).anyTimes();24 EasyMock.expect(detailElementName.getLocalPart()).andReturn("faultstring").anyTimes();25 EasyMock.expect(detailElement.getText()).andReturn("faultstring").anyTimes();26 EasyMock.replay(exception, detail, detailElement, detailElementName);27 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();28 sendSoapFaultAction.setSoapFaultDetailException(exception);29 Assert.assertEquals(sendSoapFaultAction.getFaultString(), "faultstring");30 EasyMock.verify(exception, detail, detailElement, detailElementName);31 }32 @Test(expectedExceptions = CitrusRuntimeException.class)33 public void testGetFaultStringNoFaultString() {34 SoapFaultDetailException exception = EasyMock.createMock(SoapFaultDetailException.class);35 SoapFaultDetail detail = EasyMock.createMock(SoapFaultDetail.class);36 SoapFaultDetailElement detailElement = EasyMock.createMock(SoapFaultDetailElement.class);37 SoapFaultDetailElementName detailElementName = EasyMock.createMock(So

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.exceptions.CitrusRuntimeException;4import com.consol.citrus.message.Message;5import com.consol.citrus.message.MessageBuilder;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.message.builder.DefaultMessageBuilder;8import com.consol.citrus.message.builder.PayloadTemplateMessageBuilder;9import com.consol.citrus.message.builder.SimpleMessageBuilder;10import com.consol.citrus.testng.AbstractTestNGUnitTest;11import com.consol.citrus.ws.message.SoapFault;12import com.consol.citrus.ws.message.SoapFaultDefinition;13import com.consol.citrus.ws.message.SoapFaultDefinitionBuilder;14import org.springframework.core.io.ClassPathResource;15import org.springframework.util.StringUtils;16import org.testng.Assert;17import org.testng.annotations.Test;18import java.io.IOException;19import java.util.HashMap;20import java.util.Map;21public class SendSoapFaultActionTest extends AbstractTestNGUnitTest {22 public void testSendSoapFaultActionBuilder() {23 MockSendSoapFaultActionBuilder builder = new MockSendSoapFaultActionBuilder();24 builder.faultCode("faultCode");25 builder.faultString("faultString");26 builder.faultActor("faultActor");27 builder.detailResourcePath("classpath:com/consol/citrus/ws/actions/detail.xml");28 builder.detailResourceData("detailData");29 builder.detailResourceCharset("UTF-8");30 builder.namespace("soap11");31 builder.namespacePrefix("soap11");32 builder.messageType(MessageType.PLAINTEXT);33 builder.messageName("soapFaultMessage");34 builder.build();35 Assert.assertEquals(builder.getFaultCode(), "faultCode");36 Assert.assertEquals(builder.getFaultString(), "faultString");37 Assert.assertEquals(builder.getFaultActor(), "faultActor");38 Assert.assertEquals(builder.getDetailResourcePath(), "classpath:com/consol/citrus/ws/actions/detail.xml");39 Assert.assertEquals(builder.getDetailResourceData(), "detailData");40 Assert.assertEquals(builder.getDetailResourceCharset(), "UTF-8");41 Assert.assertEquals(builder.getNamespace(), "soap11");42 Assert.assertEquals(builder.getNamespacePrefix(), "soap11");

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.exceptions.CitrusRuntimeException;4import com.consol.citrus.message.Message;5import com.consol.citrus.message.MessageBuilder;6import com.consol.citrus.report.TestActionListeners;7import com.consol.citrus.ws.message.SoapFault;8import com.consol.citrus.ws.message.SoapMessage;9import com.consol.citrus.ws.message.SoapMessageHeaders;10import org.slf4j.Logger;11import org.slf4j.LoggerFactory;12import org.springframework.util.Assert;13import org.springframework.util.CollectionUtils;14import org.springframework.util.StringUtils;15import org.springframework.ws.soap.SoapBody;16import org.springframework.ws.soap.SoapEnvelope;17import org.springframework.ws.soap.SoapVersion;18import org.springframework.ws.soap.client.SoapFaultClientException;19import org.springframework.ws.soap.server.SoapFaultDefinition;20import org.springframework.ws.soap.server.SoapFaultDefinitionEditor;21import org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver;22import org.springframework.ws.soap.soap11.Soap11Body;23import org.springframework.ws.soap.soap11.Soap11Envelope;24import org.springframework.ws.soap.soap12.Soap12Body;25import org.springframework.ws.soap.soap12.Soap12Envelope;26import org.springframework.ws.soap.soap12.Soap12Fault;27import org.springframework.ws.soap.soap12.Soap12Reason;28import org.springframework.ws.soap.soap12.Soap12ReasonText;29import org.springframework.ws.soap.soap12.Soap12Role;30import org.springframework.ws.soap.soap12.Soap12ServerOrReceiverFault;31import org.springframework.ws.soap.soap12.Soap12ServerOrReceiverFaultDefinition;32import org.springframework.ws.soap.soap12.Soap12SenderFault;33import org.springframework.ws.soap.soap12.Soap12SenderFaultDefinition;34import org.springframework.ws.soap.soap12.Soap12SoapFault;35import org.springframework.ws.soap.soap12.Soap12SubCode;36import org.springframework.ws.soap.soap12.Soap12SubCodeValue;37import org.springframework.ws.soap.soap12.Soap12Text;38import org.springframework.ws.soap.soap12.Soap12VersionMismatchFault;39import org.springframework.ws.soap.soap12.Soap12VersionMismatchFaultDefinition;40import org.springframework

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.ws.message.SoapFault;4import com.consol.citrus.ws.message.SoapFaultDefinition;5import com.consol.citrus.ws.message.SoapMessage;6import org.slf4j.Logger;7import org.slf4j.LoggerFactory;8import org.springframework.ws.soap.SoapBody;9import org.springframework.ws.soap.SoapFaultDetail;10import org.springframework.ws.soap.SoapFaultDetailElement;11import org.springframework.ws.soap.SoapMessageFactory;12import javax.xml.namespace.QName;13import java.util.HashMap;14import java.util.Map;15public class SendSoapFaultAction extends AbstractSoapAction {16 private static Logger log = LoggerFactory.getLogger(SendSoapFaultAction.class);17 private final SoapFaultDefinition faultDefinition;18 private String faultMessage;19 private Map<String, Object> faultDetail = new HashMap<String, Object>();20 private String faultDetailName;21 public SendSoapFaultAction(String name, SoapFaultDefinition faultDefinition) {22 super(name);23 this.faultDefinition = faultDefinition;24 }25 public void doExecute(TestContext context) {26 SoapMessageFactory messageFactory = getWebServiceMessageFactory(context);27 SoapMessage faultMessage = new SoapMessage(messageFactory.createWebServiceMessage());28 SoapBody soapBody = faultMessage.getSoapBody();29 SoapFault soapFault = soapBody.addServerOrReceiverFault(getFaultString(context), faultDefinition.getFaultCode());30 if (faultDetailName != null) {31 SoapFaultDetail faultDetail = soapFault.addFaultDetail();32 for (Map.Entry<String, Object> entry : faultDetail.entrySet()) {33 SoapFaultDetailElement faultDetailElement = faultDetail.addFaultDetailElement(new QName(faultDetailName, entry.getKey()));34 faultDetailElement.setText(entry.getValue().toString());35 }36 }37 log.info("Sending SOAP fault message: '" + faultMessage.toString() + "'");38 send(faultMessage, context);39 }40 private String getFaultString(TestContext context) {

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import com.consol.citrus.ws.message.SoapFault;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.ws.soap.SoapFaultDetail;6import org.springframework.ws.soap.SoapFaultDetailElement;7import org.springframework.ws.soap.SoapFaultDetailElementName;8import org.springframework.ws.soap.SoapFaultDetailException;9import org.springframework.ws.soap.SoapFaultDetailExceptionDefinition;10import org.springframework.ws.soap.SoapFaultDetailExceptionTranslator;11import org.springframework.ws.soap.SoapFaultDetailText;12import org.springframework.ws.soap.SoapFaultDetailTextExceptionDefinition;13import org.springframework.ws.soap.SoapFaultDetailTextExceptionTranslator;14import org.springframework.ws.soap.SoapFaultDetailXml;15import org.springframework.ws.soap.SoapFaultDetailXmlExceptionDefinition;16import org.springframework.ws.soap.SoapFaultDetailXmlExceptionTranslator;17import org.springframework.ws.soap.SoapFaultException;18import org.springframework.ws.soap.SoapFaultExceptionDefinition;19import org.springframework.ws.soap.SoapFaultExceptionTranslator;20import org.springframework.ws.soap.SoapFaultMappingExceptionResolver;21import org.springframework.ws.soap.SoapFaultMappingExceptionResolverDefinition;22import org.springframework.ws.soap.SoapFaultMappingInfo;23import org.springframework.ws.soap.SoapFaultMappingInfoExceptionDefinition;24import org.springframework.ws.soap.SoapFaultMappingInfoExceptionTranslator;25import org.springframework.ws.soap.SoapFaultReason;26import org.springframework.ws.soap.SoapFaultReasonText;27import org.springframework.ws.soap.SoapFaultReasonTextExceptionDefinition;28import org.springframework.ws.soap.SoapFaultReasonTextExceptionTranslator;29import org.springframework.ws.soap.SoapFaultReasonXml;30import org.springframework.ws.soap.SoapFaultReasonXmlExceptionDefinition;31import org.springframework.ws.soap.SoapFaultReasonXmlExceptionTranslator;32import org.springframework.ws.soap.SoapFaultSubCode;33import org.springframework.ws.soap.SoapFaultSubCodeExceptionDefinition;34import org.springframework.ws.soap.SoapFaultSubCodeExceptionTranslator;35import org.springframework.ws.soap.SoapFaultSubCodeValue;36import org.springframework.ws.soap.SoapFaultSubCodeValueExceptionDefinition;37import org.springframework.ws.soap.SoapFaultSubCodeValueExceptionTranslator;38import org.springframework.ws.soap.SoapFaultVersionMismatchException;39import org.springframework.ws.soap.SoapFaultVersionMismatch

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import org.testng.annotations.Test;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4public class GetFaultStringTest extends AbstractTestNGUnitTest {5public void testGetFaultString() {6SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();7sendSoapFaultAction.setFaultString("faultString");8sendSoapFaultAction.getFaultString();9}10}11[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ 3 ---12[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ 3 ---13[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ 3 ---14[INFO] --- maven-install-plugin:2.4:install (default-install) @ 3 ---

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.actions;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.ws.interceptor.SoapFaultInterceptor;4import com.consol.citrus.ws.message.SoapFault;5import org.springframework.ws.WebServiceMessage;6import org.springframework.ws.soap.SoapMessage;7import org.springframework.ws.soap.SoapMessageFactory;8import org.springframework.ws.soap.SoapVersion;9public class SendSoapFaultAction extends AbstractSendSoapFaultAction<SendSoapFaultAction> {10 private final SoapFaultInterceptor soapFaultInterceptor = new SoapFaultInterceptor();11 private final SoapFault soapFault;12 public SendSoapFaultAction(SoapFault soapFault) {13 this.soapFault = soapFault;14 }15 public void doExecute(TestContext context) {16 SoapMessageFactory messageFactory = getSoapMessageFactory(context);17 SoapMessage response = messageFactory.createWebServiceMessage().getPayload(SoapMessage.class);18 soapFaultInterceptor.setSoapFault(soapFault);19 soapFaultInterceptor.setSoapVersion(SoapVersion.fromVersionString(response.getVersion().getEnvelopeNamespaceUri()));20 soapFaultInterceptor.handleFault(response, null);21 }22 public String getFaultString() {23 return soapFault.getFaultString();24 }25}26package com.consol.citrus.ws.actions;27import com.consol.citrus.context.TestContext;28import com.consol.citrus.ws.interceptor.SoapFaultInterceptor;29import com.consol.citrus.ws.message.SoapFault;30import org.springframework.ws.WebServiceMessage;31import org.springframework.ws.soap.SoapMessage;32import org.springframework.ws.soap.SoapMessageFactory;33import org.springframework.ws.soap.SoapVersion;34public class SendSoapFaultAction extends AbstractSendSoapFaultAction<SendSoapFaultAction> {35 private final SoapFaultInterceptor soapFaultInterceptor = new SoapFaultInterceptor();36 private final SoapFault soapFault;37 public SendSoapFaultAction(SoapFault soapFault) {38 this.soapFault = soapFault;39 }40 public void doExecute(TestContext context) {

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package org.citrusframework.demo;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.Import;5import com.consol.citrus.dsl.endpoint.CitrusEndpoints;6import com.consol.citrus.dsl.runner.TestRunner;7import com.consol.citrus.dsl.runner.TestRunnerBeforeSuiteSupport;8import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;9import com.consol.citrus.message.MessageType;10import com.consol.citrus.testng.CitrusParameters;11import com.consol.citrus.ws.client.WebServiceClient;12import com.consol.citrus.ws.server.WebServiceServer;13@Import({com.consol.citrus.dsl.CitrusSpringConfig.class, com.consol.citrus.ws.spring.WebServiceConfig.class})14public class CitrusConfig extends TestNGCitrusTestDesigner {15 public WebServiceServer echoServer() {16 return CitrusEndpoints.soap()17 .server()18 .port(8080)19 .autoStart(true)20 .build();21 }22 public WebServiceClient echoClient() {23 return CitrusEndpoints.soap()24 .client()25 .build();26 }27 @CitrusParameters({"faultCode", "faultString"})28 public void configure() {29 description("Send SOAP fault and validate fault code and fault string");30 variable("faultCode", "soap:Server");31 variable("faultString", "Internal Server Error");32 send(echoClient())33 .header("Content-Type", "text/xml;charset=UTF-8")34 .soap()35 .fault()36 .faultCode("${faultCode}")37 .faultString("${faultString}");38 receive(echoServer())

Full Screen

Full Screen

getFaultString

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.ws.actions.SendSoapFaultAction;5import org.testng.annotations.Test;6import static com.consol.citrus.actions.EchoAction.Builder.echo;7import static com.consol.citrus.actions.SendMessageAction.Builder.soap;8import static com.consol.citrus.actions.SoapActionBuilder.soap;9import static com.consol.citrus.actions.SoapActionBuilder.soapFault;10import static com.consol.citrus.actions.SoapActionBuilder.soapFault;11public class getFaultString extends TestNGCitrusTestRunner {12public void getFaultString() {13SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();14sendSoapFaultAction.setFaultString("fault string");15sendSoapFaultAction.setFaultCode("fault code");16sendSoapFaultAction.setFaultActor("fault actor");17sendSoapFaultAction.setFaultDetail("fault detail");18sendSoapFaultAction.setEndpoint("soapFaultEndpoint");19sendSoapFaultAction.setFaultCodeNamespace("fault code namespace");20sendSoapFaultAction.setFaultStringOrReason("fault string or reason");21sendSoapFaultAction.setFaultRole("fault role");22sendSoapFaultAction.setFaultNode("fault node");23sendSoapFaultAction.setFaultDetail("fault detail");24sendSoapFaultAction.setFaultDetailNamespace("fault detail namespace");25sendSoapFaultAction.setFaultDetailPrefix("fault detail prefix");26sendSoapFaultAction.setFaultDetailType("fault detail type");27sendSoapFaultAction.setFaultDetailElementName("fault detail element name");28sendSoapFaultAction.setFaultDetailElementNamespace("fault detail element namespace");29sendSoapFaultAction.setFaultDetailElementPrefix("fault detail element prefix");30sendSoapFaultAction.setFaultDetailElementValue("fault detail element value");31sendSoapFaultAction.setFaultDetailElementAttributes("fault detail element attributes");32sendSoapFaultAction.setFaultDetailElementChildElements("fault detail element child elements");33sendSoapFaultAction.setFaultDetailElementAttributeNamespace("fault detail element attribute namespace");34sendSoapFaultAction.setFaultDetailElementAttributePrefix("fault detail element attribute prefix");35sendSoapFaultAction.setFaultDetailElementAttributeValue("fault detail element attribute value");36sendSoapFaultAction.setFaultDetailElementChildElementNamespace("fault detail

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful