Skip to main content

[soa-testing-snippets~soatestingutilities:109] (Commit message missing)

  • From:
  • To:
  • Subject: [soa-testing-snippets~soatestingutilities:109] (Commit message missing)
  • Date: Tue, 5 Mar 2013 19:48:29 +0000

Project:    soa-testing-snippets
Repository: soatestingutilities
Revision:   109
Author:     olivierld
Date:       2013-03-05 19:48:27 UTC
Link:       

Log Message:
------------



Revisions:
----------
109


Modified Paths:
---------------
ConsolidatedTestEnv/src/testhelper/ServiceUnitTestHelper.java
ConsolidatedTestEnv/src/unittests/patterns/services/SynchronousServiceUnitTest.java
SOATestingSnippets.jws
ConsolidatedTestEnv/basic-service-test.xml
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousOneWayUnitTest.java
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousTwoWayUnitTest.java


Diffs:
------
Index: ConsolidatedTestEnv/src/testhelper/ServiceUnitTestHelper.java
===================================================================
--- ConsolidatedTestEnv/src/testhelper/ServiceUnitTestHelper.java       
(revision 108)
+++ ConsolidatedTestEnv/src/testhelper/ServiceUnitTestHelper.java       
(revision 109)
@@ -87,6 +87,8 @@
 
 import org.xml.sax.SAXException;
 
+import testhelper.gui.SOAPTrafficFrame;
+
 import util.httputil.HTTPRequestHandler;
 import util.httputil.TinyHTTPServer;
 
@@ -146,6 +148,8 @@
   private String password = null;
 
   private HandlerResolver handlerResolver = null;
+  
+  private static SOAPTrafficFrame trafficFrame = null;
 
   public void setVerbose(boolean b)
   {
@@ -990,6 +994,16 @@
       soapCustomerKey2.addTextNode("Fault#123456789");
       */
     }
+    // GUI ? Request
+    if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+    {
+      if (!trafficFrame.isVisible())
+        trafficFrame.setVisible(true);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      soapMessage.writeTo(baos);
+      trafficFrame.setMessageOut(baos.toString());
+    }
+    
     if (verbose)
     {
       soapMessage.writeTo(System.out);
@@ -1144,6 +1158,15 @@
       default:
         break;
     }
+    // GUI ? Response
+    if (response != null && 
"yes".equals(System.getProperty("display.traffic.gui", "no")))
+    {
+      if (!trafficFrame.isVisible())
+        trafficFrame.setVisible(true);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      response.writeTo(baos);
+      trafficFrame.setMessageIn(baos.toString());
+    }
     if ((mode == SYNCHRONOUS || mode == SYNC_THEN_ASYNCHRONOUS_TWO_WAYS) && 
response != null)
     {
       if (verbose)
@@ -1409,6 +1432,13 @@
 
   public static void setAsyncResponse(String asr)
   {
+    // GUI ? Response
+    if (asr != null && 
"yes".equals(System.getProperty("display.traffic.gui", "no")))
+    {
+      if (!trafficFrame.isVisible())
+        trafficFrame.setVisible(true);
+      trafficFrame.setMessageIn(asr);
+    }
     asyncResponse = asr;
   }
 
@@ -1900,8 +1930,59 @@
   {
     return getDefaultContext(jpsConfig).getAttribute("name");
   }
+  
+  private Thread guiThread = null;
+  public void startGUIThread()
+  {
+    final ServiceUnitTestHelper instance = this;
+    final Thread main = Thread.currentThread();
+    guiThread = new Thread()
+      {
+        public void run()
+        {
+          if (trafficFrame == null)
+            trafficFrame = new SOAPTrafficFrame(instance);
+          if (!trafficFrame.isVisible())
+            trafficFrame.setVisible(true);
+          try
+          {
+            synchronized (main) { main.notify(); }
+          }
+          catch (Exception ex)
+          {
+            ex.printStackTrace();
+          }
+          synchronized (this)
+          {
+            try
+            {
+              this.wait();
+              System.out.println("GUIThread terminated.");
+            }
+            catch (Exception ex)
+            {
+              ex.printStackTrace();
+            }
+          }
+        }
+      };
+    guiThread.start();
+    try
+    {
+      synchronized (main) { main.wait(); } // Wait for the GUI to be up
+    }
+    catch (Exception ex)
+    {
+      ex.printStackTrace();
+    }
+    System.out.println("GUIThread on its way");
+  }
+  
+  public Thread getGUIThread()
+  {
+    return guiThread;
+  }
 
-
   private static class CustomNamespaceResolver
     implements NSResolver
   {
@@ -1954,7 +2035,7 @@
       try
       {
         before = true;
-        //      ths = new TinyHTTPServer(httpServerPort, null, hrh, 
terminateAfterFirstRequest, verbose);
+//      ths = new TinyHTTPServer(httpServerPort, null, hrh, 
terminateAfterFirstRequest, verbose);
         ths.runServer();
         before = false;
         if (verbose)
Index: 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousTwoWayUnitTest.java
===================================================================
--- 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousTwoWayUnitTest.java
 (revision 108)
+++ 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousTwoWayUnitTest.java
 (revision 109)
@@ -68,6 +68,8 @@
       firstOfAll();
       // Context setup
       suth = new ServiceUnitTestHelper();
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+        suth.startGUIThread();
       verbose = "true".equals(System.getProperty("verbose", "false"));
       projectDirectory = System.getProperty("project.directory", ".");
       suth.setVerbose(verbose);
@@ -346,6 +348,20 @@
       onError(ex);
 //    ex.printStackTrace();
     }
