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 th...@apache.org on 2005/07/20 14:13:43 UTC
svn commit: r219885 - in /webservices/axis/trunk/java/modules/samples: ./
src/sample/mtom/ src/sample/mtom/client/ test/org/apache/axis2/mtom/
Author: thilina
Date: Wed Jul 20 05:13:42 2005
New Revision: 219885
URL: http://svn.apache.org/viewcvs?rev=219885&view=rev
Log:
Fixing the test cases for the changes in MIME processing + Fixed test cases to contain assertEquals
Modified:
webservices/axis/trunk/java/modules/samples/project.xml
webservices/axis/trunk/java/modules/samples/src/sample/mtom/MTOMService.java
webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/MTOMClientModel.java
webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/UserInterface.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java
Modified: webservices/axis/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/project.xml?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis/trunk/java/modules/samples/project.xml Wed Jul 20 05:13:42 2005
@@ -1,221 +1,221 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
- -->
-<project>
- <pomVersion>3</pomVersion>
- <extend>../../etc/project.xml</extend>
-
- <id>axis2-Samples</id>
- <name>samples</name>
- <description>Set of samples available for Axis 2.0.</description>
-
-
- <dependencies>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis2-core</artifactId>
- <version>${pom.currentVersion}</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis2-xml</artifactId>
- <version>${pom.currentVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis2-wsdl</artifactId>
- <version>${pom.currentVersion}</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>addressing</artifactId>
- <version>${pom.currentVersion}</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis2-tools</artifactId>
- <version>${pom.currentVersion}</version>
- </dependency>
-
- <!-- external JARs -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.3</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
- <dependency>
- <groupId>stax</groupId>
- <artifactId>stax</artifactId>
- <version>1.1.1-dev</version>
- <properties>
- <module>true</module>
- </properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
- </dependency>
-
- <dependency>
- <groupId>groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <version>1.0-jsr-01</version>
- <properties>
- <module>true</module>
- </properties>
- <url>http://dist.codehaus.org/groovy/jars/</url>
- </dependency>
-
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.0-rc2</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
-
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.8</version>
- <properties>
- <module>true</module>
- </properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
- </dependency>
-
- <dependency>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- <version>1.0</version>
- <properties>
- <module>true</module>
- </properties>
- <url>http://dist.codehaus.org/stax/jars/</url>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-wsdl4j</artifactId>
- <version>1.2</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
- <dependency>
- <groupId>geronimo-spec</groupId>
- <artifactId>geronimo-spec-javamail</artifactId>
- <version>1.3.1-SNAPSHOT</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
- <dependency>
- <groupId>geronimo-spec</groupId>
- <artifactId>geronimo-spec-activation</artifactId>
- <version>1.0.2-SNAPSHOT</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
- <dependency>
- <groupId>xmlbeans</groupId>
- <artifactId>xbean</artifactId>
- <version>2.0.0-beta1</version>
- <type>jar</type>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
-
- </dependencies>
-
- <!-- build information for the project -->
- <build>
- <nagEmailAddress>axis-dev@ws.apache.org</nagEmailAddress>
- <sourceDirectory>src</sourceDirectory>
- <unitTestSourceDirectory>test</unitTestSourceDirectory>
-
- <unitTest>
-
- <excludes>
- <exclude>**/*Abstract*.java</exclude>
- <exclude>**/*Util*.java</exclude>
- <exclude>**/*InteropStubTest.java</exclude>
- <exclude>**/*EchoRawXMLChunckedTest.java</exclude>
- <exclude>**org/apache/axis2/mail/*.java</exclude>
- <exclude>**org/apache/axis2/mtom/*.java</exclude>
- <!-- <exclude>**/*MailEchoRawXMLTest.java</exclude>
- <exclude>**/*MailOneWayRawXMLTest.java</exclude>
- <exclude>**/*MailRequestResponseRawXMLTest.java</exclude>
- <exclude>**/*CommonsHTTPEchoRawXMLTest.java</exclude>
- <exclude>**/*EchoRawMTOMTest.java</exclude>
- <exclude>**/*EchoRawMTOMLoadTest.java</exclude>
- <exclude>**/*EchoRawMTOMToBase64Test.java</exclude> -->
- </excludes>
- <includes>
- <include>**/*Test.java</include>
- </includes>
-
- <resources>
- <resource>
- <directory>${basedir}/test-resources</directory>
- </resource>
- <resource>
- <directory>conf</directory>
- <includes>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </resources>
- </unitTest>
-
- <resources>
- <resource>
- <directory>conf</directory>
- <includes>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- </resource>
- <resource>
- <directory>test</directory>
- <includes>
- <include>**/*.jpg</include>
- </includes>
- </resource>
- </resources>
- </build>
-
- <reports/>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ -->
+<project>
+ <pomVersion>3</pomVersion>
+ <extend>../../etc/project.xml</extend>
+
+ <id>axis2-Samples</id>
+ <name>samples</name>
+ <description>Set of samples available for Axis 2.0.</description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis2-core</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis2-xml</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis2-wsdl</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>addressing</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis2-tools</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+
+ <!-- external JARs -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.3</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax</artifactId>
+ <version>1.1.1-dev</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/stax/jars/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.0-jsr-01</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/groovy/jars/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0-rc2</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.8</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/stax/jars/</url>
+ </dependency>
+
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ <url>http://dist.codehaus.org/stax/jars/</url>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-wsdl4j</artifactId>
+ <version>1.2</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-javamail</artifactId>
+ <version>1.3.1-SNAPSHOT</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-activation</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>xmlbeans</groupId>
+ <artifactId>xbean</artifactId>
+ <version>2.0.0-beta1</version>
+ <type>jar</type>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
+ </dependencies>
+
+ <!-- build information for the project -->
+ <build>
+ <nagEmailAddress>axis-dev@ws.apache.org</nagEmailAddress>
+ <sourceDirectory>src</sourceDirectory>
+ <unitTestSourceDirectory>test</unitTestSourceDirectory>
+
+ <unitTest>
+
+ <excludes>
+ <exclude>**/*Abstract*.java</exclude>
+ <exclude>**/*Util*.java</exclude>
+ <exclude>**/*InteropStubTest.java</exclude>
+ <exclude>**/*EchoRawXMLChunckedTest.java</exclude>
+ <exclude>**org/apache/axis2/mail/*.java</exclude>
+
+ <!-- <exclude>**/*MailEchoRawXMLTest.java</exclude>
+ <exclude>**/*MailOneWayRawXMLTest.java</exclude>
+ <exclude>**/*MailRequestResponseRawXMLTest.java</exclude>
+ <exclude>**/*CommonsHTTPEchoRawXMLTest.java</exclude>
+ <exclude>**/*EchoRawMTOMTest.java</exclude>
+ <exclude>**/*EchoRawMTOMLoadTest.java</exclude>
+ <exclude>**/*EchoRawMTOMToBase64Test.java</exclude> -->
+ </excludes>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+
+ <resources>
+ <resource>
+ <directory>${basedir}/test-resources</directory>
+ </resource>
+ <resource>
+ <directory>conf</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </unitTest>
+
+ <resources>
+ <resource>
+ <directory>conf</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>test</directory>
+ <includes>
+ <include>**/*.jpg</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+ <reports/>
+
+</project>
Modified: webservices/axis/trunk/java/modules/samples/src/sample/mtom/MTOMService.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/MTOMService.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/mtom/MTOMService.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/mtom/MTOMService.java Wed Jul 20 05:13:42 2005
@@ -31,6 +31,8 @@
*/
public class MTOMService {
public OMElement mtomSample(OMElement element) throws Exception {
+
+ System.out.println("Entered");
OMElement imageEle = element.getFirstElement();
System.out.println(imageEle.getLocalName());
OMElement imageName = (OMElement) imageEle.getNextSibling();
@@ -40,16 +42,19 @@
//Extracting the data and saving
DataHandler actualDH;
actualDH = binaryNode.getDataHandler();
+ System.out.println("got DH");
Image actualObject = new JDK13IO().loadImage(actualDH.getDataSource()
.getInputStream());
+ System.out.println("image created");
FileOutputStream imageOutStream = new FileOutputStream(fileName);
new JDK13IO().saveImage("image/jpeg", actualObject, imageOutStream);
-
+ System.out.println("saved"+fileName);
//setting response
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace("urn://fakenamespace", "ns");
OMElement ele = fac.createOMElement("response", ns);
ele.setText("Image Saved");
+ System.out.println("Exited");
return ele;
}
}
Modified: webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/MTOMClientModel.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/MTOMClientModel.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/MTOMClientModel.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/MTOMClientModel.java Wed Jul 20 05:13:42 2005
@@ -85,7 +85,7 @@
call.setTo(targetEPR);
// enabling MTOM in the client side
call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP,
Constants.TRANSPORT_HTTP, false);
OMElement result = (OMElement) call.invokeBlocking(operationName
.getLocalPart(),
Modified: webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/UserInterface.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/UserInterface.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/UserInterface.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/sample/mtom/client/UserInterface.java Wed Jul 20 05:13:42 2005
@@ -149,6 +149,7 @@
mtomTest.setTargetEPR(EPRName);
OMElement result = (OMElement) mtomTest.testEchoXMLSync(fileName);
jTextArea.setText(result.toString());
+ jTextArea.append("\n"+result.getText());
JOptionPane.showMessageDialog(parent, "Sent & saved Image Succesfully",
" Success", JOptionPane.PLAIN_MESSAGE);
} catch (Exception e) {
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMCommonsChunkingTest.java Wed Jul 20 05:13:42 2005
@@ -20,7 +20,6 @@
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
import java.awt.Image;
-import java.io.FileOutputStream;
import java.io.InputStream;
import javax.activation.DataHandler;
@@ -51,114 +50,111 @@
import org.apache.commons.logging.LogFactory;
public class EchoRawMTOMCommonsChunkingTest extends TestCase {
- private EndpointReference targetEPR = new EndpointReference(
- AddressingConstants.WSA_TO, "http://127.0.0.1:"
- + (UtilServer.TESTING_PORT+1)
- + "/axis/services/EchoXMLService/echoOMElement");
-
- private Log log = LogFactory.getLog(getClass());
-
- private QName serviceName = new QName("EchoXMLService");
-
- private QName operationName = new QName("echoOMElement");
-
- private QName transportName = new QName("http://localhost/my",
- "NullTransport");
-
- private String imageInFileName = "img/test.jpg";
-
- private String imageOutFileName = "mtom/img/testOut.jpg";
-
- private AxisConfiguration engineRegistry;
-
- private MessageContext mc;
-
- private ServiceContext serviceContext;
-
- private ServiceDescription service;
-
- private OMElement data;
-
- private boolean finish = false;
-
- public EchoRawMTOMCommonsChunkingTest() {
- super(EchoRawMTOMCommonsChunkingTest.class.getName());
- }
-
- public EchoRawMTOMCommonsChunkingTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- UtilServer.start(Constants.TESTING_PATH + "MTOM-enabledRepository");
- service = Utils.createSimpleService(serviceName, Echo.class.getName(),
- operationName);
- UtilServer.deployService(service);
- serviceContext = UtilServer.getConfigurationContext()
- .createServiceContext(service.getName());
- }
-
- protected void tearDown() throws Exception {
- UtilServer.unDeployService(serviceName);
- UtilServer.stop();
- }
-
- private OMElement createEnvelope() throws Exception {
-
- DataHandler expectedDH;
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
- OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
- data = fac.createOMElement("data", omNs);
- Image expectedImage;
- expectedImage = new JDK13IO()
- .loadImage(getResourceAsStream("org/apache/axis2/mtom/test.jpg"));
-
- ImageDataSource dataSource = new ImageDataSource("test.jpg",
- expectedImage);
- expectedDH = new DataHandler(dataSource);
- //OMTextImpl textData = new OMTextImpl(expectedDH, true);
- for (int i =0; i<1 ; i++)
- {
- OMElement subData = fac.createOMElement("subData",omNs);
- OMText textData = new OMTextImpl(new DataHandler("Thilina","text/plain"));
- subData.addChild(textData);
- data.addChild(subData);
- }
- rpcWrapEle.addChild(data);
- return rpcWrapEle;
-
- }
-
- public void testEchoXMLSync() throws Exception {
- SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-
- OMElement payload = createEnvelope();
-
- org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(Constants.TESTING_PATH+"commons-http-enabledRepository");
- call.setTo(targetEPR);
- call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
- call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP, Constants.TRANSPORT_HTTP, false);
-
- OMElement result = (OMElement) call.invokeBlocking(operationName
- .getLocalPart(), payload);
-
- OMElement ele = (OMElement) result.getFirstChild();
- this.campareWithCreatedOMElement(data);
-
- }
-
- private InputStream getResourceAsStream(String path) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- return cl.getResourceAsStream(path);
- }
-
- private void campareWithCreatedOMElement(OMElement element){
+ private EndpointReference targetEPR = new EndpointReference(
+ AddressingConstants.WSA_TO, "http://127.0.0.1:"
+ + (UtilServer.TESTING_PORT)
+ + "/axis/services/EchoXMLService/echoOMElement");
+
+ private Log log = LogFactory.getLog(getClass());
+
+ private QName serviceName = new QName("EchoXMLService");
+
+ private QName operationName = new QName("echoOMElement");
+
+ private QName transportName = new QName("http://localhost/my",
+ "NullTransport");
+
+ private String imageInFileName = "img/test.jpg";
+
+ private String imageOutFileName = "mtom/img/testOut.jpg";
+
+ private AxisConfiguration engineRegistry;
+
+ private MessageContext mc;
+
+ private ServiceContext serviceContext;
+
+ private ServiceDescription service;
+
+ private OMElement data;
+
+ private boolean finish = false;
+
+ public EchoRawMTOMCommonsChunkingTest() {
+ super(EchoRawMTOMCommonsChunkingTest.class.getName());
+ }
+
+ public EchoRawMTOMCommonsChunkingTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilServer.start(Constants.TESTING_PATH + "MTOM-enabledRepository");
+ service = Utils.createSimpleService(serviceName, Echo.class.getName(),
+ operationName);
+ UtilServer.deployService(service);
+ serviceContext = UtilServer.getConfigurationContext()
+ .createServiceContext(service.getName());
+ }
+
+ protected void tearDown() throws Exception {
+ UtilServer.unDeployService(serviceName);
+ UtilServer.stop();
+ }
+
+ private OMElement createEnvelope() throws Exception {
+
+ DataHandler expectedDH;
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+ OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
+ data = fac.createOMElement("data", omNs);
+ Image expectedImage;
+ expectedImage = new JDK13IO()
+ .loadImage(getResourceAsStream("org/apache/axis2/mtom/test.jpg"));
+
+ ImageDataSource dataSource = new ImageDataSource("test.jpg",
+ expectedImage);
+ expectedDH = new DataHandler(dataSource);
+ OMElement subData = fac.createOMElement("subData", omNs);
+ OMText textData = new OMTextImpl(expectedDH);
+ subData.addChild(textData);
+ data.addChild(subData);
+ rpcWrapEle.addChild(data);
+ return rpcWrapEle;
+
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+ OMElement payload = createEnvelope();
+
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call(
+ Constants.TESTING_PATH + "commons-http-enabledRepository");
+ call.setTo(targetEPR);
+ call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
+ call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP,
+ Constants.TRANSPORT_HTTP, false);
+ OMElement result = (OMElement) call.invokeBlocking(operationName
+ .getLocalPart(), payload);
+
+ OMElement ele = (OMElement) result.getFirstChild();
+ this.campareWithCreatedOMElement(data);
+
+ }
+
+ private InputStream getResourceAsStream(String path) {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return cl.getResourceAsStream(path);
+ }
+
+ private void campareWithCreatedOMElement(OMElement element) {
OMElement firstChild = element.getFirstElement();
TestCase.assertNotNull(firstChild);
String originalTextValue = data.getFirstElement().getText();
- String returnedTextValue = firstChild.getText();
- TestCase.assertEquals(returnedTextValue,originalTextValue);
+ String returnedTextValue = firstChild.getText();
+ TestCase.assertEquals(returnedTextValue, originalTextValue);
}
}
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java Wed Jul 20 05:13:42 2005
@@ -20,6 +20,8 @@
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
+import java.io.ByteArrayInputStream;
+
import junit.framework.TestCase;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
@@ -70,6 +72,8 @@
private ServiceDescription service;
private boolean finish = false;
+
+ byte[] expectedByteArray;
public EchoRawMTOMLoadTest() {
super(EchoRawMTOMLoadTest.class.getName());
@@ -99,12 +103,12 @@
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement rpcWrapEle = fac.createOMElement("echoOMElement", omNs);
OMElement data = fac.createOMElement("data", omNs);
- byte[] byteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
+ expectedByteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
98};
for (int i = 0; i < 4; i++) {
OMElement subData = fac.createOMElement("subData", omNs);
DataHandler dataHandler = new DataHandler(
- new ByteArrayDataSource(byteArray));
+ new ByteArrayDataSource(expectedByteArray));
OMText textData = new OMTextImpl(dataHandler, true);
//OMText textData = new OMTextImpl("Thilina Gunarathne");
subData.addChild(textData);
@@ -135,6 +139,12 @@
OMElement ele = (OMElement) result.getFirstChild();
OMElement ele1 = (OMElement) ele.getFirstChild();
OMText binaryNode = (OMText) ele1.getFirstChild();
+ DataHandler actualDataHandler = binaryNode.getDataHandler();
+ ByteArrayInputStream inStream = (ByteArrayInputStream)actualDataHandler.getContent();
+ byte[] actualByteArray = new byte[11];
+ inStream.read(actualByteArray);
+ assertEquals(expectedByteArray[0],actualByteArray[0]);
+ assertEquals(expectedByteArray[0],actualByteArray[0]);
System.out.println(i);
}
}
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMTest.java Wed Jul 20 05:13:42 2005
@@ -78,6 +78,8 @@
private ServiceDescription service;
private boolean finish = false;
+
+ private OMTextImpl expectedTextData;
public EchoRawMTOMTest() {
super(EchoRawMTOMTest.class.getName());
@@ -113,14 +115,11 @@
new JDK13IO()
.loadImage(
getResourceAsStream("org/apache/axis2/mtom/test.jpg"));
-
ImageDataSource dataSource = new ImageDataSource("test.jpg",
expectedImage);
expectedDH = new DataHandler(dataSource);
- OMTextImpl textData = new OMTextImpl(expectedDH, true);
- data.addChild(textData);
- //OMTextImpl textData1 = new OMTextImpl(expectedDH, true);
- //data.addChild(textData1);
+ expectedTextData = new OMTextImpl(expectedDH, true);
+ data.addChild(expectedTextData);
rpcWrapEle.addChild(data);
return rpcWrapEle;
@@ -144,6 +143,11 @@
// OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
OMElement ele = (OMElement) result.getFirstChild();
OMText binaryNode = (OMText) ele.getFirstChild();
+
+ // to the assert equal
+ compareWithCreatedOMText(binaryNode);
+
+ // Save the image
DataHandler actualDH;
actualDH = binaryNode.getDataHandler();
Image actualObject = new JDK13IO().loadImage(actualDH.getDataSource()
@@ -156,5 +160,10 @@
private InputStream getResourceAsStream(String path) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return cl.getResourceAsStream(path);
+ }
+ private void compareWithCreatedOMText(OMText actualTextData) {
+ String originalTextValue = expectedTextData.getText();
+ String returnedTextValue = actualTextData.getText();
+ TestCase.assertEquals(returnedTextValue, originalTextValue);
}
}
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java?rev=219885&r1=219884&r2=219885&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java Wed Jul 20 05:13:42 2005
@@ -20,7 +20,11 @@
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
+
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
@@ -35,35 +39,38 @@
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.OMNamespace;
+import org.apache.axis2.om.OMText;
import org.apache.axis2.om.impl.llom.OMTextImpl;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-
public class EchoRawMTOMToBase64Test extends TestCase {
- private EndpointReference targetEPR =
- new EndpointReference(AddressingConstants.WSA_TO,
- "http://127.0.0.1:"
- + (UtilServer.TESTING_PORT)
- + "/axis/services/EchoXMLService/echoMTOMtoBase64");
+ private EndpointReference targetEPR = new EndpointReference(
+ AddressingConstants.WSA_TO, "http://127.0.0.1:"
+ + (UtilServer.TESTING_PORT)
+ + "/axis/services/EchoXMLService/echoMTOMtoBase64");
+
private Log log = LogFactory.getLog(getClass());
+
private QName serviceName = new QName("EchoXMLService");
+
private QName operationName = new QName("echoMTOMtoBase64");
+
private QName transportName = new QName("http://localhost/my",
"NullTransport");
private AxisConfiguration engineRegistry;
+
private MessageContext mc;
- //private Thread thisThread;
- // private SimpleHTTPServer sas;
+
private ServiceContext serviceContext;
+
private ServiceDescription service;
+ OMText expectedTextData;
+
private boolean finish = false;
public EchoRawMTOMToBase64Test() {
@@ -76,14 +83,11 @@
protected void setUp() throws Exception {
UtilServer.start();
- service =
- Utils.createSimpleService(serviceName,
- Echo.class.getName(),
- operationName);
+ service = Utils.createSimpleService(serviceName, Echo.class.getName(),
+ operationName);
UtilServer.deployService(service);
- serviceContext =
- UtilServer.getConfigurationContext().createServiceContext(
- service.getName());
+ serviceContext = UtilServer.getConfigurationContext()
+ .createServiceContext(service.getName());
}
protected void tearDown() throws Exception {
@@ -91,46 +95,48 @@
UtilServer.stop();
}
- private OMElement createEnvelope() {
+ private OMElement createPayload() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement rpcWrapEle = fac.createOMElement("echoMTOMtoBase64", omNs);
OMElement data = fac.createOMElement("data", omNs);
- byte[] byteArray = new byte[]{13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
- 98};
- DataHandler dataHandler = new DataHandler(
- new ByteArrayDataSource(byteArray));
- OMTextImpl textData = new OMTextImpl(dataHandler, true);
- data.addChild(textData);
+ byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
+ 98 };
+ DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(
+ byteArray));
+ expectedTextData = new OMTextImpl(dataHandler, true);
+ data.addChild(expectedTextData);
rpcWrapEle.addChild(data);
return rpcWrapEle;
}
-
public void testEchoXMLSync() throws Exception {
for (int i = 0; i < 10; i++) {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
- OMElement payload = createEnvelope();
+ OMElement payload = createPayload();
org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
call.setTo(targetEPR);
- call.set(Constants.Configuration.ENABLE_MTOM,
- Constants.VALUE_TRUE);
+ call.set(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
call.setTransportInfo(Constants.TRANSPORT_HTTP,
- Constants.TRANSPORT_HTTP,
- false);
+ Constants.TRANSPORT_HTTP, false);
+
+ OMElement result = (OMElement) call.invokeBlocking(operationName
+ .getLocalPart(), payload);
- OMElement result =
- (OMElement) call.invokeBlocking(
- operationName.getLocalPart(), payload);
- result.serializeWithCache(XMLOutputFactory.newInstance()
- .createXMLStreamWriter(System.out));
+ OMElement data = (OMElement) result.getFirstChild();
+ compareWithCreatedOMText(data.getText());
call.close();
System.out.println(i);
}
}
-}
+ private void compareWithCreatedOMText(String actualText) {
+ String originalTextValue = expectedTextData.getText();
+ TestCase.assertEquals(actualText, originalTextValue);
+ }
+
+}
\ No newline at end of file