You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2006/12/05 17:27:05 UTC

svn commit: r482701 - in /webservices/axis2/trunk/java/modules/jaxws: test-resources/wsdl/ test/org/apache/axis2/jaxws/framework/ test/org/apache/axis2/jaxws/sample/ test/org/apache/axis2/jaxws/sample/faultsservice/ test/org/apache/axis2/jaxws/sample/f...

Author: scheu
Date: Tue Dec  5 08:27:01 2006
New Revision: 482701

URL: http://svn.apache.org/viewvc?view=rev&rev=482701
Log:
AXIS2-1799
Contributor:Rich Scheuerle
Upgraded the Faults Service and client test.  Legacy Exception and Simple Exceptions are now coded.  These two new tests
are disabled until I fix/add the code to the JAX-WS runtime.

Added:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault_Exception.java
      - copied, changed from r482315, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java
Removed:
    webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/FaultsService.wsdl
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/FaultsService.wsdl

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=482701&r1=482700&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Tue Dec  5 08:27:01 2006
@@ -81,7 +81,7 @@
     
     static {
         // Uncomment the followign line to enable debug
-        BasicConfigurator.configure();
+        // BasicConfigurator.configure();
     }
     
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java?view=diff&rev=482701&r1=482700&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java Tue Dec  5 08:27:01 2006
@@ -6,11 +6,18 @@
 import javax.xml.ws.BindingProvider;
 
 import org.apache.axis2.jaxws.sample.faultsservice.BaseFault_Exception;
+import org.test.polymorphicfaults.BaseFault;
 import org.test.polymorphicfaults.ComplexFault;
+import org.test.polymorphicfaults.DerivedFault1;
 import org.apache.axis2.jaxws.sample.faultsservice.ComplexFault_Exception;
 import org.test.polymorphicfaults.DerivedFault2;
+import org.apache.axis2.jaxws.sample.faultsservice.DerivedFault1_Exception;
+import org.apache.axis2.jaxws.sample.faultsservice.DerivedFault2_Exception;
 import org.apache.axis2.jaxws.sample.faultsservice.FaultsService;
 import org.apache.axis2.jaxws.sample.faultsservice.FaultsServicePortType;
+import org.apache.axis2.jaxws.sample.faultsservice.InvalidTickerFault_Exception;
+import org.apache.axis2.jaxws.sample.faultsservice.SimpleFault;
+
 import junit.framework.TestCase;
 
 
@@ -18,19 +25,52 @@
     
     String axisEndpoint = "http://localhost:8080/axis2/services/FaultsService";
     
-    public void testFaultsService1(){
-        //FaultyWebServiceFault_Exception exception = null;
+    /**
+     * Utility method to get the proxy
+     * @return proxy
+     */
+    private FaultsServicePortType getProxy() {
+        FaultsService service = new FaultsService();
+        FaultsServicePortType proxy = service.getFaultsPort();
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+        return proxy;
+    }
+    
+    /**
+     * Tests that that BaseFault is thrown
+     */
+    public void testFaultsService0() {
         Exception exception = null;
         try{
-            System.out.println("----------------------------------");
-            System.out.println("test: " + getName());
-            FaultsService service = new FaultsService();
-            FaultsServicePortType proxy = service.getFaultsPort();
-            BindingProvider p = (BindingProvider)proxy;
-            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-
+            FaultsServicePortType proxy = getProxy();
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "BaseFault", 2);
+            
+        }catch(BaseFault_Exception e){
+            exception = e;
+        } catch (ComplexFault_Exception e) {
+            fail("Should not get ComplexFault_Exception in this testcase");
+        }
+        
+        System.out.println("----------------------------------");
+        
+        assertNotNull(exception);
+        Object fault = ((BaseFault_Exception)exception).getFaultInfo();
+        assertTrue(fault.getClass() == BaseFault.class);
+        BaseFault bf = (BaseFault) fault;
+        assertTrue(bf.getA() == 2);
+        
+    }
+    /**
+     * Tests that that BaseFault (DerivedFault1) is thrown
+     */
+    public void testFaultsService1() {
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
             // the invoke will throw an exception, if the test is performed right
-            int total = proxy.throwFault(2, "a", 2);
+            int total = proxy.throwFault(2, "DerivedFault1", 2);
             
         }catch(BaseFault_Exception e){
             exception = e;
@@ -41,21 +81,48 @@
         System.out.println("----------------------------------");
         
         assertNotNull(exception);
-        assertTrue(((BaseFault_Exception)exception).getFaultInfo() instanceof DerivedFault2);
+        Object fault = ((BaseFault_Exception)exception).getFaultInfo();
+        assertTrue(fault.getClass() == DerivedFault1.class);
+        DerivedFault1 df = (DerivedFault1) fault;
+        assertTrue(df.getA() == 2);
+        assertTrue(df.getB().equals("DerivedFault1"));
         
     }
