You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/07/29 07:15:43 UTC
svn commit: r980310 - in /servicemix/smx4/features/trunk/examples/itests: ./
cxf-mtom-osgi/ cxf-mtom-osgi/src/ cxf-mtom-osgi/src/main/
cxf-mtom-osgi/src/main/java/ cxf-mtom-osgi/src/main/java/org/
cxf-mtom-osgi/src/main/java/org/apache/ cxf-mtom-osgi/s...
Author: ffang
Date: Thu Jul 29 05:15:42 2010
New Revision: 980310
URL: http://svn.apache.org/viewvc?rev=980310&view=rev
Log:
[SMX4-568] add cxf mtom test
Added:
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/pom.xml
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/TestMtomImpl.java
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml (with props)
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/
servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/mtom.wsdl
Modified:
servicemix/smx4/features/trunk/examples/itests/pom.xml
servicemix/smx4/features/trunk/examples/itests/tests/pom.xml
servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
Added: servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/pom.xml?rev=980310&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/pom.xml (added)
+++ servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/pom.xml Thu Jul 29 05:15:42 2010
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>org.apache.servicemix.examples.itests</artifactId>
+ <version>4.3.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>org.apache.servicemix.examples.itests.cxf-mtom-osgi</artifactId>
+ <packaging>bundle</packaging>
+ <version>4.3.0-SNAPSHOT</version>
+ <name>Apache ServiceMix Example ITESTS BUNDLE:: CXF MTOM OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${cxf.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+ <version>${geronimo.wsmetadata.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>${cxf.version}</version>
+ <executions>
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>${basedir}/src/main/resources/wsdl/mtom.wsdl</wsdl>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Import-Package>
+ javax.jws,
+ javax.wsdl,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.namespace,
+ javax.xml.soap,
+ javax.xml.transform,
+ javax.xml.ws,
+ javax.activation,
+ javax.jws.soap,
+ javax.mail.util,
+ META-INF.cxf,
+ META-INF.cxf.osgi,
+ org.apache.cxf.feature,
+ org.apache.cxf.bus,
+ org.apache.cxf.bus.spring,
+ org.apache.cxf.bus.resource,
+ org.apache.cxf.configuration.spring,
+ org.apache.cxf.resource,
+ org.apache.cxf.transport.http_osgi,
+ org.springframework.beans.factory.config
+ </Import-Package>
+ <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
+ <Export-Package>org.apache.cxf.mime, org.apache.cxf.mime.types, org.apache.servicemix.examples.cxf.mtom</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/TestMtomImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/TestMtomImpl.java?rev=980310&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/TestMtomImpl.java (added)
+++ servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/java/org/apache/servicemix/examples/cxf/mtom/TestMtomImpl.java Thu Jul 29 05:15:42 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.servicemix.examples.cxf.mtom;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataHandler;
+import javax.jws.WebService;
+import javax.mail.util.ByteArrayDataSource;
+import javax.xml.ws.Holder;
+
+import org.apache.cxf.mime.TestMtom;
+
+@WebService(serviceName = "TestMtomService",
+ portName = "TestMtomPort",
+ targetNamespace = "http://cxf.apache.org/mime",
+ endpointInterface = "org.apache.cxf.mime.TestMtom",
+ wsdlLocation = "testutils/mtom_xop.wsdl")
+public class TestMtomImpl implements TestMtom {
+ public void testXop(Holder<String> name, Holder<DataHandler> attachinfo) {
+ try {
+ System.out.println("Received image with mtom enabled from client");
+ InputStream mtomIn = attachinfo.value.getInputStream();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(mtomIn, out);
+ System.out.println("The image data size is " + out.size());
+ name.value = "Hello " + name.value;
+ mtomIn.close();
+ attachinfo.value = new DataHandler(new ByteArrayDataSource(out.toByteArray(),
+ attachinfo.value.getContentType()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static int copy(final InputStream input, final OutputStream output) throws IOException {
+ final byte[] buffer = new byte[4096];
+ int n = 0;
+ n = input.read(buffer);
+ int total = 0;
+ while (-1 != n) {
+ output.write(buffer, 0, n);
+ total += n;
+ n = input.read(buffer);
+ }
+ return total;
+ }
+}
Added: servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml?rev=980310&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml (added)
+++ servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml Thu Jul 29 05:15:42 2010
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!-- START SNIPPET: beans -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+ <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
+
+ <jaxws:endpoint id="MtomEndpoint"
+ implementor="org.apache.servicemix.examples.cxf.mtom.TestMtomImpl"
+ address="/mtom"
+ wsdlLocation="wsdl/mtom.wsdl"
+ endpointName="e:TestMtomPort"
+ serviceName="s:TestMtomService"
+ xmlns:e="http://cxf.apache.org/mime"
+ xmlns:s="http://cxf.apache.org/mime">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:properties>
+ <entry key="mtom-enabled" value="true"/>
+ </jaxws:properties>
+ </jaxws:endpoint>
+
+
+ <jaxws:client id="client"
+ serviceClass="org.apache.cxf.mime.TestMtom"
+ endpointName="e:TestMtomPort"
+ serviceName="s:TestMtomService"
+ xmlns:e="http://cxf.apache.org/mime"
+ xmlns:s="http://cxf.apache.org/mime"
+ wsdlLocation="wsdl/mtom.wsdl"
+ address="http://localhost:8080/cxf/mtom">
+ <jaxws:features>
+ <bean class="org.apache.cxf.feature.LoggingFeature"/>
+ </jaxws:features>
+ <jaxws:properties>
+ <entry key="mtom-enabled" value="true"/>
+ </jaxws:properties>
+ </jaxws:client>
+
+ <osgi:service id="testMtom" ref="client"
+ interface="org.apache.cxf.mime.TestMtom"/>
+
+
+</beans>
+<!-- END SNIPPET: beans -->
Propchange: servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/META-INF/spring/beans.xml
------------------------------------------------------------------------------
svn:executable = *
Added: servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/mtom.wsdl
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/mtom.wsdl?rev=980310&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/mtom.wsdl (added)
+++ servicemix/smx4/features/trunk/examples/itests/cxf-mtom-osgi/src/main/resources/wsdl/mtom.wsdl Thu Jul 29 05:15:42 2010
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions name="SOAPBuilders-mime-cr-test" xmlns:types="http://cxf.apache.org/mime/types"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://cxf.apache.org/mime"
+ xmlns:jms="http://cxf.apache.org/transports/jms"
+ xmlns:xmime="http://www.w3.org/2005/05/xmlmime" targetNamespace="http://cxf.apache.org/mime">
+
+ <wsdl:types>
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://cxf.apache.org/mime/types"
+ xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified">
+ <complexType name="XopType">
+ <sequence>
+ <element name="name" type="xsd:string" />
+ <element name="attachinfo" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"/>
+ </sequence>
+ </complexType>
+ <element name="testXop" type="types:XopType" />
+ <element name="testXopResponse" type="types:XopType" />
+ </schema>
+
+ </wsdl:types>
+
+ <wsdl:message name="testXopIn">
+ <wsdl:part name="data" element="types:testXop" />
+ </wsdl:message>
+
+ <wsdl:message name="testXopOut">
+ <wsdl:part name="data" element="types:testXopResponse" />
+ </wsdl:message>
+
+
+ <wsdl:portType name="TestMtom">
+
+ <wsdl:operation name="testXop">
+ <wsdl:input message="tns:testXopIn" />
+ <wsdl:output message="tns:testXopOut" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="TestMtomBinding" type="tns:TestMtom">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+ <wsdl:operation name="testXop">
+ <soap:operation soapAction="" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+
+
+ </wsdl:binding>
+
+ <wsdl:service name="TestMtomService">
+ <wsdl:port name="TestMtomPort" binding="tns:TestMtomBinding">
+ <soap:address location="http://localhost:9036/mime-test" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
Modified: servicemix/smx4/features/trunk/examples/itests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/pom.xml?rev=980310&r1=980309&r2=980310&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/itests/pom.xml Thu Jul 29 05:15:42 2010
@@ -38,6 +38,7 @@
<module>cxf-nmr-osgi</module>
<module>cxf-soap-handler-osgi</module>
<module>cxf-handler-cfg</module>
+ <module>cxf-mtom-osgi</module>
<module>tests</module>
</modules>
Modified: servicemix/smx4/features/trunk/examples/itests/tests/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/tests/pom.xml?rev=980310&r1=980309&r2=980310&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/tests/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/itests/tests/pom.xml Thu Jul 29 05:15:42 2010
@@ -237,6 +237,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.servicemix.examples</groupId>
+ <artifactId>org.apache.servicemix.examples.itests.cxf-mtom-osgi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.servicemix.examples</groupId>
<artifactId>org.apache.servicemix.examples.itests.cxf-soap-handler-osgi</artifactId>
<version>${project.version}</version>
Modified: servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java?rev=980310&r1=980309&r2=980310&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java (original)
+++ servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java Thu Jul 29 05:15:42 2010
@@ -22,6 +22,7 @@ import java.io.InputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.io.OutputStream;
+import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.jar.Manifest;
@@ -29,9 +30,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.List;
-
+import javax.activation.DataHandler;
import javax.xml.transform.Source;
-
+import javax.xml.ws.Holder;
import org.apache.cxf.Bus;
import org.apache.servicemix.examples.cxf.HelloWorld;
import org.apache.servicemix.jbi.jaxp.StringSource;
@@ -155,6 +156,7 @@ public class IntegrationTest extends Abs
getBundle("org.apache.servicemix.examples", "org.apache.servicemix.examples.itests.cxf-ws-security-osgi"),
getBundle("org.apache.servicemix.examples", "org.apache.servicemix.examples.itests.cxf-jms-osgi"),
getBundle("org.apache.servicemix.examples", "org.apache.servicemix.examples.itests.cxf-soap-handler-osgi"),
+ getBundle("org.apache.servicemix.examples", "org.apache.servicemix.examples.itests.cxf-mtom-osgi"),
getBundle("org.apache.servicemix.examples", "org.apache.servicemix.examples.itests.cxf-handler-cfg"),
getBundle("org.apache.servicemix.examples", "cxf-ws-addressing"),
getBundle("org.apache.servicemix.examples", "cxf-jaxrs"),
@@ -227,6 +229,9 @@ public class IntegrationTest extends Abs
mf.getMainAttributes().putValue(Constants.EXPORT_PACKAGE,
exportP + ",org.apache.handlers, "
+ "org.apache.springcfg.handlers, "
+ + "org.apache.cxf.mime, "
+ + "javax.xml.ws, "
+ + "javax.activation, "
+ "org.apache.handlers.types, "
+ "org.apache.servicemix.examples.cxf,"
+ "org.apache.servicemix.examples.cxf.soaphandler,"
@@ -349,4 +354,44 @@ public class IntegrationTest extends Abs
assertTrue(baos.toString().indexOf("Hello John Doe") >= 0);
}
+
+ public void testMtomOsgi() throws Exception {
+ Thread.sleep(5000);
+ waitOnContextCreation("org.apache.servicemix.examples.itests.cxf-mtom-osgi");
+ Thread.sleep(5000);
+
+ ServiceReference ref = bundleContext.getServiceReference(org.apache.cxf.mime.TestMtom.class.getName());
+ assertNotNull("Service Reference is null", ref);
+
+ org.apache.cxf.mime.TestMtom testMtom = null;
+
+ testMtom = (org.apache.cxf.mime.TestMtom) bundleContext.getService(ref);
+ assertNotNull("Cannot find the service", testMtom);
+
+ URL fileURL = getClass().getClassLoader().getResource("me.bmp");
+ System.out.println("\nStarting MTOM test with DataHandler:");
+ Holder<String> name = new Holder<String>("Bob");
+ Holder<DataHandler> handler = new Holder<DataHandler>();
+
+ handler.value = new DataHandler(fileURL);
+
+ System.out.println("--Sending the me.bmp image to server");
+ System.out.println("--Sending a name value of " + name.value);
+
+ testMtom.testXop(name, handler);
+
+ InputStream mtomIn = handler.value.getInputStream();
+ long fileSize = 0;
+ for (int i = mtomIn.read(); i != -1; i = mtomIn.read()) {
+ fileSize++;
+ }
+
+ System.out.println("--Received DataHandler back from server, "
+ + "returned size is " + fileSize);
+ System.out.println("--Returned string value is " + name.value);
+ assertEquals(fileSize, 163166);
+ System.out.println("Successfully ran MTOM/DataHandler demo");
+
+ }
+
}