You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2008/04/03 03:36:09 UTC

svn commit: r644131 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/ jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ jaxws-integration/test/org/apache/axis2/jaxws/provider/ jaxws/src...

Author: scheu
Date: Wed Apr  2 18:36:08 2008
New Revision: 644131

URL: http://svn.apache.org/viewvc?rev=644131&view=rev
Log:
AXIS2-3271
Contributor:Rich Scheuerle
MTOMFeature(threshold) is not yet fully supported...see WSCOMMONS-313.
So I am changing the code in Axis2 to "tolerate" the setting and not disable MTOM.
Code and tests are added.

Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/MTOMConfigurator.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java Wed Apr  2 18:36:08 2008
@@ -126,16 +126,11 @@
         InvocationContext ic = testController.getInvocationContext();
         MessageContext request = ic.getRequestMessageContext();
         
-        assertFalse("MTOM should not be enabled.  The threshold was not exceeded.", request.getMessage().isMTOMEnabled());
-    }
-    
-    /*
-     * Test the configuration of the threshold for MTOM when an attachment is specified.
-     * In this case, MTOM should be enabled on the Message if the attachment specified is
-     * larger than the threshold.
-     */
-    public void testMTOMFeatureThresholdWithAttachment() {
-        
+        // A Threshold indicates that MTOM should be enabled.
+        // The decision about whether the attachment is inlined is made on a per attachment
+        // basis in Axiom...and cannot be tested in unit test that does not send the message
+        // to the server.
+        assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
     }
     
     /*

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java Wed Apr  2 18:36:08 2008
@@ -115,18 +115,13 @@
         InvocationContext ic = testController.getInvocationContext();
         MessageContext request = ic.getRequestMessageContext();
         
-        assertTrue("Request should not be null.", request != null);
-        assertTrue("MTOM should NOT be abled on the Message, the threshold was not met.", !request.getMessage().isMTOMEnabled());
-    }
-    
-    /*
-     * Test the configuration of the threshold for MTOM when an attachment is specified.
-     * In this case, MTOM should be enabled on the Message if the attachment specified is
-     * larger than the threshold.
-     */
-    public void testMTOMFeatureThresholdWithAttachment() {
-        
+        // A Threshold indicates that MTOM should be enabled.
+        // The decision about whether the attachment is inlined is made on a per attachment
+        // basis in Axiom...and cannot be tested in unit test that does not send the message
+        // to the server.
+        assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
     }
+
     
     @WebService()
     public interface ProxyMTOMService {

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java Wed Apr  2 18:36:08 2008
@@ -245,4 +245,43 @@
 
         assertTrue(response != null);
     }
+    
+    /**
+     * This test dispatches to the SOAPMessage CheckMTOM endpoint
+     * which verifies that an attachment was sent (versus inline)
+     * @throws Exception
+     */
+    public void testMTOMAttachmentImageProvider_MTOMFeatureThreshhold() throws Exception {
+        TestLogger.logger.debug("---------------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        //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);
+        
+        Service svc = Service.create(PROVIDER_SERVICE_NAME);
+        svc.addPort(portName, null, PROVIDER_ENDPOINT_URL);
+        
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        // Make sure MTOMFeature with a small threshhold (1) works correctly
+        // by sending an optimized MTOM message.
+        MTOMFeature mtom = new MTOMFeature(1);
+        
+        Dispatch<Object> dispatch = svc
+                .createDispatch(portName, jbc, Service.Mode.PAYLOAD, mtom);
+        
+        //Create a request bean with imagedepot bean as value
+        ObjectFactory factory = new ObjectFactory();
+        SendImage request = factory.createSendImage();
+        request.setInput(imageDepot);
+        
+        // The provider service returns the same image back if successful
+        SendImage response = (SendImage) dispatch.invoke(request);
+
+        assertTrue(response != null);
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/MTOMConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/MTOMConfigurator.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/MTOMConfigurator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/MTOMConfigurator.java Wed Apr  2 18:36:08 2008
@@ -65,14 +65,19 @@
             int threshold = mtomFeature.getThreshold();
             List<String> attachmentIDs = requestMsg.getAttachmentIDs();
             
-            // If a threshold wasn't configured, enable MTOM for all cases.
+            // Enable MTOM
+            requestMsg.setMTOMEnabled(true);
+            
+            
             if (threshold <= 0) {
                 if (log.isDebugEnabled()) {
                     log.debug("Enabling MTOM with no threshold.");
-                }
-                requestMsg.setMTOMEnabled(true);
+                }             
             }
             else if (attachmentIDs != null) {
+                // REVIEW This processing will be moved to axiom.
+                // DISABLING FOR NOW
+                /*
             	long size = 0L;
             	
             	for (String attachmentID : attachmentIDs) {
@@ -102,8 +107,10 @@
             	    }
             	}
             	
-            	if (size > threshold)
+            	if (size > threshold) {
             	    requestMsg.setMTOMEnabled(true);
+                }
+                */
             }
         }
         else {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/dispatch/DispatchMTOMFeatureTest.java Wed Apr  2 18:36:08 2008
@@ -126,16 +126,11 @@
         InvocationContext ic = testController.getInvocationContext();
         MessageContext request = ic.getRequestMessageContext();
         
-        assertFalse("MTOM should not be enabled.  The threshold was not exceeded.", request.getMessage().isMTOMEnabled());
-    }
-    
-    /*
-     * Test the configuration of the threshold for MTOM when an attachment is specified.
-     * In this case, MTOM should be enabled on the Message if the attachment specified is
-     * larger than the threshold.
-     */
-    public void testMTOMFeatureThresholdWithAttachment() {
-        
+        // A Threshold indicates that MTOM should be enabled.
+        // The decision about whether the attachment is inlined is made on a per attachment
+        // basis in Axiom...and cannot be tested in unit test that does not send the message
+        // to the server.
+        assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
     }
     
     /*

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java?rev=644131&r1=644130&r2=644131&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyMTOMFeatureTest.java Wed Apr  2 18:36:08 2008
@@ -116,16 +116,11 @@
         MessageContext request = ic.getRequestMessageContext();
         
         assertTrue("Request should not be null.", request != null);
-        assertTrue("MTOM should NOT be abled on the Message, the threshold was not met.", !request.getMessage().isMTOMEnabled());
-    }
-    
-    /*
-     * Test the configuration of the threshold for MTOM when an attachment is specified.
-     * In this case, MTOM should be enabled on the Message if the attachment specified is
-     * larger than the threshold.
-     */
-    public void testMTOMFeatureThresholdWithAttachment() {
-        
+        // A Threshold indicates that MTOM should be enabled.
+        // The decision about whether the attachment is inlined is made on a per attachment
+        // basis in Axiom...and cannot be tested in unit test that does not send the message
+        // to the server.
+        assertTrue("MTOM should be enabled.", request.getMessage().isMTOMEnabled());
     }
     
     @WebService()



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