+    /**
+     * Tests that that BaseFault (DerivedFault1) is thrown
+     */
+    public void testFaultsService2() {
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "DerivedFault2", 2);
+            
+        }catch(BaseFault_Exception e){
+            exception = e;
+        } catch (ComplexFault_Exception e) {
+            fail("Should not get ComplexFault_Exception in this testcase");
+        }
+        
+        System.out.println("----------------------------------");
+        
+        assertNotNull(exception);
+        Object fault = ((BaseFault_Exception)exception).getFaultInfo();
+        assertTrue(fault.getClass() == DerivedFault2.class);
+        DerivedFault2 df = (DerivedFault2) fault;
+        assertTrue(df.getA() == 2);
+        assertTrue(df.getB().equals("DerivedFault2"));  
+        assertTrue(df.getC() == 2);
+    }
     
-    public void testFaultsService2(){
-        //FaultyWebServiceFault_Exception exception = null;
+    /**
+     * Tests that that ComplxFaultFault is thrown 
+     */
+    public void testFaultsService3(){
         Exception exception = null;
         try{
-            System.out.println("----------------------------------");
-            System.out.println("test: " + getName());
-            FaultsService service = new FaultsService();
-            FaultsServicePortType proxy = service.getFaultsPort();
-            BindingProvider p = (BindingProvider)proxy;
-            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-
+            FaultsServicePortType proxy = getProxy();
+            
             // the invoke will throw an exception, if the test is performed right
             int total = proxy.throwFault(2, "Complex", 2);  // "Complex" will cause service to throw ComplexFault_Exception
             
@@ -68,8 +135,126 @@
         System.out.println("----------------------------------");
         
         assertNotNull(exception);
-        assertTrue(((ComplexFault_Exception)exception).getFaultInfo() instanceof ComplexFault);
-        
+        Object fault = ((ComplexFault_Exception)exception).getFaultInfo();
+        assertTrue(fault.getClass() == ComplexFault.class);
+        ComplexFault cf = (ComplexFault) fault;
+        assertTrue(cf.getA() == 2);
+        assertTrue(cf.getB().equals("Complex"));  
+        assertTrue(cf.getC() == 2);
+        assertTrue(cf.getD() == 5);
     }
+    
+    /**
+     * Tests that throwing of SimpleFault
+     * Disabled while I fix this test
+     */
+    public void _testFaultsService4(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            float total = proxy.getQuote("SMPL");
+            fail( "Expected SimpleFault but no fault was thrown ");
+        }catch(SimpleFault e){
+            SimpleFault fault = (SimpleFault) e;
+
+            int faultInfo = fault.getFaultInfo();
+            assertTrue(faultInfo == 100);
+        } catch (Exception e) {
+            fail("Wrong exception thrown.  Expected SimpleFault but received " + e.getClass());
+        }
+    }
+    
+    
+    /**
+     * Test throwing legacy fault
+     * Disabled while I fix this test
+     */
+    public void _testFaultsService5(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            float total = proxy.getQuote("LEGC");
+            fail( "Expected InvalidTickerFault_Exception but no fault was thrown ");
+        }catch(InvalidTickerFault_Exception e){
+            InvalidTickerFault_Exception fault = (InvalidTickerFault_Exception) e;
+
+            assertTrue(fault.getLegacyData1().equals("LEGC"));
+            assertTrue(fault.getLegacyData2() == 123);
+        } catch (Exception e) {
+            fail("Wrong exception thrown.  Expected InvalidTickerFault_Exception but received " + e.getClass());
+        }
+    }
+    
+    /**
+     * Tests that throwing of BaseFault_Exception
+     */
+    public void testFaultsService6(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            float total = proxy.getQuote("BASE");
+            fail( "Expected BaseFault_Exception but no fault was thrown ");
+        }catch(BaseFault_Exception e){
+            BaseFault_Exception fault = (BaseFault_Exception) e;
+
+            BaseFault faultInfo = fault.getFaultInfo();
+            assertTrue(faultInfo != null);
+            assertTrue(faultInfo.getA() == 400);
+        } catch (Exception e) {
+            fail("Wrong exception thrown.  Expected BaseFault_Exception but received " + e.getClass());
+        }
+    }
+
+    /**
+     * Tests that throwing of DerivedFault1_Exception
+     */
+    public void testFaultsService7(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            float total = proxy.getQuote("DF1");
+            fail( "Expected DerivedFault1_Exception but no fault was thrown");
+        }catch(DerivedFault1_Exception e){
+            DerivedFault1_Exception fault = (DerivedFault1_Exception) e;
 
+            DerivedFault1 faultInfo = fault.getFaultInfo();
+            assertTrue(faultInfo != null);
+            assertTrue(faultInfo.getA() == 100);
+            assertTrue(faultInfo.getB().equals("DF1"));
+        } catch (Exception e) {
+            fail("Wrong exception thrown.  Expected DerivedFault1_Exception but received " + e.getClass());
+        }
+    }
+    
+    /**
+     * Tests that throwing of DerivedFault1_Exception
+     */
+    public void testFaultsService8(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            float total = proxy.getQuote("DF2");
+            fail( "Expected DerivedFault2_Exception but no fault was thrown ");
+        }catch(DerivedFault2_Exception e){
+            DerivedFault2_Exception fault = (DerivedFault2_Exception) e;
+
+            DerivedFault2 faultInfo = fault.getFaultInfo();
+            assertTrue(faultInfo != null);
+            assertTrue(faultInfo.getA() == 200);
+            assertTrue(faultInfo.getB().equals("DF2"));
+            assertTrue(faultInfo.getC() == 80.0F);
+        } catch (Exception e) {
+            fail("Wrong exception thrown.  Expected DerivedFault1_Exception but received " + e.getClass());
+        }
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java?view=diff&rev=482701&r1=482700&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServicePortType.java Tue Dec  5 08:27:01 2006
@@ -27,7 +27,7 @@
      * @param symbol
      * @return
      *     returns float
