You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2013/05/21 18:52:18 UTC

svn commit: r1484872 - /axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java

Author: veithen
Date: Tue May 21 16:52:18 2013
New Revision: 1484872

URL: http://svn.apache.org/r1484872
Log:
Don't use the catch-and-fail JUnit anti-pattern.

Modified:
    axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java

Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java?rev=1484872&r1=1484871&r2=1484872&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/test/org/apache/axis2/jaxws/proxy/ProxyTests.java Tue May 21 16:52:18 2013
@@ -50,232 +50,191 @@ public class ProxyTests extends Abstract
     }
 
     public void testMultipleServiceCalls(){
-        try{
-            if(!runningOnAxis){
-                return;
-            }
-            TestLogger.logger.debug("---------------------------------------");
-            TestLogger.logger.debug("test:" + getName());
-            String request = new String("some string request");
-            TestLogger.logger.debug("Service Call #1");
-            ProxyDocLitWrappedService service1 = new ProxyDocLitWrappedService();
-            DocLitWrappedProxy proxy1 = service1.getDocLitWrappedProxyImplPort();
-            BindingProvider p1 =    (BindingProvider)proxy1;
-            p1.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-            String response1 = proxy1.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response1);
-            TestLogger.logger.debug("---------------------------------------");
-
-            TestLogger.logger.debug("Service Call #2");
-            ProxyDocLitWrappedService service2 = new ProxyDocLitWrappedService();
-            DocLitWrappedProxy proxy2 = service2.getDocLitWrappedProxyImplPort();
-            BindingProvider p2 =    (BindingProvider)proxy2;
-            p2.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-            String response2 = proxy2.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response2);
-            TestLogger.logger.debug("---------------------------------------");
-            
-        }catch(Exception e){
-            e.printStackTrace();
-            fail(getName() + " failed");
+        if(!runningOnAxis){
+            return;
         }
-    }
-    
-    public void testInvokeWithNullParam(){
-        try{ 
-            if(!runningOnAxis){
-                return;
-            }
-            TestLogger.logger.debug("---------------------------------------");
-            TestLogger.logger.debug("Test Name: " + getName());
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName); 
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
-            TestLogger.logger.debug(">>Invoking Binding Provider property");
-            BindingProvider p = (BindingProvider)proxy;
+        TestLogger.logger.debug("---------------------------------------");
+        TestLogger.logger.debug("test:" + getName());
+        String request = new String("some string request");
+        TestLogger.logger.debug("Service Call #1");
+        ProxyDocLitWrappedService service1 = new ProxyDocLitWrappedService();
+        DocLitWrappedProxy proxy1 = service1.getDocLitWrappedProxyImplPort();
+        BindingProvider p1 =    (BindingProvider)proxy1;
+        p1.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+        String response1 = proxy1.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response1);
+        TestLogger.logger.debug("---------------------------------------");
+
+        TestLogger.logger.debug("Service Call #2");
+        ProxyDocLitWrappedService service2 = new ProxyDocLitWrappedService();
+        DocLitWrappedProxy proxy2 = service2.getDocLitWrappedProxyImplPort();
+        BindingProvider p2 =    (BindingProvider)proxy2;
+        p2.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+        String response2 = proxy2.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response2);
+        TestLogger.logger.debug("---------------------------------------");
+    }
+    
+    public void testInvokeWithNullParam() throws Exception {
+        if(!runningOnAxis){
+            return;
+        }
+        TestLogger.logger.debug("---------------------------------------");
+        TestLogger.logger.debug("Test Name: " + getName());
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName); 
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
+        TestLogger.logger.debug(">>Invoking Binding Provider property");
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
+        TestLogger.logger.debug(">> Invoking Proxy Synchronously");
+        String request = null;
+        String response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+
+        // Try again
+        response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+        TestLogger.logger.debug("---------------------------------------");
+    }
+    
+    public void testInvoke() throws Exception {
+        if(!runningOnAxis){
+            return;
+        }
+        TestLogger.logger.debug("---------------------------------------");
+        
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName);
+        String request = new String("some string request"); 
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
+        TestLogger.logger.debug(">>Invoking Binding Provider property");
+        BindingProvider p = (BindingProvider)proxy;
             p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
-            TestLogger.logger.debug(">> Invoking Proxy Synchronously");
-            String request = null;
-            String response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
-
             
