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/08/11 05:31:40 UTC
svn commit: r231384 - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis2/ core/src/org/apache/axis2/transport/http/
integration/ integration/test/org/apache/axis2/mtom/
integration/test/org/apache/axis2/swa/ xml/src/org/apache/axis2/att...
Author: thilina
Date: Wed Aug 10 20:31:14 2005
New Revision: 231384
URL: http://svn.apache.org/viewcvs?rev=231384&view=rev
Log:
Commiting File Storage stuffs....+ File caching test cases....
Added:
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml
Modified:
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/Constants.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
webservices/axis/trunk/java/modules/integration/maven.xml
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java
webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEBodyPartInputStream.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/Constants.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/Constants.java Wed Aug 10 20:31:14 2005
@@ -178,6 +178,7 @@
public static final String ENABLE_MTOM = "enableMTOM";
public static final String ATTACHMENT_TEMP_DIR = "attachmentDIR";
public static final String CACHE_ATTACHMENTS = "cacheAttachments";
+ public static final String FILE_SIZE_THRESHOLD = "sizeThreshold";
}
public static final String VALUE_TRUE = "true";
@@ -187,7 +188,7 @@
public static final String TESTING_PATH = "target/test-resources/";
- //public static final String TESTING_PATH = "modules/samples/target/test-resources/";
+ //public static final String TESTING_PATH = "modules/integration/target/test-resources/";
public static final String TESTING_REPOSITORY = TESTING_PATH + "samples";
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Wed Aug 10 20:31:14 2005
@@ -316,13 +316,20 @@
msgContext.getProperty(
Constants.Configuration.CACHE_ATTACHMENTS)));
String attachmentRepoDir = null;
+ String attachmentSizeThreshold = null;
if (fileCacheForAttachments) {
attachmentRepoDir = (String) msgContext
.getProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+// if (attachmentRepoDir==null | ("").equals(attachmentRepoDir))
+// {
+// msgContext.getServiceContext().getEngineContext().getRealPath("temp");
+// }
+ attachmentSizeThreshold = (String) msgContext
+ .getProperty(Constants.Configuration.FILE_SIZE_THRESHOLD);
}
MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString,
- fileCacheForAttachments, attachmentRepoDir);
+ fileCacheForAttachments, attachmentRepoDir,attachmentSizeThreshold);
XMLStreamReader reader = XMLInputFactory.newInstance()
.createXMLStreamReader(
Modified: webservices/axis/trunk/java/modules/integration/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/maven.xml?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/maven.xml (original)
+++ webservices/axis/trunk/java/modules/integration/maven.xml Wed Aug 10 20:31:14 2005
@@ -49,6 +49,11 @@
<copy file="test/org/apache/axis2/mtom/MTOM-enabled-axis2.xml"
tofile="target/test-resources/MTOM-enabledRepository/axis2.xml"/>
+ <!-- MTOM enabled Repository -->
+ <mkdir dir="target/test-resources/MTOM-fileCache-enabledRepository"/>
+ <copy file="test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml"
+ tofile="target/test-resources/MTOM-fileCache-enabledRepository/axis2.xml"/>
+
<mkdir dir="target/groovyRepo"/>
<mkdir dir="target/groovyRepo/services"/>
<ant:copy file="../samples/target/samples/groovyService.aar" tofile="target/groovyRepo/services/groovyService.aar"/>
Added: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java?rev=231384&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java (added)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheLoadTest.java Wed Aug 10 20:31:14 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 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.
+ *
+ */
+package org.apache.axis2.mtom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.util.Utils;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class EchoRawMTOMFileCacheLoadTest extends EchoRawMTOMLoadTest {
+
+ private QName serviceName = new QName("EchoXMLService");
+
+ private QName operationName = new QName("echoOMElement");
+
+ private ServiceContext serviceContext;
+
+ private ServiceDescription service;
+
+ public EchoRawMTOMFileCacheLoadTest() {
+ super(EchoRawMTOMFileCacheLoadTest.class.getName());
+ }
+
+ public EchoRawMTOMFileCacheLoadTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilServer.start(Constants.TESTING_PATH + "MTOM-fileCache-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();
+ }
+
+
+ public void testEchoXMLSync() throws Exception {
+ super.testEchoXMLSync();
+ }
+
+}
Added: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java?rev=231384&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java (added)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMFileCacheTest.java Wed Aug 10 20:31:14 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 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.
+ *
+ */
+package org.apache.axis2.mtom;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.util.Utils;
+
+/**
+ * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
+ */
+public class EchoRawMTOMFileCacheTest extends EchoRawMTOMTest{
+
+ private QName serviceName = new QName("EchoXMLService");
+
+ private QName operationName = new QName("echoOMElement");
+
+ private ServiceContext serviceContext;
+
+ private ServiceDescription service;
+
+ public EchoRawMTOMFileCacheTest() {
+ super(EchoRawMTOMFileCacheTest.class.getName());
+ }
+
+ public EchoRawMTOMFileCacheTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilServer.start(Constants.TESTING_PATH + "MTOM-fileCache-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();
+ }
+
+ public void testEchoXMLASync() throws Exception {
+ super.testEchoXMLASync();
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ super.testEchoXMLSync();
+ }
+}
Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java (original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMLoadTest.java Wed Aug 10 20:31:14 2005
@@ -20,15 +20,22 @@
* @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.EndpointReference;
-import org.apache.axis2.attachments.ByteArrayDataSource;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.ServiceDescription;
import org.apache.axis2.engine.Echo;
import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.om.*;
+import org.apache.axis2.om.OMAbstractFactory;
+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.SOAP12Constants;
import org.apache.axis2.soap.SOAPFactory;
@@ -36,9 +43,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-
public class EchoRawMTOMLoadTest extends TestCase {
private EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:"
+ (UtilServer.TESTING_PORT)
@@ -81,7 +85,7 @@
UtilServer.stop();
}
- private OMElement createEnvelope() {
+ protected OMElement createEnvelope() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
@@ -91,8 +95,8 @@
98};
for (int i = 0; i < 4; i++) {
OMElement subData = fac.createOMElement("subData", omNs);
- DataHandler dataHandler = new DataHandler(
- new ByteArrayDataSource(expectedByteArray));
+ DataHandler dataHandler = new DataHandler("Thilina","text/plain");
+ //new ByteArrayDataSource(expectedByteArray));
textData = new OMTextImpl(dataHandler, true);
subData.addChild(textData);
data.addChild(subData);
@@ -127,7 +131,7 @@
log.info("" + i);
}
}
- private void compareWithActualOMText(OMText binaryNode)
+ protected void compareWithActualOMText(OMText binaryNode)
{
assertEquals(textData.getText(),binaryNode.getText());
}
Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java (original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMTest.java Wed Aug 10 20:31:14 2005
@@ -20,28 +20,38 @@
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
+import java.awt.Image;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.attachments.utils.ImageDataSource;
import org.apache.axis2.attachments.utils.JDK13IO;
+import org.apache.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.ServiceDescription;
import org.apache.axis2.engine.Echo;
import org.apache.axis2.integration.UtilServer;
-import org.apache.axis2.om.*;
+import org.apache.axis2.om.OMAbstractFactory;
+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.SOAP12Constants;
+import org.apache.axis2.soap.SOAPEnvelope;
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 java.awt.*;
-import java.io.InputStream;
-
public class EchoRawMTOMTest extends TestCase {
private EndpointReference targetEPR = new EndpointReference("http://127.0.0.1:"
+ (UtilServer.TESTING_PORT)
@@ -58,6 +68,8 @@
private ServiceDescription service;
private OMTextImpl expectedTextData;
+
+ private boolean finish = false;
public EchoRawMTOMTest() {
super(EchoRawMTOMTest.class.getName());
@@ -81,7 +93,7 @@
UtilServer.stop();
}
- private OMElement createEnvelope() throws Exception {
+ protected OMElement createEnvelope() throws Exception {
DataHandler expectedDH;
OMFactory fac = OMAbstractFactory.getOMFactory();
@@ -101,7 +113,49 @@
return rpcWrapEle;
}
+ public void testEchoXMLASync() throws Exception {
+ OMElement payload = createEnvelope();
+
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+
+ Callback callback = new Callback() {
+ public void onComplete(AsyncResult result) {
+ SOAPEnvelope envelope = result.getResponseEnvelope();
+
+ OMElement ele = (OMElement) envelope.getBody().getFirstElement().getFirstChild();
+ OMText binaryNode = (OMText) ele.getFirstChild();
+
+ // to the assert equal
+ compareWithCreatedOMText(binaryNode);
+ finish = true;
+ }
+
+ public void reportError(Exception e) {
+ log.info(e.getMessage());
+ finish = true;
+ }
+ };
+
+ call.invokeNonBlocking(operationName.getLocalPart(),
+ payload,
+ callback);
+ int index = 0;
+ while (!finish) {
+ Thread.sleep(1000);
+ index++;
+ if (index > 10) {
+ throw new AxisFault(
+ "Server is shutdown as the Async response take too longs time");
+ }
+ }
+ call.close();
+ }
+
public void testEchoXMLSync() throws Exception {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
@@ -135,12 +189,12 @@
}
- private InputStream getResourceAsStream(String path) {
+ protected InputStream getResourceAsStream(String path) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return cl.getResourceAsStream(path);
}
- private void compareWithCreatedOMText(OMText actualTextData) {
+ protected void compareWithCreatedOMText(OMText actualTextData) {
String originalTextValue = expectedTextData.getText();
String returnedTextValue = actualTextData.getText();
TestCase.assertEquals(returnedTextValue, originalTextValue);
Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java (original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/EchoRawMTOMToBase64Test.java Wed Aug 10 20:31:14 2005
@@ -21,9 +21,13 @@
*/
import junit.framework.TestCase;
+
+import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.attachments.ByteArrayDataSource;
+import org.apache.axis2.clientapi.AsyncResult;
+import org.apache.axis2.clientapi.Callback;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.ServiceDescription;
import org.apache.axis2.engine.Echo;
@@ -31,6 +35,7 @@
import org.apache.axis2.om.*;
import org.apache.axis2.om.impl.llom.OMTextImpl;
import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.axis2.util.Utils;
import org.apache.commons.logging.Log;
@@ -55,6 +60,8 @@
private ServiceDescription service;
OMText expectedTextData;
+
+ private boolean finish = false;
public EchoRawMTOMToBase64Test() {
super(EchoRawMTOMToBase64Test.class.getName());
@@ -93,6 +100,46 @@
return rpcWrapEle;
}
+ public void testEchoXMLASync() throws Exception {
+ OMElement payload = createPayload();
+
+ org.apache.axis2.clientapi.Call call = new org.apache.axis2.clientapi.Call();
+
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_HTTP,
+ Constants.TRANSPORT_HTTP,
+ false);
+
+ Callback callback = new Callback() {
+ public void onComplete(AsyncResult result) {
+ SOAPEnvelope envelope = result.getResponseEnvelope();
+
+ OMElement data = (OMElement) envelope.getBody().getFirstElement().getFirstChild();
+ compareWithCreatedOMText(data.getText());
+ finish = true;
+ }
+
+ public void reportError(Exception e) {
+ log.info(e.getMessage());
+ finish = true;
+ }
+ };
+
+ call.invokeNonBlocking(operationName.getLocalPart(),
+ payload,
+ callback);
+ int index = 0;
+ while (!finish) {
+ Thread.sleep(1000);
+ index++;
+ if (index > 10) {
+ throw new AxisFault(
+ "Server is shutdown as the Async response take too longs time");
+ }
+ }
+ call.close();
+ }
+
public void testEchoXMLSync() throws Exception {
for (int i = 0; i < 10; i++) {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
Added: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml?rev=231384&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml (added)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/mtom/MTOM-fileCache-enabled-axis2.xml Wed Aug 10 20:31:14 2005
@@ -0,0 +1,97 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="xsd:false">true</parameter>
+ <parameter name="hotupdate" locked="xsd:false">false</parameter>
+ <parameter name="enableMTOM" locked="xsd:false">true</parameter>
+ <parameter name="cacheAttachments" locked="xsd:false">true</parameter>
+ <parameter name="attachmentDIR" locked="xsd:false">target/test-resources/</parameter>
+ <parameter name="sizeThreshold" locked="xsd:false">4000</parameter>
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="eanbleREST" locked="xsd:false">true</parameter>-->
+
+
+ <parameter name="userName" locked="xsd:false">admin</parameter>
+ <parameter name="password" locked="xsd:false">axis2</parameter>
+
+
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!-- This is the Deafult Message Receiver for the Request Response style Operations -->
+ <messageReceiver mep="INOUT" class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="xsd:false">6060</parameter>
+ </transportReceiver>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">
+ <parameter name="transport.mail.pop3.host" locked="xsd:false">127.0.0.1</parameter>
+ <parameter name="transport.mail.pop3.user" locked="xsd:false">axis2</parameter>
+ <parameter name="transport.mail.pop3.password" locked="xsd:false">axis2</parameter>
+ <parameter name="transport.mail.pop3.port" locked="xsd:false">110</parameter>
+ <parameter name="transport.mail.replyToAddress" locked="xsd:false">axis2@127.0.0.1</parameter>
+ </transportReceiver> -->
+
+ <transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="xsd:false">6060</parameter>
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="xsd:false">HTTP/1.0</parameter>
+ </transportSender>
+ <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportSender name="mail" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="transport.mail.smtp.host" locked="xsd:false">127.0.0.1</parameter>
+ <parameter name="transport.mail.smtp.user" locked="xsd:false">axis2</parameter>
+ <parameter name="transport.mail.smtp.password" locked="xsd:false">axis2</parameter>
+ <parameter name="transport.mail.smtp.port" locked="xsd:false">25</parameter>
+ </transportSender>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Uncomment this to enable Addressing
+ <module ref="addressing"/> -->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="TransportIn"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch"/>
+ <phase name="PostDispatch"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+</axisconfig>
+
Modified: webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java (original)
+++ webservices/axis/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java Wed Aug 10 20:31:14 2005
@@ -20,7 +20,17 @@
* @author <a href="mailto:thilina@opensource.lk">Thilina Gunarathne </a>
*/
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketException;
+
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
+
import org.apache.axis2.Constants;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.OperationDescription;
@@ -35,13 +45,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.wsdl.WSDLService;
-import javax.xml.namespace.QName;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.Socket;
-
public class EchoRawSwATest extends TestCase {
private Log log = LogFactory.getLog(getClass());
@@ -91,34 +94,34 @@
}
public void testEchoXMLSync() throws Exception {
+ Thread.sleep(1000);
Socket socket = new Socket("127.0.0.1", 5555);
OutputStream outStream = socket.getOutputStream();
InputStream inStream = socket.getInputStream();
InputStream requestMsgInStream = getResourceAsStream("org/apache/axis2/swa/swainput.bin");
int data;
- while ((data = requestMsgInStream.read())!=-1) {
+ while ((data = requestMsgInStream.read()) != -1) {
+ System.out.print(data);
outStream.write(data);
}
outStream.flush();
socket.shutdownOutput();
- BufferedReader reader = new BufferedReader( new InputStreamReader(socket.getInputStream()));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(socket
+ .getInputStream()));
StringBuffer sb = new StringBuffer();
+
String response = reader.readLine();
- while( null != response ) {
- sb.append(response.trim());
- response = reader.readLine();
+ while (null != response) {
+ try {
+ sb.append(response.trim());
+ response = reader.readLine();
+ } catch (SocketException e) {
+ break;
+ }
}
-// int x=0;
-// BufferedInputStream buffredStream = new BufferedInputStream(inStream);
-// socket.setKeepAlive(true);
-// while ((i[0] = (byte)buffredStream.read()) > -1) {
-// stringBuffer.append(new String(i));
-// System.out.println(x);
-// x++;
-// }
- // socket.close();
- assertTrue(sb.toString().indexOf("Apache Axis2 - The NExt Generation Web Services Engine")>0);
- assertTrue(sb.toString().indexOf("multipart/related")>0);
+ assertTrue(sb.toString().indexOf(
+ "Apache Axis2 - The NExt Generation Web Services Engine") > 0);
+ assertTrue(sb.toString().indexOf("multipart/related") > 0);
}
private InputStream getResourceAsStream(String path) {
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEBodyPartInputStream.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEBodyPartInputStream.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEBodyPartInputStream.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEBodyPartInputStream.java Wed Aug 10 20:31:14 2005
@@ -97,4 +97,9 @@
inStream.unread(boundary, 1, boundaryIndex - 1);
return boundary[0];
}
+
+ public boolean getBoundaryStatus()
+ {
+ return boundaryFound;
+ }
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/MIMEHelper.java Wed Aug 10 20:31:14 2005
@@ -10,17 +10,19 @@
*/
package org.apache.axis2.attachments;
-import org.apache.axis2.om.OMException;
-import org.apache.axis2.om.impl.MTOMConstants;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.HashMap;
import javax.activation.DataHandler;
import javax.mail.MessagingException;
import javax.mail.internet.ContentType;
import javax.mail.internet.ParseException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PushbackInputStream;
-import java.util.HashMap;
+
+import org.apache.axis2.om.OMException;
+import org.apache.axis2.om.impl.MTOMConstants;
/**
* @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
@@ -74,6 +76,8 @@
String attachmentRepoDir = null;
+ int fileStorageThreshold;
+
/**
* @param inStream
* @param contentTypeString
@@ -84,17 +88,22 @@
* read till first MIME boundary is found or end of stream reached.
*/
public MIMEHelper(InputStream inStream, String contentTypeString,
- boolean fileCacheEnable, String attachmentRepoDir)
- throws OMException {
+ boolean fileCacheEnable, String attachmentRepoDir,
+ String fileThreshold) throws OMException {
this.attachmentRepoDir = attachmentRepoDir;
this.fileCacheEnable = fileCacheEnable;
+ if (fileThreshold != null && (!fileThreshold.equals(""))) {
+ this.fileStorageThreshold = Integer.parseInt(fileThreshold);
+ } else {
+ this.fileStorageThreshold = 1;
+ }
bodyPartsMap = new HashMap();
try {
contentType = new ContentType(contentTypeString);
} catch (ParseException e) {
throw new OMException(
"Invalid Content Type Field in the Mime Message"
- + e.toString());
+ ,e);
}
// Boundary always have the prefix "--".
this.boundary = ("--" + contentType.getParameter("boundary"))
@@ -143,7 +152,7 @@
*/
public MIMEHelper(InputStream inStream, String contentTypeString)
throws OMException {
- this(inStream, contentTypeString, false, null);
+ this(inStream, contentTypeString, false, null, null);
}
/**
@@ -181,7 +190,7 @@
return dh.getInputStream();
} catch (IOException e) {
throw new OMException(
- "Problem with DataHandler of the Root Mime Part. " + e);
+ "Problem with DataHandler of the Root Mime Part. ",e);
}
}
@@ -334,17 +343,40 @@
"Referenced MIME part not found.End of Stream reached.");
Part part = null;
- MIMEBodyPartInputStream partStream;
- partStream = new MIMEBodyPartInputStream(pushbackInStream, boundary,
- this);
+
try {
if (fileCacheEnable) {
try {
- part = new PartOnFile(partStream, attachmentRepoDir);
+ MIMEBodyPartInputStream partStream;
+ byte[] buffer = new byte[fileStorageThreshold];
+ partStream = new MIMEBodyPartInputStream(pushbackInStream,
+ boundary, this);
+ int count = 0;
+ int value;
+ // Make sure not to modify this to a Short Circuit "&". If
+ // removed a byte will be lost
+ while (count != fileStorageThreshold
+ && (!partStream.getBoundaryStatus())) {
+ value = partStream.read();
+ buffer[count] = (byte) value;
+ count++;
+ }
+ if (count == fileStorageThreshold) {
+ PushbackFilePartInputStream filePartStream = new PushbackFilePartInputStream(
+ partStream, buffer);
+ part = new PartOnFile(filePartStream, attachmentRepoDir);
+ } else {
+ ByteArrayInputStream byteArrayInStream = new ByteArrayInputStream(
+ buffer,0,count-1);
+ part = new PartOnMemory(byteArrayInStream);
+ }
} catch (Exception e) {
- throw new OMException("Error creating temporary File." + e);
+ throw new OMException("Error creating temporary File.", e);
}
} else {
+ MIMEBodyPartInputStream partStream;
+ partStream = new MIMEBodyPartInputStream(pushbackInStream,
+ boundary, this);
part = new PartOnMemory(partStream);
}
// This will take care if stream ended without having MIME
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnFile.java Wed Aug 10 20:31:14 2005
@@ -1,18 +1,12 @@
/**
- * Copyright 2001-2004 The Apache Software Foundation.
- * <p/>
- * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * 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.
- * <p/>
+ * Copyright 2001-2004 The Apache Software Foundation. <p/>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 <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0 <p/>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. <p/>
*/
package org.apache.axis2.attachments;
@@ -38,8 +32,7 @@
HashMap headers;
- public PartOnFile(MIMEBodyPartInputStream inStream, String repoDir)
- {
+ public PartOnFile(PushbackFilePartInputStream inStream, String repoDir) {
super();
headers = new HashMap();
@@ -50,26 +43,27 @@
try {
cacheFile = java.io.File.createTempFile("Axis2", ".att",
(repoDir == null) ? null : new File(repoDir));
-
- FileOutputStream fileOutStream = new FileOutputStream(cacheFile);
- int value;
- value = parseTheHeaders(inStream);
-
- if(value!=-1)
- {
- do {
+
+ FileOutputStream fileOutStream = new FileOutputStream(cacheFile);
+ int value;
+ value = parseTheHeaders(inStream);
fileOutStream.write(value);
- }while ((value = inStream.read()) != -1);
- }
- fileOutStream.flush();
- fileOutStream.close();
+ while (!inStream.getBoundaryStatus()) {
+ value = inStream.read();
+ if (!inStream.getBoundaryStatus()) {
+ fileOutStream.write(value);
+ }
+
+ }
+
+ fileOutStream.flush();
+ fileOutStream.close();
} catch (IOException e) {
- throw new OMException("Error creating temporary File."+e);
+ throw new OMException("Error creating temporary File.", e);
}
}
-
- private int parseTheHeaders(InputStream inStream) throws IOException
- {
+
+ private int parseTheHeaders(InputStream inStream) throws IOException {
int value;
boolean readingHeaders = true;
StringBuffer header = new StringBuffer();
@@ -100,31 +94,28 @@
private void putToMap(StringBuffer header) {
String headerString = header.toString();
int delimiter = headerString.indexOf(":");
- headers.put(headerString.substring(0, delimiter).trim(),
- headerString.substring(delimiter + 1, headerString.length())
- .trim());
+ headers.put(headerString.substring(0, delimiter).trim(), headerString
+ .substring(delimiter + 1, headerString.length()).trim());
}
public String getContentID() {
- String cID = (String)headers.get("Content-ID");;
- if (cID==null)
- {
- cID= (String)headers.get("Content-Id");
- if (cID==null)
- {
- cID= (String)headers.get("Content-id");
- if (cID==null)
- {
- cID= (String)headers.get("content-id");
+ String cID = (String) headers.get("Content-ID");
+ ;
+ if (cID == null) {
+ cID = (String) headers.get("Content-Id");
+ if (cID == null) {
+ cID = (String) headers.get("Content-id");
+ if (cID == null) {
+ cID = (String) headers.get("content-id");
}
}
-
+
}
return cID;
}
public int getSize() throws MessagingException {
- return (int)cacheFile.length();
+ return (int) cacheFile.length();
}
public int getLineCount() throws MessagingException {
@@ -172,16 +163,14 @@
}
public String getContentType() throws MessagingException {
- String cType= (String)headers.get("Content-Type");
- if (cType==null)
- {
- cType= (String)headers.get("Content-type");
- if (cType==null)
- {
- cType= (String)headers.get("content-type");
+ String cType = (String) headers.get("Content-Type");
+ if (cType == null) {
+ cType = (String) headers.get("Content-type");
+ if (cType == null) {
+ cType = (String) headers.get("content-type");
}
}
- return cType;
+ return cType;
}
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/PartOnMemory.java Wed Aug 10 20:31:14 2005
@@ -29,7 +29,7 @@
public class PartOnMemory implements Part{
MimeBodyPart part;
- public PartOnMemory(MIMEBodyPartInputStream partInStream) throws MessagingException
+ public PartOnMemory(InputStream partInStream) throws MessagingException
{
part = new MimeBodyPart(partInStream);
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java?rev=231384&r1=231383&r2=231384&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java Wed Aug 10 20:31:14 2005
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright 2004,2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");