Best Citrus code snippet using com.consol.citrus.ws.actions.SendSoapFaultAction.getFaultCode
Source:SendSoapFaultTestRunnerTest.java
...59 when(soapServer.getActor()).thenReturn(null);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}...
Source:SendSoapFaultTestDesignerTest.java
...67 StaticMessageContentBuilder messageBuilder = (StaticMessageContentBuilder) action.getMessageBuilder();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}...
Source:SendSoapFaultActionTest.java
...54 public Object answer(InvocationOnMock invocation) throws Throwable {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);...
getFaultCode
Using AI Code Generation
1package com.consol.citrus;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.ws.actions.SendSoapFaultAction;5import org.testng.annotations.Test;6import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;7import static com.consol.citrus.actions.EchoAction.Builder.echo;8import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;9import static com.consol.citrus.container.SequenceBeforeTest.Builder.sequential;10import static com.consol.citrus.container.While.Builder.whWhile;11import static com.consol.citrus.dsl.XpathSupport.xPath;12import static com.consol.citrus.dsl.XpathSupport.xPathResult;13import static com.consol.citrus.ws.actions.SendSoapFaultAction.Builder.sendSoapFault;14public class Test3 extends AbstractTestNGCitrusTest {15 @CitrusParameters({"param1", "param2"})16 public void test1(String param1, String param2) {17 echo("This is a test");18 }19 public void test2() {20 }21 public void test3() {22 }23 public void test4() {24 }25 public void test5() {
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.message.SoapFault;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.core.io.ClassPathResource;8import org.springframework.ws.soap.SoapFaultDetail;9import org.testng.annotations.Test;10import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;11import static com.consol.citrus.actions.EchoAction.Builder.echo;12import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;13import static com.consol.citrus.actions.ExecuteSQLQueryAction.Builder.sql;14import static com.consol.citrus.actions.PurgeJmsQueuesAction.Builder.purgeQueues;15import static com.consol.citrus.actions.ReceiveMessageAction.Builder.receive;16import static com.consol.citrus.actions.SendMessageAction.Builder.send;17import static com.consol.citrus.actions.SleepAction.Builder.sleep;18import static com.consol.citrus.actions.S
getFaultCode
Using AI Code Generation
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.testng.Assert;6import org.testng.annotations.Test;7import java.util.Map;8import java.util.HashMap;9public class GetFaultCodeTest extends AbstractTestNGUnitTest {10 private SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();11 public void testGetFaultCode() {12 SoapFault soapFault = new SoapFault();13 soapFault.setFaultCode("Server");14 sendSoapFaultAction.setFault(soapFault);15 Assert.assertEquals(sendSoapFaultAction.getFaultCode(), "Server");16 }17}18package com.consol.citrus.ws.actions;19import com.consol.citrus.exceptions.CitrusRuntimeException;20import com.consol.citrus.testng.AbstractTestNGUnitTest;21import com.consol.citrus.ws.message.SoapFault;22import org.testng.Assert;23import org.testng.annotations.Test;24import java.util.Map;25import java.util.HashMap;26public class GetFaultReasonTest extends AbstractTestNGUnitTest {27 private SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();28 public void testGetFaultReason() {29 SoapFault soapFault = new SoapFault();30 soapFault.setFaultReason("Server Fault");31 sendSoapFaultAction.setFault(soapFault);32 Assert.assertEquals(sendSoapFaultAction.getFaultReason(), "Server Fault");33 }34}35package com.consol.citrus.ws.actions;36import com.consol.citrus.exceptions.CitrusRuntimeException;37import com.consol.citrus.testng.AbstractTestNGUnitTest;38import com.consol.citrus.ws.message.SoapFault;39import org.testng.Assert;40import org.testng.annotations.Test;41import java.util.Map;42import java.util.HashMap;43public class GetFaultActorTest extends AbstractTestNGUnitTest {44 private SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();45 public void testGetFaultActor() {
getFaultCode
Using AI Code Generation
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.ws.message.SoapFault;6import com.consol.citrus.ws.message.SoapFaultDefinition;7import com.consol.citrus.ws.message.SoapFaultDefinitionBuilder;8import org.springframework.ws.soap.SoapFaultDetail;9import org.springframework.ws.soap.SoapMessage;10import org.springframework.ws.soap.SoapMessageFactory;11import org.testng.Assert;12import org.testng.annotations.Test;13import java.util.HashMap;14import java.util.Map;15public class SendSoapFaultActionTest {16 private SendSoapFaultAction sendSoapFaultAction;17 public void testGetFaultCode() {18 sendSoapFaultAction = new SendSoapFaultAction();19 sendSoapFaultAction.setFaultCode("Client");20 Assert.assertEquals(sendSoapFaultAction.getFaultCode(), "Client");21 }22}23package com.consol.citrus.ws.actions;24import com.consol.citrus.context.TestContext;25import com.consol.citrus.exceptions.CitrusRuntimeException;26import com.consol.citrus.message.Message;27import com.consol.citrus.ws.message.SoapFault;28import com.consol.citrus.ws.message.SoapFaultDefinition;29import com.consol.citrus.ws.message.SoapFaultDefinitionBuilder;30import org.springframework.ws.soap.SoapFaultDetail;31import org.springframework.ws.soap.SoapMessage;32import org.springframework.ws.soap.SoapMessageFactory;33import org.testng.Assert;34import org.testng.annotations.Test;35import java.util.HashMap;36import java.util.Map;37public class SendSoapFaultActionTest {38 private SendSoapFaultAction sendSoapFaultAction;39 public void testSetFaultCode() {40 sendSoapFaultAction = new SendSoapFaultAction();41 sendSoapFaultAction.setFaultCode("faultCode");42 Assert.assertEquals(sendSoapFaultAction.getFaultCode(), "faultCode");43 }44}45package com.consol.citrus.ws.actions;46import com.consol
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import org.testng.annotations.Test;3import com.consol.citrus.annotations.CitrusTest;4import com.consol.citrus.testng.CitrusParameters;5import com.consol.citrus.ws.client.WebServiceClient;6import com.consol.citrus.ws.message.SoapFault;7import com.consol.citrus.ws.message.SoapFaultDetail;8import com.consol.citrus.ws.message.SoapFaultDetailEntry;9import com.consol.citrus.ws.message.SoapFaultDetailEntryData;10public class SendSoapFaultActionTestIT extends AbstractWSActionUnitTest {11 private final WebServiceClient webServiceClient = new WebServiceClient();12 private final SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();13 private final SoapFault soapFault = new SoapFault();14 private final SoapFaultDetail soapFaultDetail = new SoapFaultDetail();15 private final SoapFaultDetailEntry soapFaultDetailEntry = new SoapFaultDetailEntry();16 private final SoapFaultDetailEntryData soapFaultDetailEntryData = new SoapFaultDetailEntryData();17 @CitrusParameters("param1")18 public void getFaultCode() {19 sendSoapFaultAction.setWebServiceClient(webServiceClient);20 sendSoapFaultAction.setFault(soapFault);21 sendSoapFaultAction.setFaultDetail(soapFaultDetail);22 sendSoapFaultAction.setFaultDetailEntry(soapFaultDetailEntry);23 sendSoapFaultAction.setFaultDetailEntryData(soapFaultDetailEntryData);24 sendSoapFaultAction.getFaultCode();25 }26}27 public String getFaultCode() {28 return null;29 }
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.testng.AbstractTestNGUnitTest;3import com.consol.citrus.ws.message.SoapFault;4import org.mockito.Mockito;5import org.springframework.ws.soap.SoapMessage;6import org.springframework.ws.soap.saaj.SaajSoapMessage;7import org.testng.Assert;8import org.testng.annotations.Test;9import javax.xml.soap.SOAPFault;10import javax.xml.soap.SOAPFactory;11import javax.xml.soap.SOAPMessage;12public class SendSoapFaultActionTest extends AbstractTestNGUnitTest {13 public void testGetFaultCode() throws Exception {14 SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();15 sendSoapFaultAction.setFaultCode("Server");16 sendSoapFaultAction.setFaultString("faultString");17 sendSoapFaultAction.setFaultActor("faultActor");18 sendSoapFaultAction.setFaultDetail("faultDetail");19 sendSoapFaultAction.setFaultRole("faultRole");20 sendSoapFaultAction.setFaultSubCode("faultSubCode");21 sendSoapFaultAction.setFaultCodeNamespace("faultCodeNamespace");22 sendSoapFaultAction.setFaultStringNamespace("faultStringNamespace");23 sendSoapFaultAction.setFaultActorNamespace("faultActorNamespace");24 sendSoapFaultAction.setFaultDetailNamespace("faultDetailNamespace");25 sendSoapFaultAction.setFaultRoleNamespace("faultRoleNamespace");26 sendSoapFaultAction.setFaultSubCodeNamespace("faultSubCodeNamespace");27 SOAPMessage soapMessage = SOAPFactory.newInstance().createMessage();28 SOAPFault soapFault = soapMessage.getSOAPBody().addFault();29 soapFault.setFaultCode("faultCode");30 soapFault.setFaultString("faultString");31 soapFault.setFaultActor("faultActor");32 soapFault.addDetail().addTextNode("faultDetail");33 soapFault.setFaultRole("faultRole");34 soapFault.setFaultSubcode(SOAPFactory.newInstance().createName("faultSubCode"));35 SoapFault soapFault1 = new SoapFault(soapFault);36 SoapFault soapFault2 = sendSoapFaultAction.getFaultCode(soapFault1);37 Assert.assertEquals(soapFault2.getFaultCode(), "Server");38 Assert.assertEquals(soapFault2.getFaultString(), "faultString");39 Assert.assertEquals(soapFault2.getFaultActor(), "faultActor");40 Assert.assertEquals(soapFault2.getFaultDetail(), "faultDetail");
getFaultCode
Using AI Code Generation
1package com.consol.citrus.samples;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class GetFaultCode extends TestNGCitrusTestDesigner {5public void getFaultCode() {6sendFault()7.faultCode("env:Sender")8.faultString("SOAP-ENV:Sender")9echo("Fault code is: ${faultCode}");10}11}12package com.consol.citrus.samples;13import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;14import org.testng.annotations.Test;15public class GetFaultString extends TestNGCitrusTestDesigner {16public void getFaultString() {17sendFault()18.faultCode("env:Sender")19.faultString("SOAP-ENV:Sender")20echo("Fault string is: ${faultString}");21}22}23package com.consol.citrus.samples;24import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;25import org.testng.annotations.Test;26public class GetFaultActor extends TestNGCitrusTestDesigner {27public void getFaultActor() {28sendFault()29.faultCode("env:Sender")30.faultString("SOAP-ENV:Sender")
getFaultCode
Using AI Code Generation
1package org.citrusframework.demo;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.ImportResource;5import com.consol.citrus.dsl.builder.BuilderSupport;6import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder;7import com.consol.citrus.dsl.builder.HttpServerResponseActionBuilder.HttpResponseMessageBuilder;8import com.consol.citrus.dsl.builder.SendSoapFaultActionBuilder;9import com.consol.citrus.dsl.builder.SendSoapFaultActionBuilder.SendSoapFaultMessageBuilder;10import com.consol.citrus.dsl.runner.TestRunner;11import com.consol.citrus.dsl.runner.TestRunnerSupport;12import com.consol.citrus.dsl.testng.TestNGCitrusTest;13import com.consol.citrus.exceptions.CitrusRuntimeException;14import com.consol.citrus.http.client.HttpClient;15import com.consol.citrus.http.message.HttpMessage;16import com.consol.citrus.message.MessageType;17import com.consol.citrus.ws.client.WebServiceClient;18import com.consol.citrus.ws.message.SoapFault;19import com.consol.citrus.ws.message.SoapMessage;20import com.consol.citrus.ws.message.SoapMessageHeaders;21@ImportResource("classpath:com/consol/citrus/ws/spring-ws-config.xml")22public class TestNGSoapFaultTest extends TestNGCitrusTest {23 public HttpClient httpClient() {24 .http()25 .client()26 .build();27 }28 public WebServiceClient webServiceClient() {29 .soap()30 .client()31 .build();32 }33 public void testSoapFault() {34 $(soap()35 .client(webServiceClient())36 .send()37 .soapFault(SoapFault.clientOrSenderFault().faultString("Hello world!")));38 $(soap()39 .client(webServiceClient())40 .receive()41 .soapFault(SoapFault.clientOrSenderFault().faultString("Hello world!")));42 }43 public void testSoapFaultBuilder() {44 $(soap()45 .client(web
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import org.springframework.ws.soap.SoapFault;3public class GetFaultCode {4public static void main(String[] args) {5SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();6sendSoapFaultAction.setFaultCode("Client");7SoapFault faultCode = sendSoapFaultAction.getFaultCode();8}9}
getFaultCode
Using AI Code Generation
1package com.consol.citrus.ws.actions;2import com.consol.citrus.exceptions.ValidationException;3import com.consol.citrus.testng.AbstractTestNGUnitTest;4import com.consol.citrus.ws.message.SoapFault;5import org.springframework.ws.soap.SoapFaultDetail;6import org.springframework.ws.soap.SoapFaultDetailElement;7import org.springframework.ws.soap.SoapFaultDetailElementDefinition;8import org.springframework.ws.soap.SoapFaultDetailException;9import org.springframework.ws.soap.SoapFaultDetailExceptionDefinition;10import org.springframework.ws.soap.SoapFaultDetailText;11import org.springframework.ws.soap.SoapFaultDetailTextDefinition;12import org.springframework.ws.soap.SoapFaultDetailXmlData;13import org.springframework.ws.soap.SoapFaultDetailXmlDataDefinition;14import org.springframework.ws.soap.SoapFaultDetailXmlString;15import org.springframework.ws.soap.SoapFaultDetailXmlStringDefinition;16import org.springframework.ws.soap.SoapFaultException;17import org.springframework.ws.soap.SoapFaultExceptionDefinition;18import org.springframework.ws.soap.SoapFaultReason;19import org.springframework.ws.soap.SoapFaultReasonText;20import org.springframework.ws.soap.SoapFaultReasonTextDefinition;21import org.springframework.ws.soap.SoapFaultVersionMismatch;22import org.springframework.ws.soap.SoapFaultVersionMismatchDefinition;23import org.springframework.ws.soap.SoapVersion;24import org.testng.annotations.Test;25import java.util.ArrayList;26import java.util.List;27import static org.testng.Assert.assertEquals;28import static org.testng.Assert.fail;29public class SendSoapFaultActionTest extends AbstractTestNGUnitTest {30 private SendSoapFaultAction sendSoapFaultAction = new SendSoapFaultAction();31 private SoapFault soapFault = new SoapFault();32 public void testSoapFault() {33 sendSoapFaultAction.setFault(soapFault);34 sendSoapFaultAction.execute(context);35 }36 public void testSoapFaultException() {37 SoapFaultExceptionDefinition exceptionDefinition = new SoapFaultExceptionDefinition();38 exceptionDefinition.setFaultCode("Server");39 exceptionDefinition.setFaultStringOrReason("Internal server error");40 exceptionDefinition.setFaultActorOrRole("Citrus");41 SoapFaultException soapFaultException = new SoapFaultException(exceptionDefinition);42 sendSoapFaultAction.setFault(soapFault);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!