citrusframework / citrus

Framework for automated integration tests with focus on messaging integration
https://citrusframework.org
Apache License 2.0
460 stars 137 forks source link

Http message sent instead of soap message if soap action send called with uri instead of autowired soap client #579

Open adhithyasrinivasan opened 5 years ago

adhithyasrinivasan commented 5 years ago

Citrus Version v2.7.8

Expected behavior Soap message should be sent

Actual behavior http message sent

Test case sample

Please, share the test case (as small as possible) which shows the issue

Actual behavior for

soap(action -> action.client("http://localhost:8080/services/WS")
                .send()
                .soapAction("getTodoList")
                .payload("<todo:getTodoListRequest xmlns:todo=\"http://citrusframework.org/samples/todolist\">\r\n" + 
                        "</todo:getTodoListRequest>"));

Debug log:

08:57:40,387 DEBUG port.LoggingReporter| TEST STEP 2: send
08:57:40,422 DEBUG faultEndpointFactory| Found cached endpoint for uri 'http://localhost:8080/services/WS'
08:57:40,652 DEBUG ltCorrelationManager| Saving correlation key for 'citrus_message_correlator_HttpClient'
08:57:40,652 DEBUG  context.TestContext| Setting variable: citrus_message_correlator_HttpClient with value: 'citrus_message_id = '9071da37-a0d2-49ff-a05d-e950d627a75c''
08:57:40,652 DEBUG    client.HttpClient| Sending HTTP message to: 'http://localhost:8080/services/WS'

Actual behavior for passing client:

@Autowired
private WebServiceClient todoSoapClient;

soap(action -> action.client(todoSoapClient)
                .send()
                .soapAction("getTodoList")
                .payload("<todo:getTodoListRequest xmlns:todo=\"http://citrusframework.org/samples/todolist\">\r\n" + 
                        "</todo:getTodoListRequest>"));

Debug log:

09:03:13,681 DEBUG port.LoggingReporter| TEST STEP 2: send
09:03:13,697 DEBUG ltCorrelationManager| Saving correlation key for 'citrus_message_correlator_todoSoapClient'
09:03:13,697 DEBUG  context.TestContext| Setting variable: citrus_message_correlator_todoSoapClient with value: 'citrus_message_id = '5360f67a-8020-47b2-b0e3-1effb5bd84f1''
09:03:13,697 DEBUG ent.WebServiceClient| Sending SOAP message to endpoint: 'http://localhost:8080/services/WS'
09:03:13,697 DEBUG ent.WebServiceClient| Message to send is:
svettwer commented 5 years ago

Hi!

Thx for reporting this! :+1: To reconstruct the described behavior, the Citrus-HTTP Module is required as a dependency. If the Citrus-HTTP Module is missing, a different error occurs which is as fatal as the original one but it indicates the root cause a little bit better, I think.

The output is the result of a modified soap-sample from the samples repository.

09:16:12.419 [main] WARN com.consol.citrus.endpoint.DefaultEndpointFactory - Unable to find default Citrus endpoint component 'com.consol.citrus.http.client.HttpEndpointComponent' in classpath
java.lang.ClassNotFoundException: com.consol.citrus.http.client.HttpEndpointComponent
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at com.consol.citrus.endpoint.DefaultEndpointFactory.resolveDefaultComponent(DefaultEndpointFactory.java:147)
        at com.consol.citrus.endpoint.DefaultEndpointFactory.create(DefaultEndpointFactory.java:109)
        at com.consol.citrus.actions.SendMessageAction.getOrCreateEndpoint(SendMessageAction.java:174)
        at com.consol.citrus.actions.SendMessageAction.isDisabled(SendMessageAction.java:137)
        at com.consol.citrus.dsl.actions.DelegatingTestAction.isDisabled(DelegatingTestAction.java:60)
        at com.consol.citrus.TestCase.executeAction(TestCase.java:216)
        at com.consol.citrus.TestCase.doExecute(TestCase.java:152)
        at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
        at com.consol.citrus.Citrus.run(Citrus.java:403)
        at com.consol.citrus.testng.AbstractTestNGCitrusTest.invokeTestMethod(AbstractTestNGCitrusTest.java:131)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.invokeTestMethod(TestNGCitrusTest.java:121)
        at com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner.invokeTestMethod(TestNGCitrusTestDesigner.java:73)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:110)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:56)
        at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:242)
[...]

and

09:16:12.431 [main] ERROR com.consol.citrus.report.LoggingReporter - TEST FAILED TodoListIT.testAddTodoEntry <com.consol.citrus.samples.todolist> Nested exception is: 
com.consol.citrus.exceptions.CitrusRuntimeException: Unable to create endpoint component with name 'http'
        at com.consol.citrus.endpoint.DefaultEndpointFactory.create(DefaultEndpointFactory.java:113)
        at com.consol.citrus.actions.SendMessageAction.getOrCreateEndpoint(SendMessageAction.java:174)
        at com.consol.citrus.actions.SendMessageAction.isDisabled(SendMessageAction.java:137)
        at com.consol.citrus.dsl.actions.DelegatingTestAction.isDisabled(DelegatingTestAction.java:60)
        at com.consol.citrus.TestCase.executeAction(TestCase.java:216)
        at com.consol.citrus.TestCase.doExecute(TestCase.java:152)
        at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
        at com.consol.citrus.Citrus.run(Citrus.java:403)
        at com.consol.citrus.testng.AbstractTestNGCitrusTest.invokeTestMethod(AbstractTestNGCitrusTest.java:131)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.invokeTestMethod(TestNGCitrusTest.java:121)
        at com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner.invokeTestMethod(TestNGCitrusTestDesigner.java:73)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:110)
        at com.consol.citrus.dsl.testng.TestNGCitrusTest.run(TestNGCitrusTest.java:56)
        at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:242)
[...]

BR, Sven