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 ch...@apache.org on 2005/06/29 09:01:28 UTC
svn commit: r202323 - in /webservices/axis/trunk/java/modules:
core/src/org/apache/axis/transport/http/
core/test/org/apache/axis/transport/http/
samples/test/org/apache/axis/engine/ xml/src/org/apache/axis/om/
xml/src/org/apache/axis/om/impl/llom/ xml...
Author: chinthaka
Date: Wed Jun 29 00:01:26 2005
New Revision: 202323
URL: http://svn.apache.org/viewcvs?rev=202323&view=rev
Log:
- Adding more constructors to SOAPFactory to create OMText
- Adding a method to check isOptimize for envelope. This is tested in HTTPTransportUtil and its test
Added:
webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/http/HTTPTransportUtilTest.java
Modified:
webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportUtils.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/OMFactory.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMTextImpl.java
webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/factory/OMLinkedListImplFactory.java
webservices/axis/trunk/java/modules/xml/test/org/apache/axis/attachments/ImageSampleTest.java
webservices/axis/trunk/java/modules/xml/test/org/apache/axis/om/impl/llom/OMOutputTest.java
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportUtils.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportUtils.java Wed Jun 29 00:01:26 2005
@@ -43,6 +43,8 @@
import org.apache.axis.om.OMElement;
import org.apache.axis.om.OMException;
import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMNode;
+import org.apache.axis.om.OMText;
import org.apache.axis.om.impl.llom.OMNamespaceImpl;
import org.apache.axis.om.impl.llom.builder.StAXBuilder;
import org.apache.axis.om.impl.llom.builder.StAXOMBuilder;
@@ -207,4 +209,22 @@
}
return builder;
}
+
+ public boolean checkEnvelopeForOptimise(SOAPEnvelope envelope)
+ {
+ return isOptimised(envelope);
+ }
+
+ private boolean isOptimised(OMElement element) {
+ Iterator childrenIter = element.getChildren();
+ while(childrenIter.hasNext()){
+ OMNode node = (OMNode) childrenIter.next();
+ if( OMNode.TEXT_NODE == node.getType() && ((OMText)node).isOptimized()){
+ return true;
+ }else if (OMNode.ELEMENT_NODE == node.getType()) {
+ return isOptimised((OMElement) node);
+ }
+ }
+ return false;
+ }
}
Added: webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/http/HTTPTransportUtilTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/http/HTTPTransportUtilTest.java?rev=202323&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/http/HTTPTransportUtilTest.java (added)
+++ webservices/axis/trunk/java/modules/core/test/org/apache/axis/transport/http/HTTPTransportUtilTest.java Wed Jun 29 00:01:26 2005
@@ -0,0 +1,68 @@
+package org.apache.axis.transport.http;
+
+import junit.framework.TestCase;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMText;
+import org.apache.axis.om.OMAttribute;
+import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.impl.llom.OMAttributeImpl;
+import org.apache.axis.om.impl.llom.OMTextImpl;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.attachments.ByteArrayDataSource;
+
+import javax.xml.namespace.QName;
+import javax.activation.DataHandler;
+
+/*
+ * Copyright 2004,2005 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.
+ *
+ * author : Eran Chinthaka (chinthaka@apache.org)
+ */
+
+public class HTTPTransportUtilTest extends TestCase{
+ private HTTPTransportUtils httpTransportUtils;
+ private SOAPFactory factory;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ httpTransportUtils = new HTTPTransportUtils();
+ factory = OMAbstractFactory.getSOAP11Factory();
+ }
+
+ public void testOptimizedEnvelope(){
+ SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();
+
+ OMElement element = factory.createOMElement(new QName("MyFirstBodyElement"), soapEnvelope.getBody());
+ OMElement element11 = factory.createOMElement(new QName("MyFirstBodyElement"), element);
+ OMText optimizedText = factory.createText("Hi", "text/plain", true);
+ element11.addChild(optimizedText);
+ assertTrue("optmization check has not performed correctly in SOAPEnvelope", httpTransportUtils.checkEnvelopeForOptimise(soapEnvelope));
+ }
+
+ public void testNonOptimizedEnvelope(){
+ SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();
+
+ OMElement element = factory.createOMElement(new QName("MyFirstBodyElement"), soapEnvelope.getBody());
+ OMElement element11 = factory.createOMElement(new QName("MyFirstBodyElement"), element);
+ OMText optimizedText = factory.createText("Hi", "text/plain", false);
+ element11.addChild(optimizedText);
+ assertFalse("optmization check has not performed correctly in SOAPEnvelope", httpTransportUtils.checkEnvelopeForOptimise(soapEnvelope));
+ }
+
+
+
+}
Modified: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java (original)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/EchoRawMTOMTest.java Wed Jun 29 00:01:26 2005
@@ -95,7 +95,7 @@
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);
+ OMTextImpl textData = new OMTextImpl(dataHandler, false);
data.addChild(textData);
return data;
}
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/OMFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/OMFactory.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/OMFactory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/OMFactory.java Wed Jun 29 00:01:26 2005
@@ -16,6 +16,7 @@
package org.apache.axis.om;
import javax.xml.namespace.QName;
+import javax.activation.DataHandler;
/**
* Class OMFactory
@@ -86,6 +87,10 @@
* @return
*/
public OMText createText(String s);
+ public OMText createText(String s, String mimeType, boolean optimize);
+ public OMText createText(DataHandler dataHandler, boolean optimize);
+ public OMText createText(OMElement parent, String s, String mimeType,
+ boolean optimize);
public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value);
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMTextImpl.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMTextImpl.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMTextImpl.java Wed Jun 29 00:01:26 2005
@@ -114,6 +114,8 @@
if (this.contentID == null && optimize==true) {
createContentID();
}
+ done = true;
+
}
/**
@@ -131,6 +133,8 @@
if (this.contentID == null && optimize==true) {
createContentID();
}
+ done = true;
+
}
/**
@@ -144,6 +148,8 @@
if (this.contentID == null) {
createContentID();
}
+ done = true;
+
}
/**
@@ -158,6 +164,8 @@
if (this.contentID == null && optimize==true) {
createContentID();
}
+ done = true;
+
}
/**
@@ -175,6 +183,8 @@
this.optimize = true;
this.isBinary = true;
this.builder = builder;
+ done = true;
+
}
/**
Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/factory/OMLinkedListImplFactory.java Wed Jun 29 00:01:26 2005
@@ -22,6 +22,7 @@
import org.apache.axis.om.impl.llom.OMAttributeImpl;
import javax.xml.namespace.QName;
+import javax.activation.DataHandler;
/**
* Class OMLinkedListImplFactory
@@ -122,6 +123,18 @@
OMTextImpl textNode = new OMTextImpl(s);
;
return textNode;
+ }
+
+ public OMText createText(String s, String mimeType, boolean optimize) {
+ return new OMTextImpl(s, mimeType, optimize);
+ }
+
+ public OMText createText(DataHandler dataHandler, boolean optimize) {
+ return new OMTextImpl(dataHandler, optimize);
+ }
+
+ public OMText createText(OMElement parent, String s, String mimeType, boolean optimize) {
+ return new OMTextImpl(parent, s, mimeType, optimize);
}
public OMAttribute createOMAttribute(String localName, OMNamespace ns, String value) {
Modified: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/attachments/ImageSampleTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/attachments/ImageSampleTest.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/attachments/ImageSampleTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/attachments/ImageSampleTest.java Wed Jun 29 00:01:26 2005
@@ -102,7 +102,7 @@
ImageDataSource dataSource = new ImageDataSource("WaterLilies.jpg",
expectedImage);
expectedDH = new DataHandler(dataSource);
- OMText binaryNode = new OMTextImpl(expectedDH);
+ OMText binaryNode = new OMTextImpl(expectedDH, false);
envelope.addChild(body);
body.addChild(data);
Modified: webservices/axis/trunk/java/modules/xml/test/org/apache/axis/om/impl/llom/OMOutputTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/test/org/apache/axis/om/impl/llom/OMOutputTest.java?rev=202323&r1=202322&r2=202323&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/test/org/apache/axis/om/impl/llom/OMOutputTest.java (original)
+++ webservices/axis/trunk/java/modules/xml/test/org/apache/axis/om/impl/llom/OMOutputTest.java Wed Jun 29 00:01:26 2005
@@ -82,7 +82,7 @@
byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
98 };
dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
- OMTextImpl textData = new OMTextImpl(dataHandler);
+ OMTextImpl textData = new OMTextImpl(dataHandler, false);
envelope.addChild(body);
body.addChild(data);