You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ba...@apache.org on 2007/04/17 22:41:38 UTC

svn commit: r529757 - in /webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws: provider/SoapMessageProviderTests.java provider/soapmsg/SoapMessageProvider.java proxy/GorillaDLWProxyTests.java proxy/rpclit/RPCLitImpl.java

Author: barrettj
Date: Tue Apr 17 13:41:37 2007
New Revision: 529757

URL: http://svn.apache.org/viewvc?view=rev&rev=529757
Log:
Change calls to Java assert() statement to JUnit assert*() methods.
Note that SOAPMessageProviderTests still fails at this point.  This is related to Axis2-2550, but is not the fix for it.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/GorillaDLWProxyTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java?view=diff&rev=529757&r1=529756&r2=529757
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/SoapMessageProviderTests.java Tue Apr 17 13:41:37 2007
@@ -118,8 +118,8 @@
         	SOAPMessage response = dispatch.invoke(request);
 
             // Check for valid content description
-            assert(response.getContentDescription() != null);
-            assert(response.getContentDescription().equals(SoapMessageProvider.XML_RESPONSE));
+            assertNotNull(response.getContentDescription());
+            assertEquals(SoapMessageProvider.XML_RESPONSE, response.getContentDescription());
             
             // Check assertions and get the data element
             SOAPElement dataElement = assertResponseXML(response, SoapMessageProvider.XML_RESPONSE);
@@ -398,7 +398,7 @@
             String content = SoapMessageProvider.getAsString(contentSS);
             assertTrue(content != null);
             assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
-            assert(attachmentPart.getContentId().equals(SoapMessageProvider.ID));
+            assertEquals(SoapMessageProvider.ID, attachmentPart.getContentId());
             
             // Print out the response
             TestLogger.logger.debug(">> Response [" + response.toString() + "]");
@@ -433,12 +433,12 @@
         assertTrue(body != null);
         
         Node invokeElement = (Node) body.getFirstChild();
-        assert(invokeElement instanceof SOAPElement);
-        assert(SoapMessageProvider.RESPONSE_NAME.equals(invokeElement.getLocalName()));
+        assertTrue(invokeElement instanceof SOAPElement);
+        assertEquals(SoapMessageProvider.RESPONSE_NAME, invokeElement.getLocalName());
         
         Node dataElement = (Node) invokeElement.getFirstChild();
-        assert(dataElement instanceof SOAPElement);
-        assert(SoapMessageProvider.RESPONSE_DATA_NAME.equals(dataElement.getLocalName()));
+        assertTrue(dataElement instanceof SOAPElement);
+        assertEquals(SoapMessageProvider.RESPONSE_DATA_NAME, dataElement.getLocalName());
         
         // TODO AXIS2 SAAJ should (but does not) support the getTextContent();
         // String text = dataElement.getTextContent();