+    finally
+    {
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+      {
+        try
+        {
+          suth.getGUIThread().join();
+        }
+        catch (Exception ex)
+        {
+          ex.printStackTrace();
+        }
+      }      
+    }
   }
 
   public void firstOfAll()
Index: 
ConsolidatedTestEnv/src/unittests/patterns/services/SynchronousServiceUnitTest.java
===================================================================
--- 
ConsolidatedTestEnv/src/unittests/patterns/services/SynchronousServiceUnitTest.java
 (revision 108)
+++ 
ConsolidatedTestEnv/src/unittests/patterns/services/SynchronousServiceUnitTest.java
 (revision 109)
@@ -63,6 +63,9 @@
       firstOfAll();
       // Init context
       suth = new ServiceUnitTestHelper();
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+        suth.startGUIThread();
+
       projectDirectory = System.getProperty("project.directory", ".");
       verbose = "true".equals(System.getProperty("verbose", "false"));
       suth.setVerbose(verbose);
@@ -298,6 +301,17 @@
     {
       if (verbose)
         System.out.println("End-of-Test");
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+      {
+        try
+        {
+          suth.getGUIThread().join();
+        }
+        catch (Exception ex)
+        {
+          ex.printStackTrace();
+        }
+      }
     }
   }
   
Index: 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousOneWayUnitTest.java
===================================================================
--- 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousOneWayUnitTest.java
 (revision 108)
+++ 
ConsolidatedTestEnv/src/unittests/patterns/services/AsynchronousOneWayUnitTest.java
 (revision 109)
@@ -48,6 +48,9 @@
       firstOfAll();
       // Initialize the context...
       suth = new ServiceUnitTestHelper();
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+        suth.startGUIThread();
+
       projectDirectory = System.getProperty("project.directory", ".");
       verbose = "true".equals(System.getProperty("verbose", "false"));
       suth.setVerbose(verbose);
@@ -221,6 +224,17 @@
     {
       if (verbose)
         System.out.println("Test is finished.");
+      if ("yes".equals(System.getProperty("display.traffic.gui", "no")))
+      {
+        try
+        {
+          suth.getGUIThread().join();
+        }
+        catch (Exception ex)
+        {
+          ex.printStackTrace();
+        }
+      }
     }
   }
 
Index: ConsolidatedTestEnv/basic-service-test.xml
===================================================================
--- ConsolidatedTestEnv/basic-service-test.xml  (revision 108)
+++ ConsolidatedTestEnv/basic-service-test.xml  (revision 109)
@@ -51,6 +51,8 @@
   <path id="library.test.util">
     <pathelement location="lib/junit-4.5.jar"/>
     <pathelement location="lib/xmlunit-1.3.jar"/>
+    <pathelement location="lib/dom4j-1.6.1.jar"/>
+    <pathelement location="lib/jsyntaxpane-0.9.5-b29.jar"/>
     <pathelement 
location="../ConsolidatedTestEnv/deploy/ConsolidatedTestEnv.jar"/>
   </path>
   <path id="library.Oracle.XML.Parser.v2">
@@ -348,6 +350,7 @@
       <sysproperty key="verbose" value="${verbose}"/>
       <!--sysproperty key="oracle.security.jps.config" 
value="../security/config/jps-config.xml"/-->
       <sysproperty key="properties.file.name" 
value="generic-service-test-async-one-way.properties"/>
+      <sysproperty key="display.traffic.gui" value="yes"/>
       <test name="${ASYNC.ONE.WAY}" haltonfailure="no" 
outfile="asynchronous"/>
     </junit>    
     <antcall target="in.case.asynchronous.1.fails"/>
@@ -375,6 +378,7 @@
       <formatter type="xml"/>
       <sysproperty key="verbose" value="${verbose}"/>
       <sysproperty key="properties.file.name" 
value="generic-service-test-synchronous.properties"/>
+      <sysproperty key="display.traffic.gui" value="yes"/>
       <test name="${SYNCHRONOUS}" haltonfailure="no" outfile="synchronous"/>
     </junit>    
     <antcall target="in.case.synchronous.fails"/>
@@ -402,6 +406,7 @@
       <formatter type="xml"/>
       <sysproperty key="verbose" value="${verbose}"/>
       <sysproperty key="properties.file.name" 
value="generic-service-test-async-two-way.properties"/>
+      <sysproperty key="display.traffic.gui" value="yes"/>
       <test name="${ASYNC.TWO.WAYS}" haltonfailure="no" 
outfile="asynchronous.2"/>
     </junit>    
     <antcall target="in.case.asynchronous.2.fails"/>
Index: SOATestingSnippets.jws
===================================================================
--- SOATestingSnippets.jws      (revision 108)
+++ SOATestingSnippets.jws      (revision 109)
@@ -33,5 +33,7 @@
       <hash><url n="URL" path="OATS.Bypass/OATS.Bypass.jpr"/></hash>
       <hash><url n="URL" 
path="SOACompositeForInstallationTests/SOACompositeForInstallationTests.jpr"/></hash>
       <hash><url n="URL" 
path="SOAInstallationTester/SOAInstallationTester.jpr"/></hash>
+      <hash><url n="URL" path="VariousXMLTests/VariousXMLTests.jpr"/></hash>
+      <hash><url n="URL" 
path="XSD.to.Schematron/XSD.to.Schematron.jpr"/></hash>
    </list>
 </jws:workspace>





[soa-testing-snippets~soatestingutilities:109] (Commit message missing)

olivierld 03/05/2013
 
 
Close
loading
Please Confirm
Close