-     * @throws InvalidTickerFault
+     * @throws InvalidTickerFault_Exception
      * @throws DerivedFault2_Exception
      * @throws BaseFault_Exception
      * @throws DerivedFault1_Exception
@@ -40,7 +40,7 @@
     public float getQuote(
         @WebParam(name = "symbol", targetNamespace = "")
         String symbol)
-        throws BaseFault_Exception, DerivedFault1_Exception, DerivedFault2_Exception, InvalidTickerFault, SimpleFault
+        throws BaseFault_Exception, DerivedFault1_Exception, DerivedFault2_Exception, InvalidTickerFault_Exception, SimpleFault
     ;
 
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java?view=diff&rev=482701&r1=482700&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/FaultsServiceSoapBindingImpl.java Tue Dec  5 08:27:01 2006
@@ -36,28 +36,29 @@
      */
     public float getQuote(String tickerSymbol) throws 
         BaseFault_Exception, DerivedFault1_Exception, 
-        DerivedFault2_Exception, InvalidTickerFault, SimpleFault {
+        DerivedFault2_Exception, InvalidTickerFault_Exception, SimpleFault {
 System.out.println("\nIn getQuote(): " + tickerSymbol + "\n");
-        if (tickerSymbol.equals("ABC")) {
+        if (tickerSymbol.equals("SMPL")) {
             throw new SimpleFault("Server throws SimpleFault", 100);
-        } else if (tickerSymbol.equals("XYZ")) {
-            throw new InvalidTickerFault("Server throws InvalidTickerFault", tickerSymbol);
-        } else if (tickerSymbol.equals("one")) {
+        } else if (tickerSymbol.equals("LEGC")) {
+            throw new InvalidTickerFault_Exception("Server throws InvalidTickerFault_Exception", tickerSymbol, 123);
+        } else if (tickerSymbol.equals("DF1")) {
             DerivedFault1 df = new DerivedFault1();
             df.setA(100);
             df.setB(tickerSymbol);
             throw new DerivedFault1_Exception("Server throws DerivedFault1_Exception", df);
-        }  else if (tickerSymbol.equals("two")) {
+        }  else if (tickerSymbol.equals("DF2")) {
             DerivedFault2 df = new DerivedFault2();
             df.setA(200);
             df.setB(tickerSymbol);
             df.setC(80.0F);
             throw new DerivedFault2_Exception("Server throws DerivedFault2_Exception", df);
-        } else {
+        } else if (tickerSymbol.equals("BASE")) {
             BaseFault bf = new BaseFault();
             bf.setA(400);
             throw new BaseFault_Exception("Server throws BaseFault_Exception", bf);
         }
+        return 100;
     }
 
 
@@ -73,12 +74,23 @@
             cf.setC(c); 
             cf.setD(5); 
             throw new ComplexFault_Exception("Server throws ComplexFault_Exception", cf);
-        } 
-        DerivedFault2 df = new DerivedFault2();
-        df.setA(a); 
-        df.setB(b); 
-        df.setC(c); 
-        throw new BaseFault_Exception("Server throws BaseFault_Exception", df);
+        } else if (b.equals("BaseFault")) {
+            BaseFault bf = new BaseFault();
+            bf.setA(a);  
+            throw new BaseFault_Exception("Server throws BaseFault_Exception", bf);
+        } else if (b.equals("DerivedFault1")) {
+            DerivedFault1 df = new DerivedFault1();
+            df.setA(a); 
+            df.setB(b); 
+            throw new BaseFault_Exception("Server throws BaseFault_Exception", df);
+        } else if (b.equals("DerivedFault2")) {
+            DerivedFault2 df = new DerivedFault2();
+            df.setA(a); 
+            df.setB(b); 
+            df.setC(c); 
+            throw new BaseFault_Exception("Server throws BaseFault_Exception", df);
+        }
+        return 0;
     }
 
 

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault_Exception.java (from r482315, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault_Exception.java?view=diff&rev=482701&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java&r1=482315&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault_Exception.java&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/InvalidTickerFault_Exception.java Tue Dec  5 08:27:01 2006
@@ -6,13 +6,14 @@
 
 
 /**
- * This class was generated by the JAXWS SI.
- * JAX-WS RI 2.0_01-b15-fcs
- * Generated source version: 2.0
- * 
+ * This is an example of a legacy exception (InvalidTickerFault) which may be the result of a JAX-RPC emission.
+ * The fault does not have the valid constructors and lacks a getFaultInfo method.
+ * However (in this case) the fault has a @WebFault that identifies the faultbean
  */
-@WebFault(name = "InvalidTickerFault", targetNamespace = "http://org/test/polymorphicfaults")
-public class InvalidTickerFault
+@WebFault(name = "InvalidTickerFault", 
+        targetNamespace = "http://org/test/polymorphicfaults",
+        faultBean="org.test.polymorphicfaults.InvalidTickerFaultBean")
+public class InvalidTickerFault_Exception
     extends Exception
 {
 
@@ -20,16 +21,18 @@
      * Java type that goes as soapenv:Fault detail element.
      * 
      */
-    private String faultInfo;
+    private String legacyData1;
+    private int legacyData2;
 
     /**
      * 
      * @param message
      * @param faultInfo
      */
-    public InvalidTickerFault(String message, String faultInfo) {
+    public InvalidTickerFault_Exception(String message, String legacyData1, int legacyData2) {
         super(message);
-        this.faultInfo = faultInfo;
+        this.legacyData1 = legacyData1;
+        this.legacyData2 = legacyData2;
     }
 
     /**
@@ -38,18 +41,18 @@
      * @param message
      * @param faultInfo
      */
-    public InvalidTickerFault(String message, String faultInfo, Throwable cause) {
+    public InvalidTickerFault_Exception(String message, String legacyData1, int legacyData2, Throwable cause) {
         super(message, cause);
-        this.faultInfo = faultInfo;
+        this.legacyData1 = legacyData1;
+        this.legacyData2 = legacyData2;
     }
 
-    /**
-     * 
-     * @return
-     *     returns fault bean: java.lang.String
-     */
-    public String getFaultInfo() {
-        return faultInfo;
+    
+    public String getLegacyData1() {
+        return legacyData1;
+    }
+    public int getLegacyData2() {
+        return legacyData2;
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/FaultsService.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/FaultsService.wsdl?view=diff&rev=482701&r1=482700&r2=482701
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/FaultsService.wsdl (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/faultsservice/META-INF/FaultsService.wsdl Tue Dec  5 08:27:01 2006
@@ -11,7 +11,13 @@
     <xsd:schema targetNamespace="http://org/test/polymorphicfaults">
         
       <xsd:element name="SimpleFault" type="xsd:int"/>
-      <xsd:element name="InvalidTickerFault" type="xsd:string"/>
+      <xsd:element name="InvalidTickerFault" type="ts:InvalidTickerFaultBean"/>
+      <xsd:complexType name="InvalidTickerFaultBean">
+        <xsd:sequence>
+           <xsd:element name="legacyData1" type="xsd:string" />
+           <xsd:element name="legacyData2" type="xsd:int" />
+        </xsd:sequence>
+      </xsd:complexType>
 
       <xsd:element name="BaseFault" type="ts:BaseFault"/>
       <xsd:complexType name="BaseFault">



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org