axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Jordahl <t...@macromedia.com>
Subject RE: cvs commit: xml-axis/java/test/wsdl Wsdl2javaTestSuite.xml
Date Thu, 05 Sep 2002 20:07:46 GMT

Dims,

Make sure you create a build.xml in the test directory so the test can be run in isolation.

Matt can give you more info.

--
Tom Jordahl
Macromedia Server Development



-----Original Message-----
From: dims@apache.org [mailto:dims@apache.org]
Sent: Thursday, September 05, 2002 4:06 PM
To: xml-axis-cvs@apache.org
Subject: cvs commit: xml-axis/java/test/wsdl Wsdl2javaTestSuite.xml


dims        2002/09/05 13:05:47

  Modified:    java/test/wsdl Wsdl2javaTestSuite.xml
  Added:       java/test/wsdl/session session.wsdl SessionTestCase.java
                        SessionTestSoapBindingImpl.java
  Log:
  Test case for "NPE with multithreaded client in RC1" problem from "Volanis, Alexander" <AVolanis@rsasecurity.com>
  
  Details:
  - http://marc.theaimsgroup.com/?t=103124516800009&r=1&w=2
  - http://marc.theaimsgroup.com/?t=103120473600002&r=1&w=2
  
  Revision  Changes    Path
  1.1                  xml-axis/java/test/wsdl/session/session.wsdl
  
  Index: session.wsdl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <wsdl:definitions targetNamespace="http://session.wsdl.test:8080/axis/services/SessionTest"
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://session.wsdl.test:8080/axis/services/SessionTest" xmlns:intf="http://session.wsdl.test:8080/axis/services/SessionTest"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:message name="doSomethingResponse">
      <wsdl:part name="doSomethingReturn" type="xsd:boolean"/>
    </wsdl:message>
    <wsdl:message name="doSomethingRequest">
    </wsdl:message>
    <wsdl:portType name="SessionTestServer">
      <wsdl:operation name="doSomething">
        <wsdl:input message="intf:doSomethingRequest" name="doSomethingRequest"/>
        <wsdl:output message="intf:doSomethingResponse" name="doSomethingResponse"/>
      </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SessionTestSoapBinding" type="intf:SessionTestServer">
      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="doSomething">
        <wsdlsoap:operation soapAction=""/>
        <wsdl:input name="doSomethingRequest">
          <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://session.wsdl.test:8080/axis/services/SessionTest"
use="encoded"/>
        </wsdl:input>
        <wsdl:output name="doSomethingResponse">
          <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://session.wsdl.test:8080/axis/services/SessionTest"
