You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/12/17 22:34:13 UTC
svn commit: r1818518 [13/30] - in /axis/axis2/java/core/branches/AXIS2-4091:
./ apidocs/ databinding-tests/ etc/ legal/ modules/adb-codegen/
modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/ modu...
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java Sun Dec 17 22:34:08 2017
@@ -21,7 +21,6 @@ package org.apache.axis2.jaxws.message.i
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.soap.RolePlayer;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
@@ -771,12 +770,8 @@ public abstract class XMLPartBase implem
OMElement om = getContentAsOMElement();
if (om !=null) {
OMXMLParserWrapper builder = om.getBuilder();
- if (builder instanceof StAXBuilder) {
- StAXBuilder staxBuilder = (StAXBuilder) builder;
- staxBuilder.releaseParserOnClose(true);
- if (!staxBuilder.isClosed()) {
- staxBuilder.close();
- }
+ if (builder != null) {
+ builder.close();
}
}
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartFactoryImpl.java Sun Dec 17 22:34:08 2017
@@ -20,8 +20,9 @@
package org.apache.axis2.jaxws.message.impl;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axis2.jaxws.message.Protocol;
import org.apache.axis2.jaxws.message.XMLPart;
import org.apache.axis2.jaxws.message.factory.XMLPartFactory;
@@ -43,8 +44,7 @@ public class XMLPartFactoryImpl implemen
*/
public XMLPart createFrom(XMLStreamReader reader, Protocol protocol)
throws XMLStreamException, WebServiceException {
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader,
- null); // Pass null has the version to trigger autodetection
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader);
SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
return createFrom(omEnvelope, protocol);
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java Sun Dec 17 22:34:08 2017
@@ -20,11 +20,9 @@
package org.apache.axis2.jaxws.message.impl;
import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.OMContainerEx;
import org.apache.axiom.soap.RolePlayer;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
@@ -46,13 +44,11 @@ import org.apache.axis2.jaxws.message.fa
import org.apache.axis2.jaxws.message.util.Reader2Writer;
import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
-import org.apache.axis2.jaxws.utility.JavaUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
@@ -187,15 +183,7 @@ class XMLSpineImpl implements XMLSpine {
}
public XMLStreamReader getXMLStreamReader(boolean consume) throws WebServiceException {
- if (consume) {
- if (root.getBuilder() != null && !root.getBuilder().isCompleted()) {
- return root.getXMLStreamReaderWithoutCaching();
- } else {
- return root.getXMLStreamReader();
- }
- } else {
- return root.getXMLStreamReader();
- }
+ return root.getXMLStreamReader(!consume);
}
/* (non-Javadoc)
@@ -215,7 +203,7 @@ class XMLSpineImpl implements XMLSpine {
SOAPFaultDetail detail = root.getBody().getFault().getDetail();
for (int i = 0; i < numDetailBlocks; i++) {
OMElement om = this._getChildOMElement(detail, i);
- blocks[i] = this._getBlockFromOMElement(om, null, obf, false);
+ blocks[i] = this._getBlockFromOMElement(om, null, obf);
}
}
@@ -312,7 +300,7 @@ class XMLSpineImpl implements XMLSpine {
if (log.isDebugEnabled()) {
log.debug("getBodyBlock: Found omElement " + omElement.getQName());
}
- return this._getBlockFromOMElement(omElement, context, blockFactory, false);
+ return this._getBlockFromOMElement(omElement, context, blockFactory);
}
/* (non-Javadoc)
@@ -345,7 +333,7 @@ class XMLSpineImpl implements XMLSpine {
if (log.isDebugEnabled()) {
log.debug("getBodyBlock: Found omElement " + omElement.getQName());
}
- return this._getBlockFromOMElement(omElement, context, blockFactory, true);
+ return this._getBlockFromOMElement(omElement, context, blockFactory);
}
public void setBodyBlock(int index, Block block) throws WebServiceException {
@@ -442,7 +430,7 @@ class XMLSpineImpl implements XMLSpine {
if (om == null) {
return null;
}
- return this._getBlockFromOMElement(om, context, blockFactory, false);
+ return this._getBlockFromOMElement(om, context, blockFactory);
}
public List<Block> getHeaderBlocks(String namespace,
@@ -474,7 +462,7 @@ class XMLSpineImpl implements XMLSpine {
// _getBlockFromOMElement may replace the current element; move the iterator to the
// next element to avoid ConcurrentModificationException
it.hasNext();
- Block block = _getBlockFromOMElement(om, context, blockFactory, false);
+ Block block = _getBlockFromOMElement(om, context, blockFactory);
blocks.add(block);
}
}
@@ -568,8 +556,7 @@ class XMLSpineImpl implements XMLSpine {
}
}
- private Block _getBlockFromOMElement(OMElement om, Object context, BlockFactory blockFactory,
- boolean setComplete) throws WebServiceException {
+ private Block _getBlockFromOMElement(OMElement om, Object context, BlockFactory blockFactory) throws WebServiceException {
try {
QName qName = om.getQName();
OMNamespace ns = om.getNamespace();
@@ -613,48 +600,6 @@ class XMLSpineImpl implements XMLSpine {
OMElement newOM = _createOMElementFromBlock(qName.getLocalPart(), ns, block, soapFactory,
(om.getParent() instanceof SOAPHeader));
om.insertSiblingBefore(newOM);
-
- // We want to set the om element and its parents to complete to
- // shutdown the parsing.
- if (setComplete) {
-
- // Get the root of the document
- OMElement root = om;
- while(root.getParent() instanceof OMElement) {
- root = (OMElement) root.getParent();
- }
-
- try {
- if (!root.isComplete() && root.getBuilder() != null &&
- !root.getBuilder().isCompleted()) {
- // Forward the parser to the end so it will close
- while (root.getBuilder().next() != XMLStreamConstants.END_DOCUMENT) {
- //do nothing
- }
- }
- } catch (Exception e) {
- // Log and continue
- if (log.isDebugEnabled()) {
- log.debug("Builder next error:" + e.getMessage());
- log.trace(JavaUtils.stackToString(e));
- }
-
- }
-
-
- OMContainer o = om;
- while (o != null && o instanceof OMContainerEx) {
- ((OMContainerEx)o).setComplete(true);
- if ((o instanceof OMNode) &&
- (((OMNode)o).getParent()) instanceof OMContainer) {
- o = ((OMNode)o).getParent();
- } else {
- o = null;
- }
- }
- }
-
-
om.detach();
}
return block;
@@ -795,9 +740,9 @@ class XMLSpineImpl implements XMLSpine {
return null;
}
QName qName = new QName(namespace, localPart);
- Iterator it = om.getChildrenWithName(qName);
+ Iterator<OMElement> it = om.getChildrenWithName(qName);
if (it != null && it.hasNext()) {
- return (OMElement)it.next();
+ return it.next();
}
return null;
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader2Writer.java Sun Dec 17 22:34:08 2017
@@ -21,8 +21,8 @@ package org.apache.axis2.jaxws.message.u
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.jaxws.utility.JavaUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFac
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import java.io.StringWriter;
import java.util.Iterator;
/**
@@ -71,7 +70,7 @@ public class Reader2Writer {
public void outputTo(XMLStreamWriter writer) throws XMLStreamException {
// Using OM to convert the reader to a writer. This seems to be
// the safest way to make the conversion, and it promotes code re-use.
- StAXOMBuilder builder = new StAXOMBuilder(reader);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader);
OMDocument omDocument = builder.getDocument();
Iterator it = omDocument.getChildren();
while (it.hasNext()) {
@@ -86,23 +85,4 @@ public class Reader2Writer {
reader.close();
}
}
-
- /**
- * Utility method to write the reader contents to a String
- * @return String
- */
- public String getAsString() throws XMLStreamException {
- StringWriter sw = new StringWriter();
- XMLStreamWriter writer = StAXUtils.createXMLStreamWriter(sw);
-
- // Write the reader to the writer
- outputTo(writer);
-
- // Flush the writer and get the String
- writer.flush();
- sw.flush();
- String str = sw.toString();
- writer.close();
- return str;
- }
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/ResettableReader.java Sun Dec 17 22:34:08 2017
@@ -20,7 +20,8 @@
package org.apache.axis2.jaxws.message.util;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import javax.xml.stream.XMLStreamReader;
@@ -41,7 +42,7 @@ public class ResettableReader extends Re
*/
public ResettableReader(XMLStreamReader reader) {
super(reader, true);
- StAXOMBuilder builder = new StAXOMBuilder(reader);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader);
omElement = builder.getDocumentElement();
reset();
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/XMLFaultUtils.java Sun Dec 17 22:34:08 2017
@@ -22,6 +22,7 @@ package org.apache.axis2.jaxws.message.u
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPBody;
@@ -36,7 +37,7 @@ import org.apache.axiom.soap.SOAPFaultRo
import org.apache.axiom.soap.SOAPFaultSubCode;
import org.apache.axiom.soap.SOAPFaultText;
import org.apache.axiom.soap.SOAPFaultValue;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
@@ -151,13 +152,7 @@ public class XMLFaultUtils {
SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
SOAPFaultCode soapCode = soapFault.getCode();
- QName codeQName = null;
- if (isSoap11) {
- codeQName = soapCode.getTextAsQName();
- } else {
- codeQName = soapCode.getValue().getTextAsQName();
- }
- XMLFaultCode code = XMLFaultCode.fromQName(codeQName);
+ XMLFaultCode code = XMLFaultCode.fromQName(soapCode.getValueAsQName());
// Get the primary reason text
// TODO what if this fails
@@ -187,9 +182,7 @@ public class XMLFaultUtils {
// Walk the nested sub codes and collect the qnames
while (soapSubCode != null) {
- SOAPFaultValue soapSubCodeValue = soapSubCode.getValue();
- QName qName = soapSubCodeValue.getTextAsQName();
- list.add(qName);
+ list.add(soapSubCode.getValueAsQName());
soapSubCode = soapSubCode.getSubCode();
}
@@ -366,7 +359,7 @@ public class XMLFaultUtils {
SOAPEnvelope dummyEnv = (SOAPEnvelope) m.getAsOMElement();
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
SOAPEnvelope newEnv = (SOAPEnvelope) builder.getDocumentElement();
SOAPBody body = newEnv.getBody();
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java Sun Dec 17 22:34:08 2017
@@ -20,18 +20,18 @@
package org.apache.axis2.jaxws.message.util.impl;
import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.util.SAAJConverter;
-import org.apache.axis2.jaxws.message.util.SOAPElementReader;
import org.apache.axis2.jaxws.utility.JavaUtils;
import org.apache.axis2.jaxws.utility.SAAJFactory;
import org.apache.commons.logging.Log;
@@ -136,15 +136,15 @@ public class SAAJConverterImpl implement
// Before we do the conversion, we have to fix the QNames for fault elements
_fixFaultElements(saajEnvelope);
- // Get a XMLStreamReader backed by a SOAPElement tree
- XMLStreamReader reader = new SOAPElementReader(saajEnvelope);
-
- // Get a SOAP OM Builder. Passing null causes the version to be automatically triggered
- StAXSOAPModelBuilder builder = null;
- if (attachments == null) {
- builder = new StAXSOAPModelBuilder(reader, null);
+ SOAPModelBuilder builder;
+ if (attachments != null) {
+ builder = OMXMLBuilderFactory.createSOAPModelBuilder(
+ OMAbstractFactory.getMetaFactory(),
+ new DOMSource(saajEnvelope),
+ attachments);
} else {
- builder = new MTOMStAXSOAPModelBuilder(reader, attachments, null);
+ // Get a SOAP OM Builder.
+ builder = OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(saajEnvelope));
}
// Create and return the OM Envelope
org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
@@ -184,8 +184,8 @@ public class SAAJConverterImpl implement
} catch (XMLStreamException e) {
throw ExceptionFactory.makeWebServiceException(e);
}
- // Get a SOAP OM Builder. Passing null causes the version to be automatically triggered
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);
+ // Get a SOAP OM Builder.
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader);
// Create and return the OM Envelope
return builder.getSOAPEnvelope();
}
@@ -207,10 +207,8 @@ public class SAAJConverterImpl implement
log.debug("The conversion occurs due to " + JavaUtils.stackToString());
}
- // Get a XMLStreamReader backed by a SOAPElement tree
- XMLStreamReader reader = new SOAPElementReader(soapElement);
// Get a OM Builder.
- StAXOMBuilder builder = new StAXOMBuilder(reader);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new DOMSource(soapElement));
// Create and return the Element
OMElement om = builder.getDocumentElement();
// TODO The following statement expands the OM tree. This is
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/registry/FactoryRegistry.java Sun Dec 17 22:34:08 2017
@@ -36,7 +36,6 @@ import org.apache.axis2.jaxws.handler.fa
import org.apache.axis2.jaxws.handler.lifecycle.factory.HandlerLifecycleManagerFactory;
import org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockFactoryImpl;
import org.apache.axis2.jaxws.message.databinding.impl.OMBlockFactoryImpl;
-import org.apache.axis2.jaxws.message.databinding.impl.ParsedEntityReaderImpl;
import org.apache.axis2.jaxws.message.databinding.impl.SOAPEnvelopeBlockFactoryImpl;
import org.apache.axis2.jaxws.message.databinding.impl.SourceBlockFactoryImpl;
import org.apache.axis2.jaxws.message.databinding.impl.XMLStringBlockFactoryImpl;
@@ -45,7 +44,6 @@ import org.apache.axis2.jaxws.message.fa
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.message.factory.OMBlockFactory;
-import org.apache.axis2.jaxws.message.factory.ParsedEntityReaderFactory;
import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory;
import org.apache.axis2.jaxws.message.factory.SOAPEnvelopeBlockFactory;
import org.apache.axis2.jaxws.message.factory.SourceBlockFactory;
@@ -126,7 +124,6 @@ public class FactoryRegistry {
table.put(InvocationControllerFactory.class, new InvocationControllerFactoryImpl());
table.put(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
table.put(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
- table.put(ParsedEntityReaderFactory.class, new ParsedEntityReaderFactory());
// register the implementation responsible for both WebServiceContext
// injection and the updating of the WebServiceContext instances that
// have already been injected, we will register these by two different
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/runtime/description/marshal/impl/PackageSetBuilder.java Sun Dec 17 22:34:08 2017
@@ -880,7 +880,7 @@ public class PackageSetBuilder {
String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
String wsdlLocationPath = new File(baseDir +File.separator+ wsdlLocation).getAbsolutePath();
File file = new File(wsdlLocationPath);
- URL url = file.toURL();
+ URL url = file.toURI().toURL();
if(log.isDebugEnabled()){
log.debug("Reading WSDL from URL:" +url.toString());
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Sun Dec 17 22:34:08 2017
@@ -21,7 +21,6 @@ package org.apache.axis2.jaxws.server.di
import org.apache.axis2.Constants;
import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.context.listener.ContextListenerUtils;
import org.apache.axis2.jaxws.context.utils.ContextUtils;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.core.util.MessageContextUtils;
@@ -307,8 +306,6 @@ public class ProviderDispatcher extends
}
}
if (providerType.equals(OMElement.class)) {
- //Register the ContextListener for performance.
- ContextListenerUtils.registerProviderOMListener(request);
// TODO avoid call to message.getValue due to
// current unnecessary message transformation in
// message.getValue. Once message.getValue is fixed,
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Sun Dec 17 22:34:08 2017
@@ -52,7 +52,6 @@ import org.apache.axis2.jaxws.client.Pro
import org.apache.axis2.jaxws.client.dispatch.JAXBDispatch;
import org.apache.axis2.jaxws.client.dispatch.XMLDispatch;
import org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler;
-import org.apache.axis2.jaxws.context.listener.ProviderOMContextListener;
import org.apache.axis2.jaxws.description.DescriptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
@@ -335,13 +334,6 @@ public class ServiceDelegate extends jav
if (serviceClient == null)
serviceClient = getServiceClient(endpointDesc.getPortQName());
-
- if(type == OMElement.class) {
- if (log.isDebugEnabled()) {
- log.debug("This a Dispatch<OMElement>. The custom builder is installed.");
- }
- ProviderOMContextListener.create(serviceClient.getServiceContext());
- }
dispatch.setServiceClient(serviceClient);
dispatch.setType(type);
@@ -445,12 +437,6 @@ public class ServiceDelegate extends jav
if (serviceClient == null)
serviceClient = getServiceClient(portName);
- if(type == OMElement.class) {
- if (log.isDebugEnabled()) {
- log.debug("This a Dispatch<OMElement>. The custom builder is installed.");
- }
- ProviderOMContextListener.create(serviceClient.getServiceContext());
- }
dispatch.setServiceClient(serviceClient);
dispatch.setType(type);
return dispatch;
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/ClassUtils.java Sun Dec 17 22:34:08 2017
@@ -316,33 +316,38 @@ public class ClassUtils {
*
*/
public static Set<Class> getClasses(Type type, Set<Class> list) {
- if (list == null) {
- list = new HashSet<Class>();
- }
- try {
- if (type instanceof Class) {
- list.add( (Class)type);
- }
- if (type instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) type;
- getClasses(pt.getRawType(), list);
- Type types[] = pt.getActualTypeArguments();
- if (types != null) {
- for (int i=0; i<types.length; i++) {
- getClasses(types[i], list);
- }
- }
- }
- if (type instanceof GenericArrayType) {
- GenericArrayType gat = (GenericArrayType) type;
- getClasses(gat.getGenericComponentType(), list);
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Problem occurred in getClasses. Processing continues " + t);
- }
- }
- return list;
+ if (list == null) {
+ list = new HashSet<Class>();
+ }
+ try {
+ if (type instanceof Class) {
+ Class<?> clazz = (Class<?>)type;
+ if (clazz.isArray()) {
+ getClasses(clazz.getComponentType(), list);
+ } else {
+ list.add(clazz);
+ }
+ }
+ if (type instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) type;
+ getClasses(pt.getRawType(), list);
+ Type types[] = pt.getActualTypeArguments();
+ if (types != null) {
+ for (int i=0; i<types.length; i++) {
+ getClasses(types[i], list);
+ }
+ }
+ }
+ if (type instanceof GenericArrayType) {
+ GenericArrayType gat = (GenericArrayType) type;
+ getClasses(gat.getGenericComponentType(), list);
+ }
+ } catch (Throwable t) {
+ if (log.isDebugEnabled()) {
+ log.debug("Problem occurred in getClasses. Processing continues " + t);
+ }
+ }
+ return list;
}
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/DataSourceFormatter.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/DataSourceFormatter.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/DataSourceFormatter.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/src/org/apache/axis2/jaxws/utility/DataSourceFormatter.java Sun Dec 17 22:34:08 2017
@@ -59,21 +59,21 @@ public class DataSourceFormatter impleme
if (log.isDebugEnabled()) {
log.debug("start writeTo()");
}
+ OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
+ DataSource busObject;
+ try {
+ busObject = (DataSource)((DataSourceBlock)((OMSourcedElement) omElement).getDataSource()).getBusinessObject(true);
+ } catch (XMLStreamException e) {
+ throw AxisFault.makeFault(e);
+ }
+ DataHandler dataHandler = new DataHandler(busObject);
if (attachments != null && !attachments.isEmpty()) {
- OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
- DataSource busObject;
- try {
- busObject = (DataSource)((DataSourceBlock)((OMSourcedElement) omElement).getDataSource()).getBusinessObject(true);
- } catch (XMLStreamException e) {
- throw AxisFault.makeFault(e);
- }
OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format);
- DataHandler rootDataHandler = new DataHandler(busObject);
- if (!rootDataHandler.getContentType().equals(contentType)) {
- rootDataHandler = new WrappedDataHandler(rootDataHandler, contentType);
+ if (!dataHandler.getContentType().equals(contentType)) {
+ dataHandler = new WrappedDataHandler(dataHandler, contentType);
}
try {
- mpw.writePart(rootDataHandler, format.getRootContentId());
+ mpw.writePart(dataHandler, format.getRootContentId());
for (String cid : attachments.keySet()) {
mpw.writePart(attachments.get(cid), cid);
}
@@ -82,24 +82,13 @@ public class DataSourceFormatter impleme
} catch (IOException ex) {
throw AxisFault.makeFault(ex);
}
- } else {
- OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
- if (omElement != null) {
- try {
- if (preserve) {
- omElement.serialize(outputStream, format);
- } else {
- omElement.serializeAndConsume(outputStream, format);
- }
- } catch (XMLStreamException e) {
- throw AxisFault.makeFault(e);
- }
- }
- try {
- outputStream.flush();
- } catch (IOException e) {
- throw AxisFault.makeFault(e);
- }
+ } else {
+ try {
+ dataHandler.writeTo(outputStream);
+ outputStream.flush();
+ } catch (IOException e) {
+ throw AxisFault.makeFault(e);
+ }
}
} finally {
if (log.isDebugEnabled()) {
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/axis2.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/axis2.xml?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/axis2.xml (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/axis2.xml Sun Dec 17 22:34:08 2017
@@ -140,12 +140,12 @@
<transportSender name="local"
class="org.apache.axis2.transport.local.LocalTransportSender"/>
<transportSender name="http"
- class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender">
<parameter name="PROTOCOL">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>
<transportSender name="https"
- class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender">
<parameter name="PROTOCOL">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/log4j.properties
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/log4j.properties?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/log4j.properties (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test-resources/log4j.properties Sun Dec 17 22:34:08 2017
@@ -35,7 +35,6 @@ log4j.rootCategory=ERROR, CONSOLE
# Set the enterprise logger priority to FATAL
log4j.logger.org.apache.axis2.enterprise=FATAL
-log4j.logger.de.hunsicker.jalopy.io=FATAL
log4j.logger.httpclient.wire.header=FATAL
log4j.logger.org.apache.commons.httpclient=FATAL
@@ -56,4 +55,4 @@ log4j.appender.SMALL=org.apache.log4j.Fi
log4j.appender.SMALL.File=axis2.small.log
log4j.appender.SMALL.Append=true
log4j.appender.SMALL.layout=org.apache.log4j.PatternLayout
-log4j.appender.SMALL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
\ No newline at end of file
+log4j.appender.SMALL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderDisableStreamingTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderDisableStreamingTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderDisableStreamingTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/datasource/jaxb/JAXBCustomBuilderDisableStreamingTests.java Sun Dec 17 22:34:08 2017
@@ -18,15 +18,14 @@
*/
package org.apache.axis2.datasource.jaxb;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+
+import org.apache.axiom.soap.SOAPBody;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.jaxws.Constants;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.Location;
-import javax.xml.stream.XMLStreamException;
-
import junit.framework.TestCase;
/**
@@ -42,13 +41,7 @@ public class JAXBCustomBuilderDisableStr
// Disable the JAXB Payload streaming
msgCtx.setProperty(Constants.JAXWS_ENABLE_JAXB_PAYLOAD_STREAMING, new Boolean(false));
jaxbDSC.setMessageContext(msgCtx);
- try {
- assertNull(jaxbCB.create("ns", "lp", null, new MockXMLStreamReader(), null));
- } catch (Exception e) {
- // Since we didn't set up the JAXBDSContext fully, if the disabling of it didn't
- // work, then we'll get some sort of exception.
- fail("JAXB Payload streaming was not disabled");
- }
+ assertThat(jaxbCB.accepts(mock(SOAPBody.class), 3, "ns", "lp")).isFalse();
}
public void testDisableJAXBPayloadStreamingWithHighFidelity() {
@@ -59,13 +52,7 @@ public class JAXBCustomBuilderDisableStr
// Disable the JAXB Payload streaming
msgCtx.setProperty(Constants.JAXWS_PAYLOAD_HIGH_FIDELITY, new Boolean(true));
jaxbDSC.setMessageContext(msgCtx);
- try {
- assertNull(jaxbCB.create("ns", "lp", null, new MockXMLStreamReader(), null));
- } catch (Exception e) {
- // Since we didn't set up the JAXBDSContext fully, if the disabling of it didn't
- // work, then we'll get some sort of exception.
- fail("JAXB Payload streaming was not disabled");
- }
+ assertThat(jaxbCB.accepts(mock(SOAPBody.class), 3, "ns", "lp")).isFalse();
}
public void testDisableJAXBPayloadStreamingWithHighFidelityParameter() throws Exception {
@@ -78,13 +65,7 @@ public class JAXBCustomBuilderDisableStr
service.addParameter(Constants.JAXWS_PAYLOAD_HIGH_FIDELITY, "true");
jaxbDSC.setMessageContext(msgCtx);
- try {
- assertNull(jaxbCB.create("ns", "lp", null, new MockXMLStreamReader(), null));
- } catch (Exception e) {
- // Since we didn't set up the JAXBDSContext fully, if the disabling of it didn't
- // work, then we'll get some sort of exception.
- fail("JAXB Payload streaming was not disabled");
- }
+ assertThat(jaxbCB.accepts(mock(SOAPBody.class), 3, "ns", "lp")).isFalse();
}
public void testDefaultJAXBPayloadStreaming() {
@@ -95,197 +76,6 @@ public class JAXBCustomBuilderDisableStr
// Do NOT Disable the JAXB Payload streaming; the default should be ON
// msgCtx.setProperty(Constants.JAXWS_ENABLE_JAXB_PAYLOAD_STREAMING, new Boolean(false));
jaxbDSC.setMessageContext(msgCtx);
- try {
- jaxbCB.create("ns", "lp", null, new MockXMLStreamReader(), null);
- fail("JAXB Payload streaming default was not enabled");
- } catch (Exception e) {
- // Expected code path
- // Since we didn't set up the JAXBDSContext fully, if the disabling of it didn't
- // work, then we'll get some sort of exception.
- }
- }
-
-
- class MockXMLStreamReader implements javax.xml.stream.XMLStreamReader {
-
- public void close() throws XMLStreamException {
- }
-
- public int getAttributeCount() {
- return 0;
- }
-
- public String getAttributeLocalName(int i) {
- return null;
- }
-
- public QName getAttributeName(int i) {
- return null;
- }
-
- public String getAttributeNamespace(int i) {
- return null;
- }
-
- public String getAttributePrefix(int i) {
- return null;
- }
-
- public String getAttributeType(int i) {
- return null;
- }
-
- public String getAttributeValue(int i) {
- return null;
- }
-
- public String getAttributeValue(String s, String s1) {
- return null;
- }
-
- public String getCharacterEncodingScheme() {
- return null;
- }
-
- public String getElementText() throws XMLStreamException {
- return null;
- }
-
- public String getEncoding() {
- return null;
- }
-
- public int getEventType() {
- return 0;
- }
-
- public String getLocalName() {
- return null;
- }
-
- public Location getLocation() {
- return null;
- }
-
- public QName getName() {
- return null;
- }
-
- public NamespaceContext getNamespaceContext() {
- return null;
- }
-
- public int getNamespaceCount() {
- return 0;
- }
-
- public String getNamespacePrefix(int i) {
- return null;
- }
-
- public String getNamespaceURI() {
- return null;
- }
-
- public String getNamespaceURI(int i) {
- return null;
- }
-
- public String getNamespaceURI(String s) {
- return null;
- }
-
- public String getPIData() {
- return null;
- }
-
- public String getPITarget() {
- return null;
- }
-
- public String getPrefix() {
- return null;
- }
-
- public Object getProperty(String s) throws IllegalArgumentException {
- return null;
- }
-
- public String getText() {
- return null;
- }
-
- public char[] getTextCharacters() {
- return null;
- }
-
- public int getTextCharacters(int i, char[] ac, int j, int k) throws XMLStreamException {
- return 0;
- }
-
- public int getTextLength() {
- return 0;
- }
-
- public int getTextStart() {
- return 0;
- }
-
- public String getVersion() {
- return null;
- }
-
- public boolean hasName() {
- return false;
- }
-
- public boolean hasNext() throws XMLStreamException {
- return false;
- }
-
- public boolean hasText() {
- return false;
- }
-
- public boolean isAttributeSpecified(int i) {
- return false;
- }
-
- public boolean isCharacters() {
- return false;
- }
-
- public boolean isEndElement() {
- return false;
- }
-
- public boolean isStandalone() {
- return false;
- }
-
- public boolean isStartElement() {
- return false;
- }
-
- public boolean isWhiteSpace() {
- return false;
- }
-
- public int next() throws XMLStreamException {
- return 0;
- }
-
- public int nextTag() throws XMLStreamException {
- return 0;
- }
-
- public void require(int i, String s, String s1) throws XMLStreamException {
-
- }
-
- public boolean standaloneSet() {
- return false;
- }
-
+ assertThat(jaxbCB.accepts(mock(SOAPBody.class), 3, "ns", "lp")).isTrue();
}
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtilsTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtilsTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtilsTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtilsTests.java Sun Dec 17 22:34:08 2017
@@ -22,7 +22,8 @@ package org.apache.axis2.jaxws.addressin
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.addressing.AddressingConstants.Final;
import org.apache.axis2.addressing.AddressingConstants.Submission;
import org.apache.axis2.addressing.EndpointReference;
@@ -84,7 +85,7 @@ public class EndpointReferenceUtilsTests
public void test200508ConversionStartingFromAxis2() throws Exception {
XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(EPR200508));
- StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(parser);
OMElement omElement = builder.getDocumentElement();
EndpointReference axis2EPR =
@@ -125,7 +126,7 @@ public class EndpointReferenceUtilsTests
public void test200408ConversionStartingFromAxis2() throws Exception {
XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(EPR200408));
- StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(parser);
OMElement omElement = builder.getDocumentElement();
EndpointReference axis2EPR =
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/ReferenceParameterListTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/ReferenceParameterListTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/ReferenceParameterListTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/addressing/util/ReferenceParameterListTests.java Sun Dec 17 22:34:08 2017
@@ -20,10 +20,12 @@
package org.apache.axis2.jaxws.addressing.util;
import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.soap.SOAPModelBuilder;
import org.w3c.dom.Element;
import javax.xml.stream.XMLStreamReader;
@@ -41,7 +43,7 @@ public class ReferenceParameterListTests
public void setUp() throws Exception {
File resourceFile = new File(testResourceDir, resourceFileName);
XMLStreamReader parser = StAXUtils.createXMLStreamReader(new FileReader(resourceFile));
- StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser, null);
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(parser);
header = ((SOAPEnvelope)builder.getDocumentElement()).getHeader();
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/attachments/MTOMSerializationTests.java Sun Dec 17 22:34:08 2017
@@ -29,7 +29,6 @@ import org.apache.axiom.om.OMText;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.Protocol;
@@ -43,12 +42,18 @@ import org.apache.axis2.jaxws.unitTest.T
import org.test.mtom.ImageDepot;
import org.test.mtom.ObjectFactory;
import org.test.mtom.SendImage;
+import org.w3c.dom.Node;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.ImageInputStream;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPMessage;
+
+import static com.google.common.truth.Truth.assertThat;
+
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -104,7 +109,7 @@ public class MTOMSerializationTests exte
OMElement payload = createPayload();
- SOAPFactory factory = new SOAP11Factory();
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope env = factory.createSOAPEnvelope();
SOAPBody body = factory.createSOAPBody(env);
@@ -198,7 +203,13 @@ public class MTOMSerializationTests exte
msg.setMTOMEnabled(true);
// Convert message to SAAJ to simulate an outbound handler
- msg.getAsSOAPMessage();
+ SOAPMessage saajMessage = msg.getAsSOAPMessage();
+
+ // SAAJ is expected to have an XOP encoded representation of the message
+ SOAPElement imageData = (SOAPElement)saajMessage.getSOAPBody().getElementsByTagNameNS("*", "imageData").item(0);
+ Node child = imageData.getFirstChild();
+ assertThat(child.getNodeType()).isEqualTo(Node.ELEMENT_NODE);
+ assertThat(child.getLocalName()).isEqualTo("Include");
// Now convert it back to AXIOM
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/MultiRedirectionCatalogTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/MultiRedirectionCatalogTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/MultiRedirectionCatalogTest.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/MultiRedirectionCatalogTest.java Sun Dec 17 22:34:08 2017
@@ -135,7 +135,7 @@ public class MultiRedirectionCatalogTest
fail();
}
File file = new File(wsdlLocation);
- url = file.toURL();
+ url = file.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
fail();
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/XMLCatalogTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/XMLCatalogTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/XMLCatalogTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/catalog/XMLCatalogTests.java Sun Dec 17 22:34:08 2017
@@ -51,10 +51,10 @@ public class XMLCatalogTests extends Tes
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(file.toURL().toString());
+ parse(file.toURI().toURL().toString());
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(doc,file.toURL().toString(),null);
+ XmlSchema schema = schemaCol.read(doc,file.toURI().toURL().toString(),null);
assertNotNull(schema);
assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct")));
@@ -72,10 +72,10 @@ public class XMLCatalogTests extends Tes
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(file.toURL().toString());
+ parse(file.toURI().toURL().toString());
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(doc,file.toURL().toString(),null);
+ XmlSchema schema = schemaCol.read(doc,file.toURI().toURL().toString(),null);
assertNotNull(schema);
assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct")));
@@ -96,11 +96,11 @@ public class XMLCatalogTests extends Tes
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(file.toURL().toString());
+ parse(file.toURI().toURL().toString());
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
schemaCol.setSchemaResolver(new CatalogURIResolver(catalogManager));
- XmlSchema schema = schemaCol.read(doc,file.toURL().toString(),null);
+ XmlSchema schema = schemaCol.read(doc,file.toURI().toURL().toString(),null);
assertNotNull(schema);
assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2","SOAPStruct")));
@@ -123,7 +123,7 @@ public class XMLCatalogTests extends Tes
fail();
}
File file = new File(wsdlLocation);
- url = file.toURL();
+ url = file.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
fail();
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ClientConfigTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ClientConfigTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ClientConfigTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ClientConfigTests.java Sun Dec 17 22:34:08 2017
@@ -50,7 +50,7 @@ public class ClientConfigTests extends T
e.printStackTrace();
}
File file = new File(wsdlLocation);
- url = file.toURL();
+ url = file.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/client/ReleaseServiceTests.java Sun Dec 17 22:34:08 2017
@@ -966,7 +966,7 @@ public class ReleaseServiceTests extends
String wsdlLocation = getWsdlLocation(wsdlFileName);
try {
File file = new File(wsdlLocation);
- url = file.toURL();
+ url = file.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
fail("Exception converting WSDL file to URL: " + e.toString());
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/DescriptionTestUtils2.java Sun Dec 17 22:34:08 2017
@@ -23,6 +23,7 @@ package org.apache.axis2.jaxws.descripti
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.spi.ServiceDelegate;
import org.apache.axis2.jaxws.unitTest.TestLogger;
+import org.apache.axis2.wsdl.WSDLUtil;
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
@@ -60,7 +61,7 @@ public class DescriptionTestUtils2 {
URL wsdlURL = null;
String urlString = getWSDLLocation(wsdlFileName);
try {
- wsdlURL = new File(urlString).getAbsoluteFile().toURL();
+ wsdlURL = new File(urlString).getAbsoluteFile().toURI().toURL();
} catch (Exception e) {
TestLogger.logger.debug(
"Caught exception creating WSDL URL :" + urlString + "; exception: " +
@@ -72,8 +73,7 @@ public class DescriptionTestUtils2 {
static Definition createWSDLDefinition(URL wsdlURL) {
Definition wsdlDefinition = null;
try {
- WSDLFactory factory = WSDLFactory.newInstance();
- WSDLReader reader = factory.newWSDLReader();
+ WSDLReader reader = WSDLUtil.newWSDLReaderWithPopulatedExtensionRegistry();
wsdlDefinition = reader.readWSDL(wsdlURL.toString());
}
catch (Exception e) {
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/sample/addnumbers/AddNumbersService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/sample/addnumbers/AddNumbersService.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/sample/addnumbers/AddNumbersService.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/description/sample/addnumbers/AddNumbersService.java Sun Dec 17 22:34:08 2017
@@ -51,7 +51,7 @@ public class AddNumbersService
e.printStackTrace();
}
File file = new File(wsdlLocation);
- url = file.toURL();
+ url = file.toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java Sun Dec 17 22:34:08 2017
@@ -1,225 +1,228 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.jaxws.handler;
-
-import junit.framework.TestCase;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
-import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
-import org.apache.axis2.jaxws.message.Block;
-import org.apache.axis2.jaxws.message.Message;
-import org.apache.axis2.jaxws.message.Protocol;
-import org.apache.axis2.jaxws.message.factory.MessageFactory;
-import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
-import org.apache.axis2.jaxws.registry.FactoryRegistry;
-
-import javax.xml.ws.handler.Handler;
-import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-import java.util.ArrayList;
-import java.util.Set;
-
-/**
- * HandlerPrePostInvokerTests verifies that the mechanisms for finding the implementation classes to
- * call before and after handler.handleMessage work, and that the calls are actually made. Simple as that.
- */
-public class HandlerPrePostInvokerTests extends TestCase {
-
- private MessageContext mc = null;
- private boolean preInvokerCalled = false;
- private boolean postInvokerCalled = false;
- private boolean messageAccessed = false;
-
- private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
-
- public static final String SOAP11_ENVELOPE =
- "<?xml version='1.0' encoding='utf-8'?>" +
- "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
- "<soapenv:Header />" +
- "<soapenv:Body>" +
- "</soapenv:Body>" +
- "</soapenv:Envelope>";
-
- @Override
- protected void setUp() throws Exception {
-
- // Create a SOAP 1.1 Message and MessageContext
- // I just grabbed this code from the JAXWS MessageTests
- MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
- Message m = mf.create(Protocol.soap11);
- XMLStringBlockFactory f =
- (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
- Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
- m.setBodyBlock(block);
-
- mc = new MessageContext();
- mc.setMessage(m);
- mc.setMEPContext(new MEPContext(mc));
- }
-
- /**
- * make sure the defaults are as expected
- *
- */
- public void testFactoryRegistry() {
- HandlerPreInvokerFactory preFact = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
- HandlerPostInvokerFactory postFact = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
- HandlerPreInvoker preInvoker = preFact.createHandlerPreInvoker();
- HandlerPostInvoker postInvoker = postFact.createHandlerPostInvoker();
- assertTrue("preInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl.class.getCanonicalName(), preInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl);
- assertTrue("postInvoker should be instanceof " + org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl.class.getCanonicalName(), postInvoker instanceof org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl);
- }
-
- /**
- * make sure the registered factories are used, and the calls are made in the places we expect
- *
- */
- public void testFactoryPrePost() {
-
- FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
- FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
-
- ArrayList<Handler> handlers = new ArrayList<Handler>();
- handlers.add(new SOAPHandler1());
- HandlerChainProcessor processor =
- new HandlerChainProcessor(handlers, Protocol.soap11);
- boolean success = true;
- try {
- // server-side incoming request
- success = processor.processChain(mc.getMEPContext(),
- HandlerChainProcessor.Direction.IN,
- HandlerChainProcessor.MEP.REQUEST,
- true);
- } catch (Exception e) {
- assertNull(e); // should not get exception
- }
-
- assertTrue("processChain should have succeeded", success);
- assertTrue("preInvoker should have been called", preInvokerCalled);
- assertTrue("postInvoker should have been called", postInvokerCalled);
- assertTrue("Handler did not access message but messageAccessed property is true.", !messageAccessed);
-
- }
-
- public void testPostInvokerMessageAccessed() {
-
- FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
-
- ArrayList<Handler> handlers = new ArrayList<Handler>();
- handlers.add(new SOAPHandlerGetsMessage());
- HandlerChainProcessor processor =
- new HandlerChainProcessor(handlers, Protocol.soap11);
- boolean success = true;
- try {
- // server-side incoming request
- success = processor.processChain(mc.getMEPContext(),
- HandlerChainProcessor.Direction.IN,
- HandlerChainProcessor.MEP.REQUEST,
- true);
- } catch (Exception e) {
- assertNull(e); // should not get exception
- }
-
- assertTrue("processChain should have succeeded", success);
- assertTrue("postInvoker should have been called", postInvokerCalled);
- assertTrue("Handler did access message but messageAccessed property is false.", messageAccessed);
-
-
- }
-
- /*****************************************
- * Classes needed for junit testcase *
- *****************************************/
-
- private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
-
- public Set getHeaders() {
- return null;
- }
-
- public void close(javax.xml.ws.handler.MessageContext messagecontext) {
- }
-
- public boolean handleFault(SOAPMessageContext messagecontext) {
- return true;
- }
-
- public boolean handleMessage(SOAPMessageContext messagecontext) {
- return true;
- }
-
- }
- /*****************************************
- * Classes needed for junit testcase *
- *****************************************/
-
- private class SOAPHandlerGetsMessage implements SOAPHandler<SOAPMessageContext> {
-
- public Set getHeaders() {
- return null;
- }
-
- public void close(javax.xml.ws.handler.MessageContext messagecontext) {
- }
-
- public boolean handleFault(SOAPMessageContext messagecontext) {
- return true;
- }
-
- public boolean handleMessage(SOAPMessageContext messagecontext) {
- messagecontext.getMessage();
- return true;
- }
-
- }
-
- private class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
- public HandlerPreInvoker createHandlerPreInvoker() {
- return new HandlerPreInvokerImpl();
- }
- }
-
- private class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
- public HandlerPostInvoker createHandlerPostInvoker() {
- return new HandlerPostInvokerImpl();
- }
- }
-
- private class HandlerPreInvokerImpl implements HandlerPreInvoker {
- public void preInvoke(javax.xml.ws.handler.MessageContext mc) {
- preInvokerCalled = true;
- }
- }
-
- private class HandlerPostInvokerImpl implements HandlerPostInvoker {
- public void postInvoke(javax.xml.ws.handler.MessageContext mc) {
- postInvokerCalled = true;
- if (mc instanceof SoapMessageContext) {
- SoapMessageContext smc = (SoapMessageContext) mc;
- // PK96521 - before getting the message (which is expensive) check first to
- // see if it was actually accessed by the handlers
- messageAccessed = false;
- if (smc.containsKey("jaxws.isMessageAccessed")) {
- messageAccessed = (Boolean)(smc.get("jaxws.isMessageAccessed"));
- }
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.handler;
+
+import junit.framework.TestCase;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.factory.HandlerPostInvokerFactory;
+import org.apache.axis2.jaxws.handler.factory.HandlerPreInvokerFactory;
+import org.apache.axis2.jaxws.message.Block;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+/**
+ * HandlerPrePostInvokerTests verifies that the mechanisms for finding the implementation classes to
+ * call before and after handler.handleMessage work, and that the calls are actually made. Simple as that.
+ */
+public class HandlerPrePostInvokerTests extends TestCase {
+
+ private MessageContext mc = null;
+ private boolean preInvokerCalled = false;
+ private boolean postInvokerCalled = false;
+ private boolean messageAccessed = false;
+
+ private static final String soap11env = "http://schemas.xmlsoap.org/soap/envelope/";
+
+ public static final String SOAP11_ENVELOPE =
+ "<?xml version='1.0' encoding='utf-8'?>" +
+ "<soapenv:Envelope xmlns:soapenv=\"" + soap11env + "\">" +
+ "<soapenv:Header />" +
+ "<soapenv:Body>" +
+ "</soapenv:Body>" +
+ "</soapenv:Envelope>";
+
+ @Override
+ protected void setUp() throws Exception {
+
+ // Create a SOAP 1.1 Message and MessageContext
+ // I just grabbed this code from the JAXWS MessageTests
+ MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
+ Message m = mf.create(Protocol.soap11);
+ XMLStringBlockFactory f =
+ (XMLStringBlockFactory) FactoryRegistry.getFactory(XMLStringBlockFactory.class);
+ Block block = f.createFrom(SOAP11_ENVELOPE, null, null);
+ m.setBodyBlock(block);
+
+ mc = new MessageContext();
+ mc.setMessage(m);
+ mc.setMEPContext(new MEPContext(mc));
+ }
+
+ /**
+ * make sure the defaults are as expected
+ *
+ */
+ public void testFactoryRegistry() {
+ HandlerPreInvokerFactory preFact = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
+ HandlerPostInvokerFactory postFact = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+ HandlerPreInvoker preInvoker = preFact.createHandlerPreInvoker();
+ HandlerPostInvoker postInvoker = postFact.createHandlerPostInvoker();
+ assertThat(preInvoker).named("preInvoker").isInstanceOf(org.apache.axis2.jaxws.handler.impl.HandlerPreInvokerImpl.class);
+ assertThat(postInvoker).named("postInvoker").isInstanceOf(org.apache.axis2.jaxws.handler.impl.HandlerPostInvokerImpl.class);
+ }
+
+ /**
+ * make sure the registered factories are used, and the calls are made in the places we expect
+ *
+ */
+ public void testFactoryPrePost() {
+ HandlerPreInvokerFactory orgHandlerPreInvokerFactory = (HandlerPreInvokerFactory)FactoryRegistry.getFactory(HandlerPreInvokerFactory.class);
+ HandlerPostInvokerFactory orgHandlerPostInvokerFactory = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+ try {
+ FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, new HandlerPreInvokerFactoryImpl());
+ FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
+
+ ArrayList<Handler> handlers = new ArrayList<Handler>();
+ handlers.add(new SOAPHandler1());
+ HandlerChainProcessor processor =
+ new HandlerChainProcessor(handlers, Protocol.soap11);
+ boolean success = true;
+ // server-side incoming request
+ success = processor.processChain(mc.getMEPContext(),
+ HandlerChainProcessor.Direction.IN,
+ HandlerChainProcessor.MEP.REQUEST,
+ true);
+
+ assertTrue("processChain should have succeeded", success);
+ assertTrue("preInvoker should have been called", preInvokerCalled);
+ assertTrue("postInvoker should have been called", postInvokerCalled);
+ assertTrue("Handler did not access message but messageAccessed property is true.", !messageAccessed);
+ } finally {
+ // Reset factory state to avoid side effects visible to other tests
+ FactoryRegistry.setFactory(HandlerPreInvokerFactory.class, orgHandlerPreInvokerFactory);
+ FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, orgHandlerPostInvokerFactory);
+ }
+ }
+
+ public void testPostInvokerMessageAccessed() {
+ HandlerPostInvokerFactory orgHandlerPostInvokerFactory = (HandlerPostInvokerFactory)FactoryRegistry.getFactory(HandlerPostInvokerFactory.class);
+ try {
+ FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, new HandlerPostInvokerFactoryImpl());
+
+ ArrayList<Handler> handlers = new ArrayList<Handler>();
+ handlers.add(new SOAPHandlerGetsMessage());
+ HandlerChainProcessor processor =
+ new HandlerChainProcessor(handlers, Protocol.soap11);
+ boolean success = true;
+ // server-side incoming request
+ success = processor.processChain(mc.getMEPContext(),
+ HandlerChainProcessor.Direction.IN,
+ HandlerChainProcessor.MEP.REQUEST,
+ true);
+
+ assertTrue("processChain should have succeeded", success);
+ assertTrue("postInvoker should have been called", postInvokerCalled);
+ assertTrue("Handler did access message but messageAccessed property is false.", messageAccessed);
+ } finally {
+ FactoryRegistry.setFactory(HandlerPostInvokerFactory.class, orgHandlerPostInvokerFactory);
+ }
+ }
+
+ /*****************************************
+ * Classes needed for junit testcase *
+ *****************************************/
+
+ private class SOAPHandler1 implements SOAPHandler<SOAPMessageContext> {
+
+ public Set getHeaders() {
+ return null;
+ }
+
+ public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+ }
+
+ public boolean handleFault(SOAPMessageContext messagecontext) {
+ return true;
+ }
+
+ public boolean handleMessage(SOAPMessageContext messagecontext) {
+ return true;
+ }
+
+ }
+ /*****************************************
+ * Classes needed for junit testcase *
+ *****************************************/
+
+ private class SOAPHandlerGetsMessage implements SOAPHandler<SOAPMessageContext> {
+
+ public Set getHeaders() {
+ return null;
+ }
+
+ public void close(javax.xml.ws.handler.MessageContext messagecontext) {
+ }
+
+ public boolean handleFault(SOAPMessageContext messagecontext) {
+ return true;
+ }
+
+ public boolean handleMessage(SOAPMessageContext messagecontext) {
+ messagecontext.getMessage();
+ return true;
+ }
+
+ }
+
+ private class HandlerPreInvokerFactoryImpl implements HandlerPreInvokerFactory {
+ public HandlerPreInvoker createHandlerPreInvoker() {
+ return new HandlerPreInvokerImpl();
+ }
+ }
+
+ private class HandlerPostInvokerFactoryImpl implements HandlerPostInvokerFactory {
+ public HandlerPostInvoker createHandlerPostInvoker() {
+ return new HandlerPostInvokerImpl();
+ }
+ }
+
+ private class HandlerPreInvokerImpl implements HandlerPreInvoker {
+ public void preInvoke(javax.xml.ws.handler.MessageContext mc) {
+ preInvokerCalled = true;
+ }
+ }
+
+ private class HandlerPostInvokerImpl implements HandlerPostInvoker {
+ public void postInvoke(javax.xml.ws.handler.MessageContext mc) {
+ postInvokerCalled = true;
+ if (mc instanceof SoapMessageContext) {
+ SoapMessageContext smc = (SoapMessageContext) mc;
+ // PK96521 - before getting the message (which is expensive) check first to
+ // see if it was actually accessed by the handlers
+ messageAccessed = false;
+ if (smc.containsKey("jaxws.isMessageAccessed")) {
+ messageAccessed = (Boolean)(smc.get("jaxws.isMessageAccessed"));
+ }
+ }
+ }
+ }
+}
Propchange: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerPrePostInvokerTests.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff
==============================================================================
--- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java (original)
+++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/HandlerResolverTest.java Sun Dec 17 22:34:08 2017
@@ -142,7 +142,7 @@ public class HandlerResolverTest extends
String sep = "/";
configLoc = sep + "test-resources" + sep + "configuration" + sep + "handlers" + sep + "handler.xml";
String baseDir = new File(System.getProperty("basedir",".")).getCanonicalPath();
- is = new File(baseDir + configLoc).toURL().openStream();
+ is = new File(baseDir + configLoc).toURI().toURL().openStream();
}
catch(Exception e) {
e.printStackTrace();