-            // Try again
-            response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
-            TestLogger.logger.debug("---------------------------------------");
-        }catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
-    }
-    public void testInvoke(){
-        try{ 
-            if(!runningOnAxis){
-                return;
-            }
-            TestLogger.logger.debug("---------------------------------------");
-            
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName);
-            String request = new String("some string request"); 
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
-            TestLogger.logger.debug(">>Invoking Binding Provider property");
-            BindingProvider p = (BindingProvider)proxy;
-                p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-                
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
-            TestLogger.logger.debug(">> Invoking Proxy Synchronously");
-            String response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
-            
-            // Try again
-            response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
-            TestLogger.logger.debug("---------------------------------------");
-        }catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
-    }
-
-    public void testInvokeWithWSDL(){
-
-    	try{ 
-            if(!runningOnAxis){
-                return;
-            }
-            TestLogger.logger.debug("---------------------------------------");
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(wsdlUrl, serviceName);
-            String request = new String("some string request"); 
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
-            TestLogger.logger.debug(">>Invoking Binding Provider property");
-            BindingProvider p = (BindingProvider)proxy;
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
+        TestLogger.logger.debug(">> Invoking Proxy Synchronously");
+        String response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+        
+        // Try again
+        response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+        TestLogger.logger.debug("---------------------------------------");
+    }
+
+    public void testInvokeWithWSDL() throws Exception {
+        if(!runningOnAxis){
+            return;
+        }
+        TestLogger.logger.debug("---------------------------------------");
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(wsdlUrl, serviceName);
+        String request = new String("some string request"); 
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
+        TestLogger.logger.debug(">>Invoking Binding Provider property");
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
+            
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
+        TestLogger.logger.debug(">> Invoking Proxy Synchronously");
+        String response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+        
+        // Try again
+        response = dwp.invoke(request);
+        TestLogger.logger.debug("Proxy Response =" + response);
+        TestLogger.logger.debug("---------------------------------------");
+    }
+    
+    public void testInvokeAsyncCallback() throws Exception {
+        if(!runningOnAxis){
+            return;
+        }
+        TestLogger.logger.debug("---------------------------------------");
+        
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName);
+        String request = new String("some string request"); 
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
+        TestLogger.logger.debug(">>Invoking Binding Provider property");
+        BindingProvider p = (BindingProvider)proxy;
             p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-                
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
-            TestLogger.logger.debug(">> Invoking Proxy Synchronously");
-            String response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
             
-            // Try again
-            response = dwp.invoke(request);
-            TestLogger.logger.debug("Proxy Response =" + response);
-            TestLogger.logger.debug("---------------------------------------");
-        }catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
-
-    }
-    
-    public void testInvokeAsyncCallback(){
-        try{ 
-            if(!runningOnAxis){
-                return;
-            }
-            TestLogger.logger.debug("---------------------------------------");
-            
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName);
-            String request = new String("some string request"); 
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class);
-            TestLogger.logger.debug(">>Invoking Binding Provider property");
-            BindingProvider p = (BindingProvider)proxy;
-                p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
-                
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
-            TestLogger.logger.debug(">> Invoking Proxy Asynchronous Callback");
-            AsyncHandler handler = new AsyncCallback();
-            Future<?> response = dwp.invokeAsync(request, handler);
-            
-            // Try again
-            handler = new AsyncCallback();
-            response = dwp.invokeAsync(request, handler);
-            TestLogger.logger.debug("---------------------------------------");
-        }catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
+        TestLogger.logger.debug(">> Invoking Proxy Asynchronous Callback");
+        AsyncHandler handler = new AsyncCallback();
+        Future<?> response = dwp.invokeAsync(request, handler);
+        
+        // Try again
+        handler = new AsyncCallback();
+        response = dwp.invokeAsync(request, handler);
+        TestLogger.logger.debug("---------------------------------------");
     }
     