use="encoded"/>
        </wsdl:output>
      </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SessionTestServerService">
      <wsdl:port binding="intf:SessionTestSoapBinding" name="SessionTest">
        <wsdlsoap:address location="http://localhost:8080/axis/services/SessionTest"/>
      </wsdl:port>
    </wsdl:service>
  </wsdl:definitions>
  
  
  1.1                  xml-axis/java/test/wsdl/session/SessionTestCase.java
  
  Index: SessionTestCase.java
  ===================================================================
  /**
   * SessionTestServerServiceTestCase.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  package test.wsdl.session;
  
  /**
   * Class SessionTestCase
   */
  public class SessionTestCase extends junit.framework.TestCase {
  
      /**
       * Constructor SessionTestCase
       * @param name
       */
      public SessionTestCase(java.lang.String name) {
          super(name);
      }
  
      /**
       * Method test1SessionTestDoSomething
       */
      public void test1SessionTestDoSomething() {
          // Threads array
          SessionTest[] clients = new SessionTest[numThreads];
  
          for (int i = 0; i < numThreads; i++) {
              clients[i] = new SessionTest();
          }
          for (int j = 0; j < numThreads; j++) {
              clients[j].start();
              try {
                  Thread.currentThread().sleep(150);
              } catch (InterruptedException e) {
                  System.out.println("Threads interrupted");
              }
          }
          try {
              synchronized (lock) {
                  while (count != 0) {
                      lock.wait();
                  }
              }
          } catch (InterruptedException ie) {
              System.out.println("Threads interrupted");
          }
          System.out.println("Succeeded " + succeeded + " times.");
          System.out.println("Failed " + failed + " times.");
          assertTrue("found session failures", (failed == 0));
      }
  
      /**
       * Class SessionTest
       */
      public class SessionTest extends Thread {
          /**
           * run the thread until done.
           */
          public void run() {
              try {
                  // Create an instance of the Web service interface.
                  SessionTestServerServiceLocator wsloc =
                          new SessionTestServerServiceLocator();
                  SessionTestServer ws = wsloc.getSessionTest();
  
                  // Maintain sessions for test calls.
                  ((org.apache.axis.client.Stub) ws).setMaintainSession(true);
                  for (int i = 0; i < NO_OF_CALLS; i++) {
                      if (ws.doSomething() == false) {
                          synchronized (testLock) {
                              failed++;
                          }
                      } else {
                          synchronized (testLock) {
                              succeeded++;
                          }
                      }
                  }
              } catch (javax.xml.rpc.ServiceException e) {
                  e.printStackTrace();
              } catch (java.rmi.RemoteException e) {
                  e.printStackTrace();
              }
              // checkout
              synchronized (lock) {
                  count--;
                  lock.notifyAll();
              }
          }
      }
  
      /** Field lock           */
      private static Object lock = new Object();
  
      /** Field testLock           */
      private static Object testLock = new Object();
  
      /** Field NO_OF_THREADS           */
      private static final int NO_OF_THREADS = 3;
  
      /** Field NO_OF_CALLS           */
      private static final int NO_OF_CALLS = 6;
  
      /** Field numThreads           */
      private static int numThreads = NO_OF_THREADS;
  
      /** Field count           */
      private static int count = NO_OF_THREADS;
  
      /** Field failed           */
      private static int failed = 0;
  
      /** Field succeeded           */
      private static int succeeded = 0;
  
      /**
       * Main entry point for the application.
       * Takes number of threads as argument.
       *
       * @param args
       *
       * @throws Exception
       */
      public static void main(String[] args) throws Exception {
          numThreads = count = Integer.parseInt(args[0]);
          SessionTestCase testCase = new SessionTestCase("SessionTestCase");
          testCase.test1SessionTestDoSomething();
      }
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/session/SessionTestSoapBindingImpl.java
  
  Index: SessionTestSoapBindingImpl.java
  ===================================================================
  /**
   * SessionTestSoapBindingImpl.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  package test.wsdl.session;
  
  /**
   * Class SessionTestSoapBindingImpl
   */
  public class SessionTestSoapBindingImpl
          implements test.wsdl.session.SessionTestServer {
  
      /**
       * Method doSomething
       *
       * @return
       *
       * @throws java.rmi.RemoteException
       */
      public boolean doSomething() throws java.rmi.RemoteException {
  
          // if this is my session only then the data will be 0
          boolean succeeded = true;
          int count = countUp();
  
          if (count != 1) {
              System.out.println("Failed with count=" + count);
              succeeded = false;
          }
          try {
              // simulate some busy processing
              Thread.currentThread().sleep(999);
          } catch (InterruptedException e) {
              // ignore
          }
  
          // check exit count
          count = countDown();
          if (count != 0) {
              System.out.println("Failed with count=" + count);
              succeeded = false;
          }
          return succeeded;
      }
  
      /**
       * Count one caller
       *
       * @return Number of simultaneous session callers.
       */
      private synchronized int countUp() {
          sessionCallers++;
          return sessionCallers;
      }
  
      /**
       * Count down one caller
       *
       * @return Number of callers left.
       */
      private synchronized int countDown() {
          sessionCallers--;
          return sessionCallers;
      }
  
      /** count simultaneous session callers           */
      private int sessionCallers = 0;
  }
  
  
  
  1.126     +7 -0      xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
  
  Index: Wsdl2javaTestSuite.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- Wsdl2javaTestSuite.xml	4 Sep 2002 13:25:03 -0000	1.125
  +++ Wsdl2javaTestSuite.xml	5 Sep 2002 20:05:47 -0000	1.126
  @@ -987,6 +987,13 @@
                  serverSide="no"
                  testcase="no">
       </wsdl2java>
  +
  +    <wsdl2java url="test/wsdl/session/session.wsdl"
  +               output="build/work"
  +               serverSide="yes"
  +               testcase="no">
  +    </wsdl2java>
  +
       <!-- Copy modified files to work directory -->
       <copy todir="${build.dir}/work/test/wsdl/jaxrpchandler" overwrite="yes">
         <fileset dir="${test.dir}/wsdl/jaxrpchandler">
  
  
  

Mime
View raw message