axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wood...@apache.org
Subject svn commit: r633234 [16/24] - in /webservices/axis2/trunk/java: ./ modules/jaxws-integration/ modules/jaxws-integration/test/ modules/jaxws-integration/test/client/ modules/jaxws-integration/test/org/ modules/jaxws-integration/test/org/apache/ modules/...
Date Mon, 03 Mar 2008 18:48:24 GMT
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultsServiceTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,437 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * 
+ */
+package org.apache.axis2.jaxws.sample;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.SOAPFault;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.faultsservice.BaseFault_Exception;
+import org.apache.axis2.jaxws.sample.faultsservice.ComplexFault_Exception;
+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 org.apache.axis2.jaxws.TestLogger;
+import org.test.polymorphicfaults.BaseFault;
+import org.test.polymorphicfaults.ComplexFault;
+import org.test.polymorphicfaults.DerivedFault1;
+import org.test.polymorphicfaults.DerivedFault2;
+
+public class FaultsServiceTests extends TestCase {
+    
+    String axisEndpoint = "http://localhost:6060/axis2/services/FaultsService.FaultsPort";
+    
+    /**
+     * 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{
+            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");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        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, "DerivedFault1", 2);
+            
+        }catch(BaseFault_Exception e){
+            exception = e;
+        } catch (ComplexFault_Exception e) {
+            fail("Should not get ComplexFault_Exception in this testcase");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        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");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        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);
+    }
+    
+    /**
+     * Tests that that ComplxFaultFault is thrown 
+     */
+    public void testFaultsService3(){
+        Exception exception = null;
+        try{
+            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
+            
+        }catch(BaseFault_Exception e){
+            fail("Should not get BaseFault_Exception in this testcase");
+        } catch (ComplexFault_Exception e) {
+            exception = e;
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        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
+     */
+    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());
+        }
+    }
+    
+    /**
+     * Tests that that SOAPFaultException is thrown 
+     */
+    public void testFaultsService9a(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "SOAPFaultException", 2);  // "SOAPFaultException" will cause service to throw SOAPFaultException
+            
+        }catch(SOAPFaultException e){
+            // Okay
+            exception = e;
+        } catch (Exception e) {
+            fail("Did not get a SOAPFaultException");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        SOAPFaultException sfe = (SOAPFaultException) exception;
+        SOAPFault soapFault = sfe.getFault();
+        assertTrue(soapFault != null);
+        assertTrue(soapFault.getFaultString().equals("hello world"));
+        assertTrue(soapFault.getFaultActor().equals("actor"));
+        assertTrue(soapFault.getDetail() == null);
+    }
+    
+    /**
+     * Tests that that SOAPFaultException is thrown 
+     */
+    public void testFaultsService9b(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "SOAPFaultException2", 2);  // "SOAPFaultException" will cause service to throw SOAPFaultException
+            
+        }catch(SOAPFaultException e){
+            // Okay
+            exception = e;
+        } catch (Exception e) {
+            fail("Did not get a SOAPFaultException");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        SOAPFaultException sfe = (SOAPFaultException) exception;
+        SOAPFault soapFault = sfe.getFault();
+        assertTrue(soapFault != null);
+        assertTrue(soapFault.getFaultString().equals("hello world2"));
+        assertTrue(soapFault.getFaultActor().equals("actor2"));
+        assertTrue(soapFault.getDetail() != null);
+        DetailEntry de = (DetailEntry) soapFault.getDetail().getDetailEntries().next();
+        assertTrue(de != null);
+        assertTrue(de.getNamespaceURI().equals("urn://sample"));
+        assertTrue(de.getLocalName().equals("detailEntry"));
+        assertTrue(de.getValue().equals("Texas"));
+    }
+    
+    /**
+     * Tests that that SOAPFaultException (NPE) is thrown 
+     */
+    public void testFaultsService10(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "NPE", 2);  // "NPE" will cause service to throw NPE System Exception
+            
+        }catch(SOAPFaultException e){
+            // Okay
+            exception = e;
+        } catch (Exception e) {
+            fail("Did not get a SOAPFaultException");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        SOAPFaultException sfe = (SOAPFaultException) exception;
+        SOAPFault soapFault = sfe.getFault();
+        assertTrue(soapFault != null);
+        assertTrue(soapFault.getFaultString().equals("java.lang.NullPointerException"));
+    }
+    
+    /**
+     * Tests that that SOAPFaultException (NPE) is thrown 
+     */
+    public void testFaultsService10a(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "NPE2", 2);  // "NPE" will cause service to throw NPE System Exception
+            
+        }catch(SOAPFaultException e){
+            // Okay
+            exception = e;
+        } catch (Exception e) {
+            fail("Did not get a SOAPFaultException");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        SOAPFaultException sfe = (SOAPFaultException) exception;
+        SOAPFault soapFault = sfe.getFault();
+        assertTrue(soapFault != null);
+        assertTrue(soapFault.getFaultString().equals("Null Pointer Exception occurred"));
+    }
+    
+    /**
+     * Tests that that SOAPFaultException (for WebServiceException) is thrown 
+     */
+    public void testFaultsService11(){
+        Exception exception = null;
+        try{
+            FaultsServicePortType proxy = getProxy();
+            
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.throwFault(2, "WSE", 2);  // "WSE" will cause service to throw WebServiceException System Exception
+            
+        }catch(SOAPFaultException e){
+            // Okay...on the client a SOAPFaultException should be thrown
+            exception = e;
+        } catch (Exception e) {
+            fail("Did not get a SOAPFaultException");
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        SOAPFaultException sfe = (SOAPFaultException) exception;
+        SOAPFault soapFault = sfe.getFault();
+        assertTrue(soapFault != null);
+        assertTrue(soapFault.getFaultString().equals("This is a WebServiceException"));
+    }
+    
+    /**
+     * Tests Resource injection
+     */
+    public void testResourceInjection() throws Exception {
+        FaultsServicePortType proxy = getProxy();
+        
+        float total = proxy.getQuote("INJECTION");
+        
+        // If resource injection occurred properly, then the a value of 1234567 is expected
+        assertTrue("Resource Injection Failed", total == 1234567);
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/FaultyWebServiceTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * 
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceFault_Exception;
+import org.apache.axis2.jaxws.sample.faults.FaultyWebServicePortType;
+import org.apache.axis2.jaxws.sample.faults.FaultyWebServiceService;
+import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrap;
+import org.apache.axis2.jaxws.sample.wrap.sei.DocLitWrapService;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.axis2.util.ThreadContextMigrator;
+import org.apache.axis2.util.ThreadContextMigratorUtil;
+import org.test.faults.FaultyWebServiceResponse;
+
+public class FaultyWebServiceTests extends TestCase {
+	String axisEndpoint = "http://localhost:6060/axis2/services/FaultyWebServiceService.FaultyWebServicePortTypeImplPort";
+	public void testFaultyWebService(){
+		FaultyWebServiceFault_Exception exception = null;
+		try{
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+		    FaultyWebServiceService service = new FaultyWebServiceService();
+		    FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+			BindingProvider p =	(BindingProvider)proxy;
+			p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+
+			// the invoke will throw an exception, if the test is performed right
+			int total = proxy.faultyWebService(10);
+			
+		}catch(FaultyWebServiceFault_Exception e){
+			exception = e;
+		}catch(Exception e) {
+           e.printStackTrace();
+           fail(e.toString());
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+		
+		assertNotNull(exception);
+		assertEquals("custom exception", exception.getMessage());
+		assertNotNull(exception.getFaultInfo());
+		assertEquals("bean custom fault info", exception.getFaultInfo().getFaultInfo());
+		assertEquals("bean custom message", exception.getFaultInfo().getMessage());
+		
+	}
+    
+    public void testFaultyWebService_badEndpoint(){
+        
+        String host = "this.is.a.bad.endpoint.terrible.in.fact";
+        String badEndpoint = "http://" + host;
+        
+        WebServiceException exception = null;
+
+        try{
+            TestLogger.logger.debug("----------------------------------");
+            TestLogger.logger.debug("test: " + getName());
+            FaultyWebServiceService service = new FaultyWebServiceService();
+            FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+            BindingProvider p = (BindingProvider)proxy;
+            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,badEndpoint);
+
+            // the invoke will throw an exception, if the test is performed right
+            int total = proxy.faultyWebService(10);
+
+        }catch(FaultyWebServiceFault_Exception e) {
+            // shouldn't get this exception
+            fail(e.toString());
+        }catch(WebServiceException e) {
+            exception = e;
+        }catch(Exception e) {
+            fail("This testcase should only produce a WebServiceException.  We got: " + e.toString());
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        assertTrue(exception.getCause() instanceof UnknownHostException);
+        assertEquals(exception.getCause().getMessage(), host);
+
+    }
+
+    // TODO should also have an invoke oneway bad endpoint test to make sure
+    // we get an exception as indicated in JAXWS 6.4.2.
+
+    
+    public void testFaultyWebService_badEndpoint_oneWay() {
+        
+        String host = "this.is.a.bad.endpoint.terrible.in.fact";
+        String badEndpoint = "http://" + host;
+        
+        WebServiceException exception = null;
+
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+        try{
+            
+            DocLitWrapService service = new DocLitWrapService();
+            DocLitWrap proxy = service.getDocLitWrapPort();
+            BindingProvider p = (BindingProvider)proxy;
+            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,badEndpoint);
+            proxy.oneWayVoid();
+            
+        }catch(WebServiceException e) {
+            exception = e;
+        }catch(Exception e) {
+            fail("This testcase should only produce a WebServiceException.  We got: " + e.toString());
+        }
+
+        TestLogger.logger.debug("----------------------------------");
+        
+        assertNotNull(exception);
+        assertTrue(exception.getCause() instanceof UnknownHostException);
+        assertEquals(exception.getCause().getMessage(), host);
+        
+    }
+    
+    public void testFaultyWebService_badEndpoint_AsyncCallback()
+            throws Exception {
+
+        String host = "this.is.a.bad.endpoint.terrible.in.fact";
+        String badEndpoint = "http://" + host;
+
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+
+        FaultyWebServiceService service = new FaultyWebServiceService();
+        FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+        BindingProvider p = (BindingProvider) proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                badEndpoint);
+
+        FaultyAsyncHandler callback = new FaultyAsyncHandler();
+        Future<?> future = proxy.faultyWebServiceAsync(1, callback);
+
+        while (!future.isDone()) {
+            Thread.sleep(1000);
+            TestLogger.logger.debug("Async invocation incomplete");
+        }
+
+        Exception e = callback.getException();
+
+        // Section 4.3.3 states that the top level Exception should be
+        // an ExecutionException, with a WebServiceException underneath.
+        assertNotNull("The exception was null.", e);
+        assertTrue("The thrown exception should be an ExecutionException.", e
+                .getClass().equals(ExecutionException.class));
+        assertTrue(
+                "The expected fault type under the ExecutionException should be a "
+                        + "SOAPFaultException.  Found type: "
+                        + e.getCause().getClass(), e.getCause().getClass()
+                        .isAssignableFrom(SOAPFaultException.class));
+
+    }
+    
+    public void testFaultyWebService_badEndpoint_AsyncPolling()
+            throws Exception {
+
+        String host = "this.is.a.bad.endpoint.terrible.in.fact";
+        String badEndpoint = "http://" + host;
+
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+
+        FaultyWebServiceService service = new FaultyWebServiceService();
+        FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+        BindingProvider p = (BindingProvider) proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                badEndpoint);
+
+        Future<?> future = proxy.faultyWebServiceAsync(1);
+        while (!future.isDone()) {
+            Thread.sleep(1000);
+            TestLogger.logger.debug("Async invocation incomplete");
+        }
+
+        Exception e = null;
+        try {
+            Object obj = future.get();
+        } catch (Exception ex) {
+            e = ex;
+        }
+        
+        // Section 4.3.3 states that the top level Exception should be
+        // an ExecutionException, with a WebServiceException underneath.
+        assertNotNull("The exception was null.", e);
+        assertTrue("The thrown exception should be an ExecutionException.", e
+                .getClass().equals(ExecutionException.class));
+        assertTrue(
+                "The expected fault type under the ExecutionException should be a "
+                        + "SOAPFaultException.  Found type: "
+                        + e.getCause().getClass(), e.getCause().getClass()
+                        .isAssignableFrom(SOAPFaultException.class));
+
+    }
+    
+    /*
+     * Tests fault processing for user defined fault types
+     */      
+    public void testCustomFault_AsyncCallback() throws Exception {
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        FaultyWebServiceService service = new FaultyWebServiceService();
+        FaultyWebServicePortType proxy = service.getFaultyWebServicePort();
+        BindingProvider p = (BindingProvider) proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+        
+        FaultyAsyncHandler callback = new FaultyAsyncHandler();
+        Future<?> future = proxy.faultyWebServiceAsync(1, callback);
+
+        while (!future.isDone()) {
+            Thread.sleep(1000);
+            TestLogger.logger.debug("Async invocation incomplete");
+        }
+        
+        Exception e = callback.getException();
+        e.printStackTrace();
+        
+        // Section 4.3.3 states that the top level Exception should be
+        // an ExecutionException, with a WebServiceException underneath.
+        assertNotNull("The exception was null.", e);
+        assertTrue("The thrown exception should be an ExecutionException.", 
+                e.getClass().equals(ExecutionException.class));
+        assertTrue("The expected fault type under the ExecutionException should be a " +
+                "FaultyWebServiceFault_Exception.  Found type: " + e.getCause().getClass(), 
+                e.getCause().getClass().isAssignableFrom(FaultyWebServiceFault_Exception.class));
+    }
+
+
+    /*
+     * A callback implementation that can be used to collect the exceptions
+     */
+    class FaultyAsyncHandler implements AsyncHandler<FaultyWebServiceResponse> {
+     
+        Exception exception;
+        
+        public void handleResponse(Response<FaultyWebServiceResponse> response) {
+            try {
+                TestLogger.logger.debug("FaultyAsyncHandler.handleResponse() was called");
+                FaultyWebServiceResponse r = response.get();
+                TestLogger.logger.debug("No exception was thrown from Response.get()");
+            }
+            catch (Exception e) {
+                TestLogger.logger.debug("An exception was thrown: " + e.getClass());
+                exception = e;
+            }
+        }
+        
+        public Exception getException() {
+            return exception;
+        }
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleByteArrayTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.awt.Image;
+import java.io.File;
+
+import javax.imageio.ImageIO;
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.jaxws.sample.mtom1.ImageDepot;
+import org.apache.axis2.jaxws.sample.mtom1.ObjectFactory;
+import org.apache.axis2.jaxws.sample.mtom1.Invoke;
+import org.apache.axis2.jaxws.sample.mtom1.SendImageResponse;
+import org.apache.axis2.jaxws.TestLogger;
+import org.w3._2005._05.xmlmime.Base64Binary;
+
+import com.sun.xml.bind.v2.runtime.unmarshaller.Base64Data;
+
+public class MtomSampleByteArrayTests extends TestCase {
+
+    private static final QName QNAME_SERVICE = new QName("urn://mtom1.sample.jaxws.axis2.apache.org", "SendImageService");
+    private static final QName QNAME_PORT    = new QName("urn://mtom1.sample.jaxws.axis2.apache.org", "sendImageSoap");
+    private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/SendImageService";
+    private static final String IMAGE_DIR = System.getProperty("basedir",".")+File.separator+"test-resources"+File.separator+"image";
+
+    /*
+     * Enable attachment Optimization through the SOAPBinding method 
+     * -- setMTOMEnabled([true|false])
+     * Using SOAP11
+     */
+    public void testAttachmentByteArrayAPI11() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+    	
+      	String imageResourceDir = IMAGE_DIR;
+      		
+      	Service svc = Service.create(QNAME_SERVICE);
+      	svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+      	
+      	JAXBContext jbc = JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
+      	Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc, Service.Mode.PAYLOAD);
+      	
+      	SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
+      	binding.setMTOMEnabled(true);
+      	
+      	Image image = ImageIO.read (new File(imageResourceDir+File.separator+"test.jpg"));
+      	ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+      	imageDepot.setImageData(image);
+        setText(imageDepot);
+      	
+      	//Create a request bean with imagedepot bean as value
+      	ObjectFactory factory = new ObjectFactory();
+      	Invoke request = factory.createInvoke();
+      	request.setInput(imageDepot);
+      	
+      	SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+      	
+      	assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        checkText(response.getOutput());
+    }
+    
+    /*
+     * Disable attachment Optimization through the SOAPBinding method 
+     * -- setMTOMEnabled([true|false])
+     * Using SOAP11
+     */
+    public void testAttachmentByteArrayAPI11_ClientSendsNonOptimizedMTOM() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+            
+        Service svc = Service.create(QNAME_SERVICE);
+        svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+        
+        JAXBContext jbc = JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
+        Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc, Service.Mode.PAYLOAD);
+        
+        SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
+        binding.setMTOMEnabled(false);  // Disabling MTOM optimization on client, but server will respond with optimized MTOM
+        
+        Image image = ImageIO.read (new File(imageResourceDir+File.separator+"test.jpg"));
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(image);
+        setText(imageDepot);
+        
+        //Create a request bean with imagedepot bean as value
+        ObjectFactory factory = new ObjectFactory();
+        Invoke request = factory.createInvoke();
+        request.setInput(imageDepot);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        checkText(response.getOutput());
+    }
+    
+    /*
+     * Enable attachment optimization using the SOAP11 binding
+     * property for MTOM.
+     */
+    public void testAttachmentByteArrayProperty11() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+    	
+      	String imageResourceDir = IMAGE_DIR;
+      		
+      	Service svc = Service.create(QNAME_SERVICE);
+      	svc.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING, URL_ENDPOINT);
+      	
+      	JAXBContext jbc = JAXBContext.newInstance("org.apache.axis2.jaxws.sample.mtom1");
+      	Dispatch<Object> dispatch = svc.createDispatch(QNAME_PORT, jbc, Service.Mode.PAYLOAD);
+      	
+      	Image image = ImageIO.read (new File(imageResourceDir+File.separator+"test.jpg"));
+      	ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+      	imageDepot.setImageData(image);
+        setText(imageDepot);
+      	
+      	//Create a request bean with imagedepot bean as value
+      	ObjectFactory factory = new ObjectFactory();
+      	Invoke request = factory.createInvoke();
+      	request.setInput(imageDepot);
+      	
+      	SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+      	
+      	assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        checkText(response.getOutput());
+        
+    }
+    
+    private static final String text = "Binary Attachments are radical";
+    private void setText(ImageDepot depot) {
+        
+        Base64Binary binary = new Base64Binary();
+        binary.setContentType("");
+        binary.setValue(text.getBytes());
+        depot.setTextData(binary);
+    }
+    
+    private void checkText(ImageDepot depot) {
+        Base64Binary binary = depot.getTextData();
+        assertTrue(binary != null);
+        String contentType = binary.getContentType();
+        assertTrue("".equals(contentType));
+        byte[] bytes = binary.getValue();
+        assertTrue(bytes != null);
+        String theText = new String(bytes);
+        assertTrue(text.equals(theText));
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample;
+
+
+import java.awt.Image;
+import java.io.File;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageInputStream;
+import javax.imageio.stream.ImageInputStream;
+import javax.xml.bind.JAXBContext;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.SOAPBinding;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.provider.DataSourceImpl;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+import org.test.mtom.SendImage;
+import org.test.mtom.SendImageResponse;
+
+public class MtomSampleTests extends TestCase {
+
+    private static final QName QNAME_SERVICE = new QName("urn://mtom.test.org", "MtomSampleService");
+    private static final QName QNAME_PORT    = new QName("urn://mtom.test.org", "MtomSample");
+    private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleServicePort";
+    private static final String IMAGE_DIR = System.getProperty("basedir",".")+"/"+"test-resources"+File.separator+"image";   
+    
+    /*
+     * Enable attachment Optimization through the SOAPBinding method 
+     * -- setMTOMEnabled([true|false])
+     * Using SOAP11
+     */
+    public void _testSendImageAttachmentAPI11() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        //Enable attachment optimization
+        SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+        binding.setMTOMEnabled(true);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+    }
+    
+    /*
+     * Enable attachment optimization using the SOAP11 binding
+     * property for MTOM.
+     */
+    public void _testSendImageAttachmentProperty11() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+    }
+    
+    /*
+     * Enable attachment optimization using both the SOAP11 binding
+     * property for MTOM and the Binding API
+     */
+    public void _testSendImageAttachmentAPIProperty11() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_MTOM_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        
+        //Enable attachment optimization
+        SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+        binding.setMTOMEnabled(true);
+        
+        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+    }
+    
+    /*
+     * Enable attachment optimization using both the SOAP12 binding
+     * property for MTOM
+     * 
+     * Sending SOAP12 message to SOAP11 endpoint will correctly result in exception
+     * 
+     */
+    public void testSendImageAttachmentProperty12() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_MTOM_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        try {
+            SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+            fail("Was expecting an exception due to sending SOAP12 message to SOAP11 endpoint.");
+        } catch (Exception e) {
+            assertNotNull(e);
+        }
+        /*
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        */
+    }
+    
+    
+    /*
+     * Enable attachment optimization using both the SOAP12 binding API
+     * for MTOM
+     * 
+     * Sending SOAP12 message to SOAP11 endpoint will correctly result in exception
+     * 
+     */
+    public void testSendImageAttachmentAPI12() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Create the JAX-WS client needed to send the request with soap 11 binding
+        // property for MTOM
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING, URL_ENDPOINT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD);
+        
+        
+        //Enable attachment optimization
+        SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+        binding.setMTOMEnabled(true);
+        
+        try {
+            SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+            fail("Was expecting an exception due to sending SOAP12 message to SOAP11 endpoint.");
+        } catch (Exception e) {
+            assertNotNull(e);
+        }
+        /*
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        */
+    }
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/NonWrapTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * 
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.Holder;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.sample.nonwrap.sei.DocLitNonWrapPortType;
+import org.apache.axis2.jaxws.sample.nonwrap.sei.DocLitNonWrapService;
+import org.apache.axis2.jaxws.TestLogger;
+import org.test.sample.nonwrap.ObjectFactory;
+import org.test.sample.nonwrap.ReturnType;
+import org.test.sample.nonwrap.TwoWay;
+import org.test.sample.nonwrap.TwoWayHolder;
+
+public class NonWrapTests extends TestCase {
+
+	
+	public NonWrapTests() {
+		super();
+		// TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * @param arg0
+	 */
+	public NonWrapTests(String arg0) {
+		super(arg0);
+		// TODO Auto-generated constructor stub
+	}
+	
+	public void testTwoWaySync(){
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+		try{
+			TwoWay twoWay = new ObjectFactory().createTwoWay();
+			twoWay.setTwowayStr("testing sync call for java bean non wrap endpoint");
+			DocLitNonWrapService service = new DocLitNonWrapService();
+			DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+			ReturnType returnValue = proxy.twoWay(twoWay);
+            TestLogger.logger.debug(returnValue.getReturnStr());
+            TestLogger.logger.debug("------------------------------");
+		}catch(Exception e){
+			e.printStackTrace();
+			fail();
+		}
+	}
+    
+    public void testTwoWaySyncNull() throws Exception{
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+        try{
+            TwoWay twoWay = null;  // This should cause an WebServiceException
+            DocLitNonWrapService service = new DocLitNonWrapService();
+            DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+            ReturnType returnValue = proxy.twoWay(twoWay);
+            
+            // TODO Revisit JAXB validation
+            // JAXWS does not make the decision of whether a
+            // null parameter can be marshalled.  This decision is
+            // delegated to JAXB.  In this case, the schema indicates
+            // that this is not a nillable element.  The assumption is
+            // that JAXB will fail.  However the current version of 
+            // JAXB considers this as 'validation checking' and is not
+            // supported.  Thus JAXB will marshal the element without
+            // an exception (and unmarshal without exception) even though
+            // this is a violation of the schema.
+            
+            
+            
+            //fail("Expected WebServiceException");
+            
+            
+        } catch(WebServiceException e){
+            TestLogger.logger.debug(e.toString());
+        }
+    }
+
+	public void testTwoWayASyncCallback(){
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+		try{
+			TwoWay twoWay = new ObjectFactory().createTwoWay();
+			twoWay.setTwowayStr("testing Async call for java bean non wrap endpoint");
+			DocLitNonWrapService service = new DocLitNonWrapService();
+			DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+			AsyncCallback callback = new AsyncCallback();
+			Future<?> monitor = proxy.twoWayAsync(twoWay, callback);
+			assertNotNull(monitor);
+            TestLogger.logger.debug("------------------------------");
+		}catch(Exception e){
+			e.printStackTrace();
+			fail();
+		}
+	}
+	public void testTwoWayHolder(){
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+		try{
+			TwoWayHolder twh = new TwoWayHolder();
+			twh.setTwoWayHolderInt(new Integer(0));
+			twh.setTwoWayHolderStr(new String("Request Holder String"));
+			Holder<TwoWayHolder> holder = new Holder<TwoWayHolder>(twh);
+			TwoWay twoWay = new ObjectFactory().createTwoWay();
+			twoWay.setTwowayStr("testing sync call for java bean non wrap endpoint");
+			DocLitNonWrapService service = new DocLitNonWrapService();
+			DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+			proxy.twoWayHolder(holder);
+			twh = holder.value;
+            TestLogger.logger.debug("Holder string =" + twh.getTwoWayHolderStr());
+            TestLogger.logger.debug("Holder int =" + twh.getTwoWayHolderInt());
+
+            TestLogger.logger.debug("------------------------------");
+		}catch(Exception e){
+			e.printStackTrace();
+			fail();
+		}
+	}
+	
+	public void testTwoWayHolderAsync(){
+        TestLogger.logger.debug("------------------------------");
+        TestLogger.logger.debug("Test : " + getName());
+		try{
+			TwoWayHolder twh = new TwoWayHolder();
+			twh.setTwoWayHolderInt(new Integer(0));
+			twh.setTwoWayHolderStr(new String("Request Holder String"));
+			Holder<TwoWayHolder> holder = new Holder<TwoWayHolder>(twh);
+			TwoWay twoWay = new ObjectFactory().createTwoWay();
+			twoWay.setTwowayStr("testing sync call for java bean non wrap endpoint");
+			DocLitNonWrapService service = new DocLitNonWrapService();
+			DocLitNonWrapPortType proxy = service.getDocLitNonWrapPort();
+			AsyncCallback callback = new AsyncCallback();
+			Future<?> monitor =proxy.twoWayHolderAsync(twh, callback);
+			while(!monitor.isDone()){
+				Thread.sleep(1000);
+			}
+
+            TestLogger.logger.debug("------------------------------");
+		}catch(Exception e){
+			e.printStackTrace();
+			fail();
+		}
+	}
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/ParallelAsyncTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,604 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.RejectedExecutionException;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Response;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.axis2.jaxws.sample.parallelasync.common.CallbackHandler;
+import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncPort;
+import org.apache.axis2.jaxws.sample.parallelasync.server.AsyncService;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.log4j.BasicConfigurator;
+import org.test.parallelasync.CustomAsyncResponse;
+import org.test.parallelasync.SleepResponse;
+import org.test.parallelasync.WakeUpResponse;
+
+/**
+ * Tests for Asynchrony in JAX-WS. Most of the simple invokeAsync/async
+ * exceptions have been covered under jaxws.dispatch and jaxws.proxy test suites
+ * 
+ * ExecutionException tests are covered in jaxws.dispatch and jaxws.proxy
+ */
+public class ParallelAsyncTests extends TestCase {
+
+    private static final String DOCLITWR_ASYNC_ENDPOINT =
+        "http://localhost:6060/axis2/services/AsyncService.DocLitWrappedPortImplPort";
+
+    // used for logging
+    private String myClassName = "ParallelAsyncTests";
+
+    public ParallelAsyncTests(String str) {
+        super(str);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(ParallelAsyncTests.class);
+        return suite;
+        
+    }
+
+    public void setUp() {
+        TestLogger.logger.debug("==================== " + getName());
+    }
+    
+    public void testNOOP () {}
+
+    /**
+     * @testStrategy Check that the web service is up and running 
+     *               before running any other tests
+     */
+    public void testService_isAlive() throws Exception {
+        final String MESSAGE = "testServiceAlive";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncPort port = getPort((Executor)null);
+
+        String req1base = "sleepAsync";
+        String req2base = "remappedAsync";
+
+        String request1 = null;
+        String request2 = null;
+
+        for (int i = 0; i < 10; i++) {
+            
+            request1 = req1base + "_" + i;
+            request2 = req2base + "_" + i;
+
+            TestLogger.logger.debug(title + "iteration [" + i + "] using request1 [" + request1 +
+                    "]  request2 [" + request2 + "]");
+
+            // submit request #1 to the server-side web service that 
+            // the web service will keep until we ask for it
+            Response<SleepResponse> resp1 = port.sleepAsync(request1);
+
+            // submit request #2 to the server that essentially processes
+            // without delay
+            Response<CustomAsyncResponse> resp2 = port.remappedAsync(request2);
+
+            // wait until the response for request #2 is done 
+            waitBlocking(resp2);
+
+            // check the waiting request #1
+            String asleep = port.isAsleep(request1);
+            //System.out.println(title+"iteration ["+i+"]   port.isAsleep(request1 ["+request1+"]) = ["+asleep+"]");
+
+            // wakeup the waiting request #1
+            String wake = port.wakeUp(request1);
+            //System.out.println(title+"iteration ["+i+"]   port.wakeUp(request1 ["+request1+"]) = ["+wake+"]");
+
+            // wait until the response for request #1 is done
+            waitBlocking(resp1);
+        
+            // get the responses
+            String req1_result = null;
+            String req2_result = null;
+
+            try {
+                req1_result = resp1.get().getMessage();
+                req2_result = resp2.get().getResponse();
+            } catch (Exception e) {
+                TestLogger.logger.debug(
+                        title + "iteration [" + i + "] using request1 [" + request1 +
+                                "]  request2 [" + request2 + "] :  got exception [" +
+                                e.getClass().getName() + "]  [" + e.getMessage() + "] ");
+                e.printStackTrace();
+                fail(e.toString());
+            }
+
+            // check status on request #1
+            assertEquals("sleepAsync did not sleep as expected", request1, asleep);
+            assertEquals("sleepAsync did not return expected response ", request1, req1_result);
+
+            // check status on request #2
+            assertEquals("remappedAsync did not return expected response", request2, req2_result);
+            
+
+            // Calling get() again should return the same object as the first call to get()
+            assertEquals("sleepAsync did not return expected response ", request1, resp1.get().getMessage());
+            assertEquals("remappedAsync did not return expected response", request2, resp2.get().getResponse());
+            
+        }
+        
+        // check the callback operation
+		CallbackHandler<SleepResponse> sleepCallbackHandler = new CallbackHandler<SleepResponse>();
+
+        request1 = req1base + "_with_Callback";
+        //System.out.println(title+" port.sleepAsync("+request1+", callbackHander)  being submitted....");
+		Future<?> sr = port.sleepAsync(request1, sleepCallbackHandler);
+
+        // wait a bit for the server to process the request ...
+        Thread.sleep(500);
+
+        // check the waiting request 
+        String asleepWithCallback = port.isAsleep(request1);
+        //System.out.println(title+" port.isAsleep("+request1+") = ["+asleepWithCallback+"]");
+
+        // wakeup the waiting request
+        String wake = port.wakeUp(request1);
+        //System.out.println(title+" port.wakeUp("+request1+") = ["+wake+"]");
+
+        // wait a bit..
+        Thread.sleep(500);
+
+        // get the response
+        String req_cb_result = null;
+
+        try {
+
+            SleepResponse sleepResp = sleepCallbackHandler.get();
+
+            if (sleepResp != null)
+            {
+                req_cb_result = sleepResp.getMessage();
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] :  result [" + req_cb_result + "] ");
+            }
+
+        } catch (Exception ex) {
+            TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
+                    ex.getClass().getName() + "]  [" + ex.getMessage() + "] ");
+            ex.printStackTrace();
+            fail(ex.toString());
+        }
+
+        // check status on request
+        assertEquals("sleepAsync with callback did not sleep as expected", request1, req_cb_result);
+
+    }
+
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow while there
+     *               is a request being processed.  Uses the default executor.
+     *               
+     */
+    public void testService_ExecutorShutdownNow() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+        ExecutorService ex = null;
+        Executor executor = service.getExecutor();
+        if ((executor != null) && (executor instanceof ExecutorService))
+        {
+            ex = (ExecutorService) executor;
+        }
+        else
+        {
+            TestLogger.logger.debug(title + " No executor service available. Nothing to test.");
+            return;
+        }
+
+
+        // submit a request to the server that will wait until we ask for it
+		CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+
+        String request1 = "sleepAsync_with_Callback_1";
+
+        TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
+                ", callbackHander1)  #1 being submitted....");
+		Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+        TestLogger.logger.debug(
+                title + " port.sleepAsync(" + request1 + ", callbackHander1)  #1 .....submitted.");
+
+        // wait a bit to make sure that the server has the request
+        Thread.sleep(1000);
+
+		// tell the executor to shutdown immediately, which 
+        // attempts to stop all actively executing tasks via Thread.interrupt()
+        // and should prevent new tasks from being submitted
+        TestLogger.logger
+                .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
+        ex.shutdownNow();
+
+        // check the waiting request 
+        TestLogger.logger.debug(title + " port.isAsleep(" + request1 + ") #1 being submitted....");
+        String asleepWithCallback1 = port.isAsleep(request1);
+        TestLogger.logger.debug(
+                title + " port.isAsleep(" + request1 + ") #1 = [" + asleepWithCallback1 + "]");
+
+        // wakeup the waiting request
+        TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
+        String wake1 = port.wakeUp(request1);
+        TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");
+
+        // wait a bit..
+        Thread.sleep(2000);
+
+        // check the Future
+        if (sr1.isDone())
+        {
+            TestLogger.logger.debug(title + " sr1.isDone[TRUE] ");
+        }
+
+        // try to get the response
+        boolean gotException = false;
+        try {
+
+            SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+            if (sleepResp1 != null)
+            {
+                TestLogger.logger.debug(title + " request [" + request1 +
+                        "] #1:  sleepResponse [NOT NULL] from callback handler");
+                String result1 = sleepResp1.getMessage();
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  result [" + result1 + "] ");
+            }
+            else
+            {
+                TestLogger.logger.debug(title + " request [" + request1 +
+                        "] #1:  sleepResponse [NULL] from callback handler");
+
+                // see what the Future says
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  ....check Future response...");
+                Object futureResult = sr1.get();
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  ....Future response [" +
+                                futureResult + "]...");
+            }
+
+        } catch (Exception exc) {
+
+            TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
+                    exc.getClass().getName() + "]  [" + exc.getMessage() + "] ");
+            gotException = true;
+        }
+
+        assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotException);
+    }
+
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow while there
+     *               is a request being processed.  Uses an application executor
+     *               service.
+     */
+    public void testService_ExecutorShutdownNow_2() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow_2";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+		ExecutorService ex = Executors.newSingleThreadExecutor();
+		service.setExecutor(ex);
+
+
+        // submit a request to the server that will wait until we ask for it
+		CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+
+        String request1 = "sleepAsync_with_Callback_1";
+
+        TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
+                ", callbackHander1)  #1 being submitted....");
+		Future<?> sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+        TestLogger.logger.debug(
+                title + " port.sleepAsync(" + request1 + ", callbackHander1)  #1 .....submitted.");
+
+        // wait a bit to make sure that the server has the request
+        Thread.sleep(1000);
+
+		// tell the executor to shutdown immediately, which 
+        // attempts to stop all actively executing tasks via Thread.interrupt()
+        // and should prevent new tasks from being submitted
+        TestLogger.logger
+                .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
+        ex.shutdownNow();
+
+        // check the waiting request 
+        TestLogger.logger.debug(title + " port.isAsleep(" + request1 + ") #1 being submitted....");
+        String asleepWithCallback1 = port.isAsleep(request1);
+        TestLogger.logger.debug(
+                title + " port.isAsleep(" + request1 + ") #1 = [" + asleepWithCallback1 + "]");
+
+        // wakeup the waiting request
+        TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
+        String wake1 = port.wakeUp(request1);
+        TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");
+
+        // wait a bit..
+        Thread.sleep(2000);
+
+        // check the Future
+        if (sr1.isDone())
+        {
+            TestLogger.logger.debug(title + " sr1.isDone[TRUE] ");
+        }
+
+        // try to get the response
+        boolean gotException = false;
+        try {
+
+            SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+            if (sleepResp1 != null)
+            {
+                TestLogger.logger.debug(title + " request [" + request1 +
+                        "] #1:  sleepResponse [NOT NULL] from callback handler");
+                String result1 = sleepResp1.getMessage();
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  result [" + result1 + "] ");
+            }
+            else
+            {
+                TestLogger.logger.debug(title + " request [" + request1 +
+                        "] #1:  sleepResponse [NULL] from callback handler");
+
+                // see what the Future says
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  ....check Future response...");
+                Object futureResult = sr1.get();
+                TestLogger.logger.debug(
+                        title + " request [" + request1 + "] #1:  ....Future response [" +
+                                futureResult + "]...");
+            }
+
+        } catch (Exception exc) {
+
+            TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
+                    exc.getClass().getName() + "]  [" + exc.getMessage() + "] ");
+            gotException = true;
+        }
+
+        assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotException);
+    }
+
+    /**
+     * @testStrategy Test for ordering an executor to shutdownNow before there
+     *               is a request.  Uses the default executor.
+     *               
+     */
+    public void testService_ExecutorShutdownNow_3() throws Exception {
+        final String MESSAGE = "testExecutorShutdownNow_3";
+
+        String title = myClassName + " : " + getName() + " : ";
+
+        AsyncService service = getService(null);
+        AsyncPort port = getPort(service);
+
+		// get the default executor and check to make sure it is an executor service
+        ExecutorService ex = null;
+        Executor executor = service.getExecutor();
+        if ((executor != null) && (executor instanceof ExecutorService))
+        {
+            ex = (ExecutorService) executor;
+
+            // tell the executor to shutdown immediately, which 
+            // attempts to stop all actively executing tasks via Thread.interrupt()
+            // and should prevent new tasks from being submitted
+            TestLogger.logger
+                    .debug(title + " shutting down executor [" + ex.getClass().getName() + "]");
+            ex.shutdownNow();
+        }
+        else
+        {
+            TestLogger.logger.debug(title + " No executor service available. Nothing to test.");
+            return;
+        }
+
+
+        boolean gotRequestException = false;
+
+        String request1 = "sleepAsync_with_Callback_1";
+        CallbackHandler<SleepResponse> sleepCallbackHandler1 = new CallbackHandler<SleepResponse>();
+        Future<?> sr1 = null;
+
+        try
+        {
+            // submit a request to the server that will wait until we ask for it
+            TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
+                    ", callbackHander1)  #1 being submitted....");
+            sr1 = port.sleepAsync(request1, sleepCallbackHandler1);
+            TestLogger.logger.debug(title + " port.sleepAsync(" + request1 +
+                    ", callbackHander1)  #1 .....submitted.");
+        }
+        catch (Exception exc)
+        {
+            TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
+                    exc.getClass().getName() + "]  [" + exc.getMessage() + "] ");
+            gotRequestException = true;
+        }
+
+        // if the request went through, continue processing to see if the response is stopped
+        // this makes sure that the server doesn't keep the request forever
+        boolean gotResponseException = false;
+
+        if (!gotRequestException)
+        {
+            // wakeup the waiting request
+            TestLogger.logger.debug(title + " port.wakeUp(request1) #1 being submitted....");
+            String wake1 = port.wakeUp(request1);
+            TestLogger.logger.debug(title + " port.wakeUp(" + request1 + ") #1 = [" + wake1 + "]");
+
+            // try to get the response
+            try {
+
+                SleepResponse sleepResp1 = sleepCallbackHandler1.get();
+
+                if (sleepResp1 != null)
+                {
+                    TestLogger.logger.debug(title + " request [" + request1 +
+                            "] #1:  sleepResponse [NOT NULL] from callback handler");
+                    String result1 = sleepResp1.getMessage();
+                    TestLogger.logger.debug(
+                            title + " request [" + request1 + "] #1:  result [" + result1 + "] ");
+                }
+                else
+                {
+                    TestLogger.logger.debug(title + " request [" + request1 +
+                            "] #1:  sleepResponse [NULL] from callback handler");
+
+                    // see what the Future says
+                    TestLogger.logger.debug(title + " request [" + request1 +
+                            "] #1:  ....check Future response...");
+                    Object futureResult = sr1.get();
+                    TestLogger.logger.debug(title + " request [" + request1 +
+                            "] #1:  ....Future response [" + futureResult + "]...");
+                }
+
+            } catch (Exception exc) {
+
+                TestLogger.logger.debug(title + " request [" + request1 + "] :  got exception [" +
+                        exc.getClass().getName() + "]  [" + exc.getMessage() + "] ");
+                gotResponseException = true;
+            }
+        }
+
+        assertTrue("Did not receive an exception from trying to submit the request when the executor service is shutdown.",gotRequestException);
+
+        //assertTrue("Did not receive an exception from trying to access the response when the executor service is shutdown.",gotResponseException);
+    }
+
+
+
+
+    /**
+     * Auxiliary method used for doing isAsleep checks. Will perform isAsleep
+     * up to a MAX_ISASLEEP_CHECK number of checks. Will sleep for
+     * SLEEP_ISASLEEP_SEC seconds in between requests. If reaches maximum number
+     * fo retries then will fail the test
+     */
+    private boolean isAsleepCheck(String MESSAGE, AsyncPort port) {
+        boolean asleep = false;
+        int check = 30;
+        String msg = null;
+        do {
+            msg = port.isAsleep(MESSAGE);
+            asleep = (msg != null);
+
+            // fail the test if we ran out of checks
+            if ((check--) == 0)
+                fail("Serve did not receive sleep after several retries");
+
+            // sleep for a bit
+            try {
+                Thread.sleep(30);
+            } 
+            catch (InterruptedException e) {
+            }
+
+        } while (!asleep);
+
+        if (asleep) {
+            assertTrue("Sleeping on an incorrect message", MESSAGE.equals(msg));
+        }
+
+        return true;
+    }
+    
+
+    private AsyncService getService(Executor ex) {
+        AsyncService service = new AsyncService();
+
+        if (ex!= null)
+            service.setExecutor(ex);
+        
+        if (service.getExecutor() == null)
+        {
+            TestLogger.logger.debug(myClassName + " : getService() : executor is null");
+        }
+        else
+        {
+            TestLogger.logger.debug(myClassName + " : getService() : executor is available ");
+        }
+
+        return service;
+    }
+
+
+    private AsyncPort getPort(AsyncService service) {
+
+        AsyncPort port = service.getAsyncPort();
+        assertNotNull("Port is null", port);
+
+        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                DOCLITWR_ASYNC_ENDPOINT);
+        
+        return port;
+
+    }
+
+    /**
+     * Auxiliary method used for obtaining a proxy pre-configured with a
+     * specific Executor
+     */
+    private AsyncPort getPort(Executor ex) {
+        AsyncService service = getService(ex);
+
+        AsyncPort port = service.getAsyncPort();
+        assertNotNull("Port is null", port);
+
+        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+                DOCLITWR_ASYNC_ENDPOINT);
+        
+        return port;
+    }
+    
+    private void waitBlocking(Future<?> monitor){
+        while (!monitor.isDone()){
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/StringListTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/StringListTests.java?rev=633234&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/StringListTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/StringListTests.java Mon Mar  3 10:47:38 2008
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.sample;
+
+import org.apache.axis2.jaxws.stringlist.sei.StringListPortType;
+import org.apache.axis2.jaxws.stringlist.sei.StringListService;
+import org.apache.axis2.jaxws.TestLogger;
+
+import junit.framework.TestCase;
+
+
+public class StringListTests extends TestCase{
+    public void testStringListScenario() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        StringListService sls = new StringListService();
+        StringListPortType portType =sls.getStringListPort();
+        String[] retString = portType.stringList(new String[]{"String1","String2","String3"});
+        assertNotNull(retString);
+        assertTrue(retString.length == 3);
+    }
+}



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


Mime
View raw message