-    public void testInvokeAsyncPolling() {
-        try {
-            TestLogger.logger.debug("---------------------------------------");
-            
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName);
-            DocLitWrappedProxy proxy =service.getPort(portName, DocLitWrappedProxy.class);
-            
-            String request = new String("some string request");
-
-            TestLogger.logger.debug(">> Invoking Binding Provider property");
-            BindingProvider p = (BindingProvider) proxy;
-            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+    public void testInvokeAsyncPolling() throws Exception {
+        TestLogger.logger.debug("---------------------------------------");
+        
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName);
+        DocLitWrappedProxy proxy =service.getPort(portName, DocLitWrappedProxy.class);
+        
+        String request = new String("some string request");
 
-            TestLogger.logger.debug(">> Invoking Proxy with async polling request");
-            Response<ReturnType> asyncResponse = proxy.invokeAsync(request);
+        TestLogger.logger.debug(">> Invoking Binding Provider property");
+        BindingProvider p = (BindingProvider) proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
 
-            while (!asyncResponse.isDone()) {
-                TestLogger.logger.debug(">> Async invocation still not complete");
-                Thread.sleep(1000);
-            }
-            
-            ReturnType response = asyncResponse.get();
-            assertNotNull(response);
-            
-            // Try again
-            asyncResponse = proxy.invokeAsync(request);
+        TestLogger.logger.debug(">> Invoking Proxy with async polling request");
+        Response<ReturnType> asyncResponse = proxy.invokeAsync(request);
 
-            while (!asyncResponse.isDone()) {
-                TestLogger.logger.debug(">> Async invocation still not complete");
-                Thread.sleep(1000);
-            }
-            
-            response = asyncResponse.get();
-            assertNotNull(response);
+        while (!asyncResponse.isDone()) {
+            TestLogger.logger.debug(">> Async invocation still not complete");
+            Thread.sleep(1000);
         }
-        catch(Exception e) { 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
+        
+        ReturnType response = asyncResponse.get();
+        assertNotNull(response);
+        
+        // Try again
+        asyncResponse = proxy.invokeAsync(request);
+
+        while (!asyncResponse.isDone()) {
+            TestLogger.logger.debug(">> Async invocation still not complete");
+            Thread.sleep(1000);
         }
+        
+        response = asyncResponse.get();
+        assertNotNull(response);
     }
     
-    public void testTwoWay(){
+    public void testTwoWay() throws Exception {
+        if(runningOnAxis){
+            return;
+        }
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName);
+        String request = new String("some string request"); 
         
-        try{ 
-            if(runningOnAxis){
-                return;
-            }
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName);
-            String request = new String("some string request"); 
-            
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class); 
-            BindingProvider p = (BindingProvider)proxy;
-            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-                
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;  
-            String response = dwp.twoWay(request);
-            System.out.println("Response =" + response);
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class); 
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
             
-            // Try again
-            response = dwp.twoWay(request);
-            System.out.println("Response =" + response);
-        } catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;  
+        String response = dwp.twoWay(request);
+        System.out.println("Response =" + response);
         
+        // Try again
+        response = dwp.twoWay(request);
+        System.out.println("Response =" + response);
     }
     
     public void testOneWay(){
@@ -286,35 +245,27 @@ public class ProxyTests extends Abstract
         
     }
     
-    public void testTwoWayAsyncCallback(){
+    public void testTwoWayAsyncCallback() throws Exception {
+        if(runningOnAxis){
+            return;
+        }
+        File wsdl= new File(wsdlLocation); 
+        URL wsdlUrl = wsdl.toURL(); 
+        Service service = Service.create(null, serviceName);
         
-        try{ 
-            if(runningOnAxis){
-                return;
-            }
-            File wsdl= new File(wsdlLocation); 
-            URL wsdlUrl = wsdl.toURL(); 
-            Service service = Service.create(null, serviceName);
-            
-            String request = new String("some string request"); 
-            
-            Object proxy =service.getPort(portName, DocLitWrappedProxy.class); 
-            BindingProvider p = (BindingProvider)proxy;
-                p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
-                
-            DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
-            AsyncHandler handler = new AsyncCallback();
-            Future<?> response = dwp.twoWayAsync(request, handler);
-            
-            // Try again
-            handler = new AsyncCallback();
-            response = dwp.twoWayAsync(request, handler);
-            
-        }catch(Exception e){ 
-            e.printStackTrace(); 
-            fail("Exception received" + e);
-        }
+        String request = new String("some string request"); 
         
+        Object proxy =service.getPort(portName, DocLitWrappedProxy.class); 
+        BindingProvider p = (BindingProvider)proxy;
+            p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+            
+        DocLitWrappedProxy dwp = (DocLitWrappedProxy)proxy;
+        AsyncHandler handler = new AsyncCallback();
+        Future<?> response = dwp.twoWayAsync(request, handler);
+        
+        // Try again
+        handler = new AsyncCallback();
+        response = dwp.twoWayAsync(request, handler);
     }
     
     public void testAsyncPooling(){