New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket : 'received pong message' : Failed to convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String' #284

Closed
vinay-prasad opened this Issue Sep 7, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@vinay-prasad

vinay-prasad commented Sep 7, 2017

I have a citrus test case which uses Websockets cleint for testing. It sends some request and validates the response (JSON). What I encountered is whenever there is a Ping-Pong communication between the client and server,

  1. Citrus logs the incoming pong as "received pong message"
  2. The receive template logs an error as it can not convert the "java.nio.HeapByteBuffer" into JSON, which I think is the representation of pong response.
    This leads to the failure

Questions:

  1. How can I control the ping/pong behavior from Citrus
  2. If I can not how can I filter a pong response from test response?

12:06:19,696 DEBUG nt.WebSocketConsumer| Waiting for message on 'ws://myhostname:60000' - retrying in 500 ms
12:06:19,755 DEBUG trusWebSocketHandler| WebSocket endpoint (some_client_ip:54406->some_server_ip:60000) received text message
12:06:20,148 DEBUG trusWebSocketHandler| WebSocket endpoint (some_client_ip:54406->some_server_ip:60000) received pong message
12:06:20,196 INFO nt.WebSocketConsumer| Received Web Socket message
12:06:20,196 DEBUG Logger.Message_IN| WEBSOCKETMESSAGE [payload: {"Acknowledgement":{"request":"CheckoutSessionRequest"}}][headers: {citrus_message_id=37f4473b-b803-49e4-b068-44cad4028110, citrus_message_timestamp=1504800380196, citrus_websocket_is_last=true}]
12:06:20,196 DEBUG ageValidatorRegistry| Found 3 message validators for message type: json
12:06:20,198 DEBUG Logger.Message_IN| WEBSOCKETMESSAGE [payload: java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]][headers: {citrus_message_id=34e09791-2321-49ff-937c-e5b4f9224d78, citrus_me
java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]][headers: {citrus_message_id=34e09791-2321-49ff-937c-e5b4f9224d78, citrus_message_timestamp=1504800380197, citrus_websocket_is_last=true}]

12:06:20,199 DEBUG ageValidatorRegistry| Found 3 message validators for message type: json
12:06:20,200 WARN .TypeConversionUtils| Using object toString representation: Failed to convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.nio.HeapByteBuffer' to required type 'java.lang.String': no matching editors or conversion strategy found
12:06:20,201 INFO citrus.Citrus|
12:06:20,201 ERROR citrus.Citrus| TEST FAILED ResetEventsCheckoutXmlTest <com.test> Nested exception is:
com.consol.citrus.exceptions.CitrusRuntimeException: Failed to parse JSON text
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(JsonTextMessageValidator.java:100)
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(JsonTextMessageValidator.java:52)
at com.consol.citrus.validation.AbstractMessageValidator.validateMessage(AbstractMessageValidator.java:65)
at com.consol.citrus.validation.AbstractMessageValidator.validateMessage(AbstractMessageValidator.java:50)
at com.consol.citrus.actions.ReceiveMessageAction.validateMessage(ReceiveMessageAction.java:216)
at com.consol.citrus.actions.ReceiveMessageAction.doExecute(ReceiveMessageAction.java:133)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.TestCase.executeAction(TestCase.java:229)
at com.consol.citrus.TestCase.doExecute(TestCase.java:145)
at com.consol.citrus.actions.AbstractTestAction.execute(AbstractTestAction.java:42)
at com.consol.citrus.Citrus.run(Citrus.java:255)
at com.consol.citrus.testng.AbstractTestNGCitrusTest.run(AbstractTestNGCitrusTest.java:112)
at com.consol.citrus.testng.AbstractTestNGCitrusTest.run(AbstractTestNGCitrusTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:212)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:115)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:128)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:112)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: net.minidev.json.parser.ParseException: Unexpected token java.nio.HeapByteBuffer[pos=0 lim=0 cap=0] at position 42.
at net.minidev.json.parser.JSONParserBase.readFirst(JSONParserBase.java:371)
at net.minidev.json.parser.JSONParserBase.parse(JSONParserBase.java:154)
at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:58)
at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:39)
at net.minidev.json.parser.JSONParser.parse(JSONParser.java:255)
at com.consol.citrus.validation.json.JsonTextMessageValidator.validateMessagePayload(JsonTextMessageValidator.java:82)
... 40 more

@christophd

This comment has been minimized.

Member

christophd commented Sep 11, 2017

The problem here is the message payload of type java.nio.HeapByteBuffer. Citrus message conversion strategy is not able to handle this type when using the JsonTextMessageValidator. Let me see how we can add the message conversion somehow.

@mlybarger

This comment has been minimized.

mlybarger commented Nov 29, 2017

@christophd we're very interested in this feature. is there a timeframe you could comment on for the 2.7.3 release? anything we can do to help :). alternatively, is there a quick way we can use the git version of citrus framework in our pom? snapshots?.. Nevermind. I found my answer here: http://citrusframework.org/docs/download/#use-latest-snapshots

@christophd

This comment has been minimized.

Member

christophd commented Nov 29, 2017

Version 2.7.3 is scheduled within the next weeks - keeping our fingers crossed! Definitely within 2017! As an alternative you can use the nightly snapshot releases 2.7.3-SNAPSHOT. These snapshots are available via labs.consol.de Maven snapshot repository. Just add the repository to your Maven POM file

<repositories>
  <repository>
    <id>consol-labs-snapshots</id>
    <url>http://labs.consol.de/maven/snapshots-repository/</url>
    <snapshots>
      <enabled>true</enabled>
      <updatePolicy>interval:10080</updatePolicy>
    </snapshots>
  </repository>
</repositories>

After that you will be able to use 2.7.3-SNAPSHOT in your project including the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment