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 sc...@apache.org on 2008/03/26 21:55:09 UTC
svn commit: r641569 - in
/webservices/axis2/trunk/java/modules/jaxws-integration: ./
test/org/apache/axis2/jaxws/provider/
test/org/apache/axis2/jaxws/provider/jaxb/
test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/
test/org/apache/axis2/jaxws/pro...
Author: scheu
Date: Wed Mar 26 13:55:04 2008
New Revision: 641569
URL: http://svn.apache.org/viewvc?rev=641569&view=rev
Log:
Adding MTOMFeature tests to the JAX-WS Integration module.
There is no code change associated with this commit.
Added:
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/MANIFEST.MF
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/SoapMessageCheckMTOMProvider.java
Modified:
webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/JAXBProviderTests.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/jaxb/JAXBProvider.java
webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java
Modified: webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml?rev=641569&r1=641568&r2=641569&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/pom.xml Wed Mar 26 13:55:04 2008
@@ -556,6 +556,22 @@
/>
<delete dir="target/test-classes/servicejars/SoapMessageProviderService"/>
+ <copy toDir="target/test-classes/servicejars/SoapMessageCheckMTOMProviderService/">
+ <fileset dir="target/test-classes">
+ <include name="org/apache/axis2/jaxws/provider/soapmsgcheckmtom/**"/>
+ <exclude name="org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/services.xml"/>
+ </fileset>
+ <fileset dir="test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom">
+ <include name="META-INF/**"/>
+ <exclude name="META-INF/services.xml"/>
+ </fileset>
+ </copy>
+
+ <zip destfile="target/test-classes/servicejars/SoapMessageCheckMTOMProviderService.jar"
+ basedir="${pom.basedir}/target/test-classes/servicejars/SoapMessageCheckMTOMProviderService"
+ />
+ <delete dir="target/test-classes/servicejars/SoapMessageCheckMTOMProviderService"/>
+
<copy toDir="target/test-classes/servicejars/SoapMessageMUProviderService/">
<fileset dir="target/test-classes">
<include name="org/apache/axis2/jaxws/provider/soapmsgmu/**"/>
@@ -1207,7 +1223,6 @@
<!-- Enable the next 2 lines if you want to attach a debugger
<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006</argLine>-->
<includes>
-
<include>**/MultiRedirectionCatalogTest.java</include>
<include>**/DispatchSoapActionTest.java</include>
<include>**/ProxySoapActionTest.java</include>
@@ -1222,7 +1237,7 @@
<include>**/SourceProviderTests.java</include>
<include>**/SourceMessageProviderTests.java</include>
<include>**/SoapMessageMUProviderTests.java</include>
- <include>**/JAXBProviderTests.java</include>
+
<include>**/ProxyTests.java</include>
<include>**/ProxyNonWrappedTests.java</include>
<include>**/RPCProxyTests.java</include>
@@ -1233,6 +1248,7 @@
<include>**/BasicAuthSecurityTests.java</include>
<include>**/AddressBookTests.java</include>
<include>**/MtomSampleTests.java</include>
+ <include>**/JAXBProviderTests.java</include>
<include>**/BareTests.java</include>
<include>**/AddNumbersHandlerTests.java</include>
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=641569&r1=641568&r2=641569&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 Mar 26 13:55:04 2008
@@ -37,6 +37,9 @@
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
+import javax.xml.ws.soap.MTOMFeature;
+import javax.xml.ws.soap.SOAPBinding;
+
import java.awt.*;
import java.io.File;
@@ -65,6 +68,10 @@
String endpointUrl = "http://localhost:6060/axis2/services/JAXBProviderService.JAXBProviderPort";
private QName serviceName = new QName("http://ws.apache.org/axis2", "JAXBProviderService");
+
+ String PROVIDER_ENDPOINT_URL = "http://localhost:6060/axis2/services/SoapMessageCheckMTOMProviderService.SoapMessageCheckMTOMProviderPort";
+ private QName PROVIDER_SERVICE_NAME = new QName("http://soapmsgcheckmtom.provider.jaxws.axis2.apache.org", "SoapMessageCheckMTOMProviderService");
+
DataSource stringDS, imageDS;
public JAXBProviderTests() {
@@ -146,6 +153,10 @@
Dispatch<Object> dispatch = svc
.createDispatch(portName, jbc, Service.Mode.PAYLOAD);
+ // Enable attachment optimization
+ SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+ binding.setMTOMEnabled(true);
+
//Create a request bean with imagedepot bean as value
ObjectFactory factory = new ObjectFactory();
SendImage request = factory.createSendImage();
@@ -156,5 +167,82 @@
SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
TestLogger.logger.debug(">> Response [" + response.toString() + "]");
+ }
+
+ /**
+ * This test dispatches to the SOAPMessage CheckMTOM endpoint
+ * which verifies that an attachment was sent (versus inline)
+ * @throws Exception
+ */
+ public void testMTOMAttachmentImageProvider_API() 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");
+
+
+ Dispatch<Object> dispatch = svc
+ .createDispatch(portName, jbc, Service.Mode.PAYLOAD);
+
+ // Enable attachment optimization
+ SOAPBinding binding = (SOAPBinding) dispatch.getBinding();
+ binding.setMTOMEnabled(true);
+
+ //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);
+ }
+
+ /**
+ * This test dispatches to the SOAPMessage CheckMTOM endpoint
+ * which verifies that an attachment was sent (versus inline)
+ * @throws Exception
+ */
+ public void testMTOMAttachmentImageProvider_MTOMFeature() 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");
+
+ MTOMFeature mtom = new MTOMFeature();
+
+ 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-integration/test/org/apache/axis2/jaxws/provider/jaxb/JAXBProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/jaxb/JAXBProvider.java?rev=641569&r1=641568&r2=641569&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/jaxb/JAXBProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/jaxb/JAXBProvider.java Wed Mar 26 13:55:04 2008
@@ -51,6 +51,7 @@
* @return
*/
public Source invoke(Source obj) {
+ System.out.println(">> JAXB Provider Service: Request received.");
TestLogger.logger.debug(">> JAXB Provider Service: Request received.\n");
SendImage siRequest = null;
SendImageResponse siResponse = null;
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/MANIFEST.MF?rev=641569&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/MANIFEST.MF (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/META-INF/MANIFEST.MF Wed Mar 26 13:55:04 2008
@@ -0,0 +1 @@
+Manifest-Version: 1.0
Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/SoapMessageCheckMTOMProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/SoapMessageCheckMTOMProvider.java?rev=641569&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/SoapMessageCheckMTOMProvider.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/provider/soapmsgcheckmtom/SoapMessageCheckMTOMProvider.java Wed Mar 26 13:55:04 2008
@@ -0,0 +1,112 @@
+/*
+ * 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.provider.soapmsgcheckmtom;
+
+import org.apache.axis2.jaxws.TestLogger;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.Detail;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.Provider;
+import javax.xml.ws.Service;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+
+@WebServiceProvider(serviceName="SoapMessageCheckMTOMProviderService",
+ targetNamespace="http://soapmsgcheckmtom.provider.jaxws.axis2.apache.org",
+ portName="SoapMessageCheckMTOMProviderPort")
+@BindingType(SOAPBinding.SOAP11HTTP_BINDING)
+@ServiceMode(value=Service.Mode.MESSAGE)
+public class SoapMessageCheckMTOMProvider implements Provider<SOAPMessage> {
+
+
+ /**
+ * Very simple operation.
+ * If there are no attachments, an exception is thrown.
+ * Otherwise the message is echoed.
+ */
+ public SOAPMessage invoke(SOAPMessage soapMessage) {
+ System.out.println(">> SoapMessageCheckMTOMProvider: Request received.");
+
+
+ int numAttachments = soapMessage.countAttachments();
+ if (numAttachments == 0) {
+ System.out.println(">> SoapMessageCheckMTOMProvider: No Attachments.");
+ throw new WebServiceException("No Attachments are detected");
+ }
+ SOAPMessage response = null;
+ try {
+ MessageFactory factory = MessageFactory.newInstance();
+ response = factory.createMessage();
+ SOAPPart soapPart = response.getSOAPPart();
+ SOAPBody soapBody = soapPart.getEnvelope().getBody();
+ soapBody.addChildElement((SOAPBodyElement)
+ soapMessage.
+ getSOAPBody().getChildElements().next());
+ response.addAttachmentPart((AttachmentPart) soapMessage.getAttachments().next());
+ } catch (SOAPException e) {
+ throw new WebServiceException(e);
+ }
+ System.out.println(">> SoapMessageCheckMTOMProvider: Returning.");
+ return response; // echo back the same message
+ }
+
+ /**
+ * Count Attachments
+ * @param msg
+ * @return
+ */
+ private int countAttachments(SOAPMessage msg) {
+ Iterator it = msg.getAttachments();
+ int count = 0;
+ if (it == null ) {
+ return 0;
+ }
+ while (it.hasNext()) {
+ it.next();
+ count++;
+ }
+ return count;
+ }
+}
Modified: 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=641569&r1=641568&r2=641569&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java Wed Mar 26 13:55:04 2008
@@ -42,6 +42,7 @@
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;
+import javax.xml.ws.soap.MTOMFeature;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.soap.SOAPFaultException;
@@ -107,6 +108,48 @@
}
/*
+ * Enable attachment Optimization through the MTOMFeature
+ * Using SOAP11
+ */
+ public void testSendImageFeature11() 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");
+
+ MTOMFeature mtom21 = new MTOMFeature();
+
+ // 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, mtom21);
+
+
+ SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
+
+ assertNotNull(response);
+ assertNotNull(response.getOutput().getImageData());
+ }
+ /*
* Enable attachment optimization using the SOAP11 binding
* property for MTOM.
*/
@@ -247,8 +290,9 @@
fault != null);
QName faultCode = sfe.getFault().getFaultCodeAsQName();
- assertTrue("Expected VERSION MISMATCH but received: "+ faultCode,
- new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "VersionMismatch", SOAPConstants.SOAP_ENV_PREFIX).equals(faultCode));
+
+ assertTrue("Expected VERSION MISMATCH but received: "+ faultCode,
+ new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "VersionMismatch", SOAPConstants.SOAP_ENV_PREFIX).equals(faultCode));
}
}
@@ -317,6 +361,7 @@
assertTrue("SOAPFault is null ",
fault != null);
QName faultCode = sfe.getFault().getFaultCodeAsQName();
+
assertTrue("Expected VERSION MISMATCH but received: "+ faultCode,
new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "VersionMismatch", SOAPConstants.SOAP_ENV_PREFIX).equals(faultCode));
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org