@@ -456,7 +456,7 @@
     private int countAttachments(SOAPMessage msg) {
         Iterator it = msg.getAttachments();
         int count = 0;
-        assert(it != null);
+        assertTrue(it != null);
         while (it.hasNext()) {
             it.next();
             count++;

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java?view=diff&rev=529757&r1=529756&r2=529757
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/soapmsg/SoapMessageProvider.java Tue Apr 17 13:41:37 2007
@@ -139,7 +139,7 @@
             } else {
                 // We should not get here
                 TestLogger.logger.debug("Unknown Type of Message");
-                assert(false);
+                assertTrue(false);
             }
             
             // Write out the Message
@@ -163,21 +163,21 @@
      * @return SOAPElement representing the data element
      */
     private SOAPElement assertRequestXML(SOAPMessage msg) throws Exception {
-        assert(msg != null);
+        assertTrue(msg != null);
         SOAPBody body = msg.getSOAPBody();
-        assert(body != null);
+        assertTrue(body != null);
         
         Node invokeElement = (Node) body.getFirstChild();
-        assert(invokeElement instanceof SOAPElement);
-        assert(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
+        assertTrue(invokeElement instanceof SOAPElement);
+        assertTrue(SoapMessageProvider.REQUEST_NAME.equals(invokeElement.getLocalName()));
         
         Node discElement = (Node) invokeElement.getFirstChild();
-        assert(discElement instanceof SOAPElement);
-        assert(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
+        assertTrue(discElement instanceof SOAPElement);
+        assertTrue(SoapMessageProvider.REQUEST_DATA_NAME.equals(discElement.getLocalName()));
         
         String text = discElement.getValue();
-        assert(text != null);
-        assert(text.length() > 0);
+        assertTrue(text != null);
+        assertTrue(text.length() > 0);
         TestLogger.logger.debug("Request Message Type is:" + text);
         
         return (SOAPElement) discElement;
@@ -193,11 +193,11 @@
         SOAPMessage response;
         
         // Transport header check
-        assert(request.getContentDescription() != null);
-        assert(request.getContentDescription().equals(SoapMessageProvider.XML_REQUEST));
+        assertTrue(request.getContentDescription() != null);
+        assertTrue(request.getContentDescription().equals(SoapMessageProvider.XML_REQUEST));
 
         // Additional assertion checks
-        assert(countAttachments(request) == 0);
+        assertTrue(countAttachments(request) == 0);
         
         // Build the Response
         MessageFactory factory = MessageFactory.newInstance();
@@ -220,7 +220,7 @@
        
 
         // Additional assertion checks
-        assert(countAttachments(request) == 0);
+        assertTrue(countAttachments(request) == 0);
         
         // Build the Response
         MessageFactory factory = MessageFactory.newInstance();
@@ -239,11 +239,11 @@
         SOAPMessage response;
         
         // Additional assertion checks
-        assert(countAttachments(request) == 1);
+        assertTrue(countAttachments(request) == 1);
         AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
         StreamSource contentSS = (StreamSource) requestAP.getContent();
         String content = getAsString(contentSS);
-        assert(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+        assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
         
         // Build the Response
         MessageFactory factory = MessageFactory.newInstance();
@@ -269,11 +269,11 @@
 
         TestLogger.logger.debug("Received MTOM Message");
         // Additional assertion checks
-        assert(countAttachments(request) == 1);
+        assertTrue(countAttachments(request) == 1);
         AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
         StreamSource contentSS = (StreamSource) requestAP.getContent();
         String content = getAsString(contentSS);
-        assert(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+        assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
 
         TestLogger.logger.debug("The MTOM Request Message appears correct.");
         
@@ -301,12 +301,12 @@
         SOAPMessage response;
         
         // Additional assertion checks
-        assert(countAttachments(request) == 1);
+        assertTrue(countAttachments(request) == 1);
         AttachmentPart requestAP = (AttachmentPart) request.getAttachments().next();
-        assert(requestAP.getContentId().equals(ID));
+        assertTrue(requestAP.getContentId().equals(ID));
         StreamSource contentSS = (StreamSource) requestAP.getContent();
         String content = getAsString(contentSS);
-        assert(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
+        assertTrue(content.contains(SoapMessageProvider.TEXT_XML_ATTACHMENT));
         
         // Build the Response
         MessageFactory factory = MessageFactory.newInstance();
@@ -358,7 +358,7 @@
     private int countAttachments(SOAPMessage msg) {
         Iterator it = msg.getAttachments();
         int count = 0;
-        assert(it != null);
+        assertTrue(it != null);
         while (it.hasNext()) {
             it.next();
             count++;
@@ -374,5 +374,11 @@
         transformer.transform(ss, result); 
         String text = new String(out.toByteArray());
         return text;
+    }
+    
+    private void assertTrue(boolean testAssertion) {
+        if (!testAssertion) {
+            throw new RuntimeException("Assertion false");
+        }
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/GorillaDLWProxyTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/GorillaDLWProxyTests.java?view=diff&rev=529757&r1=529756&r2=529757
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/GorillaDLWProxyTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/GorillaDLWProxyTests.java Tue Apr 17 13:41:37 2007
@@ -89,7 +89,7 @@
            
             String response = proxy.echoString(request);
             assertTrue(response != null);
-            assert(response.equals(request));
+            assertEquals(response, request);
             
         }catch(Exception e){ 
             e.printStackTrace(); 

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java?view=diff&rev=529757&r1=529756&r2=529757
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java Tue Apr 17 13:41:37 2007
@@ -62,7 +62,7 @@
      * Echo the input
      */
     public String testSimple(String simpleIn) {
-        assert(simpleIn != null);  // According to JAX-WS an RPC service should never receive a null
+        assertTrue(simpleIn != null);  // According to JAX-WS an RPC service should never receive a null
         
         // Test to ensure that returning null causes the proper exception 
         if (simpleIn.contains("returnNull")) {



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