You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/12/25 08:37:40 UTC

svn commit: r1819234 - in /axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2: engine/ThirdPartyResponseRawXMLTest.java integration/TestingUtils.java

Author: veithen
Date: Mon Dec 25 08:37:40 2017
New Revision: 1819234

URL: http://svn.apache.org/viewvc?rev=1819234&view=rev
Log:
Improve debuggability of ThirdPartyResponseRawXMLTest.

Modified:
    axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/ThirdPartyResponseRawXMLTest.java
    axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/integration/TestingUtils.java

Modified: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/ThirdPartyResponseRawXMLTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/ThirdPartyResponseRawXMLTest.java?rev=1819234&r1=1819233&r2=1819234&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/ThirdPartyResponseRawXMLTest.java (original)
+++ axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/engine/ThirdPartyResponseRawXMLTest.java Mon Dec 25 08:37:40 2017
@@ -21,6 +21,8 @@ package org.apache.axis2.engine;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
@@ -38,6 +40,12 @@ import org.apache.axis2.integration.Util
 import org.apache.axis2.transport.http.SimpleHTTPServer;
 import org.apache.axis2.util.Utils;
 
+import static com.google.common.truth.Truth.assertThat;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+
 import javax.xml.namespace.QName;
 
 public class ThirdPartyResponseRawXMLTest extends UtilServerBasedTestCase implements TestConstants {
@@ -45,7 +53,7 @@ public class ThirdPartyResponseRawXMLTes
         return getTestSetup(new TestSuite(ThirdPartyResponseRawXMLTest.class));
     }
     
-	private boolean received;
+    private final BlockingQueue<OMElement> received = new ArrayBlockingQueue<>(1);
     protected AxisService service;
     private SimpleHTTPServer receiver;
     private String callbackOperation;
@@ -62,8 +70,13 @@ public class ThirdPartyResponseRawXMLTes
     	AxisService callbackService  = Utils.createSimpleInOnlyService(new QName(callbackServiceName),new MessageReceiver(){
             public void receive(MessageContext messageCtx) throws AxisFault {
                 SOAPEnvelope envelope = messageCtx.getEnvelope();
-                TestingUtils.compareWithCreatedOMElement(envelope.getBody().getFirstElement());
-                received = true;
+                OMElement bodyContent = envelope.getBody().getFirstElement();
+                bodyContent.build();
+                try {
+                    received.put(bodyContent);
+                } catch (InterruptedException ex) {
+                    // Do nothing
+                }
             }
         },new QName(callbackOperation));
         UtilServer.deployService(callbackService);
@@ -85,14 +98,9 @@ public class ThirdPartyResponseRawXMLTes
         sender.setOptions(op);
         sender.engageModule(Constants.MODULE_ADDRESSING);
         sender.fireAndForget(TestingUtils.createDummyOMElement());
-        int index = 0;
-        while (!received) {
-            Thread.sleep(1000);
-            index++;
-            if (index == 20) {
-                throw new AxisFault("error Occured");
-            }
-        }
+        OMElement bodyContent = received.poll(20, TimeUnit.SECONDS);
+        assertThat(bodyContent).isNotNull();
+        TestingUtils.compareWithCreatedOMElement(bodyContent);
     }
 
     protected void tearDown() throws Exception {

Modified: axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/integration/TestingUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/integration/TestingUtils.java?rev=1819234&r1=1819233&r2=1819234&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/integration/TestingUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/integration/test/org/apache/axis2/integration/TestingUtils.java Mon Dec 25 08:37:40 2017
@@ -25,6 +25,8 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import java.io.File;
 import java.io.IOException;
 
@@ -56,7 +58,7 @@ public class TestingUtils {
         OMElement firstChild = element.getFirstElement();
         TestCase.assertNotNull(firstChild);
         String textValue = firstChild.getText();
-        TestCase.assertEquals(textValue, "Isaac Asimov, The Foundation Trilogy");
+        assertThat(textValue).isEqualTo("Isaac Asimov, The Foundation Trilogy");
     }
 
     public static String prefixBaseDirectory(String path) {