Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/SOAPHeadersAdapterTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/SOAPHeadersAdapterTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/SOAPHeadersAdapterTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/handler/soapheadersadapter/SOAPHeadersAdapterTests.java Sun Dec 17 22:34:08 2017 @@ -42,8 +42,7 @@ import javax.xml.ws.WebServiceException; import junit.framework.TestCase; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; -import org.apache.axiom.soap.impl.llom.soap11.SOAP11HeaderImpl; +import org.apache.axiom.om.OMSourcedElement; import org.apache.axis2.Constants; import org.apache.axis2.jaxws.core.MessageContext; import org.apache.axis2.jaxws.handler.LogicalMessageImpl; @@ -760,16 +759,16 @@ public class SOAPHeadersAdapterTests ext adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList); // get message object and convert to SOAPEnvelope - OMElement omEnvelope = messageContext.getMessage().getAsOMElement(); + org.apache.axiom.soap.SOAPEnvelope omEnvelope = (org.apache.axiom.soap.SOAPEnvelope)messageContext.getMessage().getAsOMElement(); - // confirm headers are there. I can cast here only because I know the implementation. :) - SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next(); + // confirm headers are there. + org.apache.axiom.soap.SOAPHeader omHeader = omEnvelope.getHeader(); - Iterator<OMSourcedElementImpl> it = omHeader.getChildElements(); + Iterator<OMElement> it = omHeader.getChildElements(); // TODO: not sure if the order of the header additions is or should be preserved. // in other words, this test may be a little too strict. - OMSourcedElementImpl headerElem1 = it.next(); - OMSourcedElementImpl headerElem2 = it.next(); + OMSourcedElement headerElem1 = (OMSourcedElement)it.next(); + OMSourcedElement headerElem2 = (OMSourcedElement)it.next(); // should only be two header elements, so... assertFalse(it.hasNext()); @@ -821,16 +820,16 @@ public class SOAPHeadersAdapterTests ext adapter.put(ACOH1_HEADER_QNAME, acoh1ContentList); // get message object and convert to SOAPEnvelope - OMElement omEnvelope = messageContext.getMessage().getAsOMElement(); + org.apache.axiom.soap.SOAPEnvelope omEnvelope = (org.apache.axiom.soap.SOAPEnvelope)messageContext.getMessage().getAsOMElement(); - // confirm headers are there. I can cast here only because I know the implementation. :) - SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next(); + // confirm headers are there. + org.apache.axiom.soap.SOAPHeader omHeader = omEnvelope.getHeader(); - Iterator<OMSourcedElementImpl> it = omHeader.getChildElements(); + Iterator<OMElement> it = omHeader.getChildElements(); // TODO: not sure if the order of the header additions is or should be preserved. // in other words, this test may be a little too strict. - OMSourcedElementImpl headerElem1 = it.next(); - OMSourcedElementImpl headerElem2 = it.next(); + OMSourcedElement headerElem1 = (OMSourcedElement)it.next(); + OMSourcedElement headerElem2 = (OMSourcedElement)it.next(); // should only be two header elements, so... assertFalse(it.hasNext()); @@ -890,16 +889,16 @@ public class SOAPHeadersAdapterTests ext payload.toString(); // get message object and convert to SOAPEnvelope - OMElement omEnvelope = messageContext.getMessage().getAsOMElement(); + org.apache.axiom.soap.SOAPEnvelope omEnvelope = (org.apache.axiom.soap.SOAPEnvelope)messageContext.getMessage().getAsOMElement(); - // confirm headers are there. I can cast here only because I know the implementation. :) - SOAP11HeaderImpl omHeader = (SOAP11HeaderImpl)omEnvelope.getChildElements().next(); + // confirm headers are there. + org.apache.axiom.soap.SOAPHeader omHeader = omEnvelope.getHeader(); - Iterator<OMSourcedElementImpl> it = omHeader.getChildElements(); + Iterator<OMElement> it = omHeader.getChildElements(); // TODO: not sure if the order of the header additions is or should be preserved. // in other words, this test may be a little too strict. - OMSourcedElementImpl headerElem1 = it.next(); - OMSourcedElementImpl headerElem2 = it.next(); + OMSourcedElement headerElem1 = (OMSourcedElement)it.next(); + OMSourcedElement headerElem2 = (OMSourcedElement)it.next(); // should only be two header elements, so... assertFalse(it.hasNext());
Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/injection/ResourceInjectionTests.java Sun Dec 17 22:34:08 2017 @@ -28,92 +28,65 @@ import org.apache.axis2.jaxws.unitTest.T import javax.xml.ws.WebServiceContext; public class ResourceInjectionTests extends TestCase { - String axisEndpoint = "http://localhost:6060/axis2/services/ResourceInjectionService.ResourceInjectionPortTypeImplPort"; - private Object resource = new WebServiceContextImpl(); - public void testInjectionOnField(){ + public void testInjectionOnField() throws Exception { Object serviceInstance = new ResourceInjectionTestImpl1(); TestLogger.logger.debug("------------------------------"); TestLogger.logger.debug("Test : " + getName()); - try{ - ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); - injector.inject(resource, serviceInstance); - ResourceInjectionTestImpl1 serviceImpl =(ResourceInjectionTestImpl1)serviceInstance; - assertNotNull(serviceImpl.ctx); - TestLogger.logger.debug("Resource Injected on Field"); - TestLogger.logger.debug("------------------------------"); - }catch(Exception e){ - e.printStackTrace(); - fail(); - } + ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); + injector.inject(resource, serviceInstance); + ResourceInjectionTestImpl1 serviceImpl =(ResourceInjectionTestImpl1)serviceInstance; + assertNotNull(serviceImpl.ctx); + TestLogger.logger.debug("Resource Injected on Field"); + TestLogger.logger.debug("------------------------------"); } - public void testInjectionOnMethod(){ + public void testInjectionOnMethod() throws Exception { Object serviceInstance = new ResourceInjectionTestImpl2(); TestLogger.logger.debug("------------------------------"); TestLogger.logger.debug("Test : " + getName()); - try{ - ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); - injector.inject(resource, serviceInstance); - ResourceInjectionTestImpl2 serviceImpl =(ResourceInjectionTestImpl2)serviceInstance; - assertNotNull(serviceImpl.ctx); - TestLogger.logger.debug("Resource Injected on Method"); - TestLogger.logger.debug("------------------------------"); - }catch(Exception e){ - e.printStackTrace(); - fail(); - } + ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); + injector.inject(resource, serviceInstance); + ResourceInjectionTestImpl2 serviceImpl =(ResourceInjectionTestImpl2)serviceInstance; + assertNotNull(serviceImpl.ctx); + TestLogger.logger.debug("Resource Injected on Method"); + TestLogger.logger.debug("------------------------------"); } - public void testInjectionOnPrivateField(){ + public void testInjectionOnPrivateField() throws Exception { Object serviceInstance = new ResourceInjectionTestImpl3(); TestLogger.logger.debug("------------------------------"); TestLogger.logger.debug("Test : " + getName()); - try{ - ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); - injector.inject(resource, serviceInstance); - ResourceInjectionTestImpl3 serviceImpl =(ResourceInjectionTestImpl3)serviceInstance; - assertNotNull(serviceImpl.getCtx()); - TestLogger.logger.debug("Resource Injected on Private Field"); - TestLogger.logger.debug("------------------------------"); - }catch(Exception e){ - e.printStackTrace(); - fail(); - } + ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); + injector.inject(resource, serviceInstance); + ResourceInjectionTestImpl3 serviceImpl =(ResourceInjectionTestImpl3)serviceInstance; + assertNotNull(serviceImpl.getCtx()); + TestLogger.logger.debug("Resource Injected on Private Field"); + TestLogger.logger.debug("------------------------------"); } - public void testInjectionOnProvateMethod(){ + public void testInjectionOnProvateMethod() throws Exception { Object serviceInstance = new ResourceInjectionTestImpl4(); TestLogger.logger.debug("------------------------------"); TestLogger.logger.debug("Test : " + getName()); - try{ - ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); - injector.inject(resource, serviceInstance); - ResourceInjectionTestImpl4 serviceImpl =(ResourceInjectionTestImpl4)serviceInstance; - assertNotNull(serviceImpl.getCtx()); - TestLogger.logger.debug("Resource Injected using private Method"); - TestLogger.logger.debug("------------------------------"); - }catch(Exception e){ - e.printStackTrace(); - fail(); - } + ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); + injector.inject(resource, serviceInstance); + ResourceInjectionTestImpl4 serviceImpl =(ResourceInjectionTestImpl4)serviceInstance; + assertNotNull(serviceImpl.getCtx()); + TestLogger.logger.debug("Resource Injected using private Method"); + TestLogger.logger.debug("------------------------------"); } - public void testTypedResourceInjectionOnField(){ + public void testTypedResourceInjectionOnField() throws Exception { Object serviceInstance = new ResourceInjectionTestImpl5(); TestLogger.logger.debug("------------------------------"); TestLogger.logger.debug("Test : " + getName()); - try{ - ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); - injector.inject(resource, serviceInstance); - ResourceInjectionTestImpl5 serviceImpl =(ResourceInjectionTestImpl5)serviceInstance; - assertNotNull(serviceImpl.ctx); - TestLogger.logger.debug("Resource Injected on Field"); - TestLogger.logger.debug("------------------------------"); - }catch(Exception e){ - e.printStackTrace(); - fail(); - } + ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class); + injector.inject(resource, serviceInstance); + ResourceInjectionTestImpl5 serviceImpl =(ResourceInjectionTestImpl5)serviceInstance; + assertNotNull(serviceImpl.ctx); + TestLogger.logger.debug("Resource Injected on Field"); + TestLogger.logger.debug("------------------------------"); } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/BlockTests.java Sun Dec 17 22:34:08 2017 @@ -25,7 +25,8 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.OMXMLParserWrapper; import org.apache.axis2.datasource.jaxb.JAXBDSContext; import org.apache.axis2.datasource.jaxb.JAXBDataSource; import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext; @@ -36,7 +37,6 @@ import org.apache.axis2.jaxws.message.fa import org.apache.axis2.jaxws.message.factory.OMBlockFactory; import org.apache.axis2.jaxws.message.factory.SourceBlockFactory; import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory; -import org.apache.axis2.jaxws.message.util.Reader2Writer; import org.apache.axis2.jaxws.registry.FactoryRegistry; import org.apache.axis2.jaxws.unitTest.TestLogger; import org.w3c.dom.Document; @@ -61,6 +61,10 @@ import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamSource; + +import static com.google.common.truth.Truth.assertAbout; +import static org.apache.axiom.truth.xml.XMLTruth.xml; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.StringReader; @@ -122,10 +126,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -161,10 +162,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -196,9 +194,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -345,8 +341,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); + String newText = OMXMLBuilderFactory.createStAXOMBuilder(reader).getDocumentElement().toString(); assertTrue(newText.contains("Hello World")); assertTrue(newText.contains("echoString")); @@ -394,8 +389,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); + String newText = OMXMLBuilderFactory.createStAXOMBuilder(reader).getDocumentElement().toString(); assertTrue(newText.contains("Hello World")); assertTrue(newText.contains("echoString")); @@ -627,7 +621,7 @@ public class BlockTests extends TestCase // what occurs on the outbound JAX-WS dispatch<OMElement> client StringReader sr = new StringReader(sampleText); XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr); - StAXOMBuilder builder = new StAXOMBuilder(inputReader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(inputReader); OMElement om = builder.getDocumentElement(); Block block = f.createFrom(om, null, null); @@ -641,10 +635,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } @@ -662,7 +653,7 @@ public class BlockTests extends TestCase // what occurs on the outbound JAX-WS dispatch<OMElement> client StringReader sr = new StringReader(sampleText); XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr); - StAXOMBuilder builder = new StAXOMBuilder(inputReader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(inputReader); OMElement om = builder.getDocumentElement(); Block block = f.createFrom(om, null, null); @@ -683,10 +674,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -754,10 +742,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -795,10 +780,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -835,9 +817,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -867,11 +847,7 @@ public class BlockTests extends TestCase assertTrue(block.isConsumed()); // Check the String for accuracy - XMLStreamReader reader = inputFactory.createXMLStreamReader((Source) bo); - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(bo).hasSameContentAs(sampleText); } /** @@ -907,11 +883,7 @@ public class BlockTests extends TestCase assertTrue(block.isConsumed()); // Check the String for accuracy - XMLStreamReader reader = inputFactory.createXMLStreamReader((Source) bo); - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(bo).hasSameContentAs(sampleText); } /** @@ -949,11 +921,7 @@ public class BlockTests extends TestCase assertTrue(block.isConsumed()); // Check the String for accuracy - XMLStreamReader reader = inputFactory.createXMLStreamReader((Source) bo); - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); - + assertAbout(xml()).that(bo).hasSameContentAs(sampleText); } /* * Testing JAXBSource, Creating Source Block using JAXBSource and then @@ -1026,9 +994,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(echoSample.equals(newText)); + assertAbout(xml()).that(reader).hasSameContentAs(echoSample); } /** * Create a Block representing a DOMSource instance and simulate an @@ -1072,9 +1038,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } /** @@ -1110,9 +1074,7 @@ public class BlockTests extends TestCase // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(reader); - String newText = r2w.getAsString(); - assertTrue(sampleText.equals(newText)); + assertAbout(xml()).that(reader).hasSameContentAs(sampleText); } } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/FaultTests.java Sun Dec 17 22:34:08 2017 @@ -21,7 +21,8 @@ package org.apache.axis2.jaxws.message; import junit.framework.TestCase; import org.apache.axiom.om.OMElement; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.soap.SOAPModelBuilder; import org.apache.axis2.jaxws.message.factory.BlockFactory; import org.apache.axis2.jaxws.message.factory.MessageFactory; import org.apache.axis2.jaxws.message.factory.SourceBlockFactory; @@ -136,7 +137,7 @@ public class FaultTests extends TestCase // OM StringReader sr = new StringReader(sampleSOAP11FaultEnvelope1); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -172,8 +173,7 @@ public class FaultTests extends TestCase // OM StringReader sr = new StringReader(sampleSOAP11FaultEnvelope2); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, - null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -228,7 +228,7 @@ public class FaultTests extends TestCase // OM StringReader sr = new StringReader(sampleSOAP12FaultEnvelope1); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -261,7 +261,7 @@ public class FaultTests extends TestCase // OM StringReader sr = new StringReader(sampleSOAP12FaultEnvelope2); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBCustomBuilderTests.java Sun Dec 17 22:34:08 2017 @@ -24,7 +24,9 @@ import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMSourcedElement; -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.ds.custombuilder.CustomBuilderSupport; import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder; import org.apache.axis2.datasource.jaxb.JAXBDSContext; import org.apache.axis2.datasource.jaxb.JAXBDataSource; @@ -93,7 +95,7 @@ public class JAXBCustomBuilderTests exte // Read the sample text using OM backed by StAX. XMLStreamReader inputReader = inputFactory.createXMLStreamReader(sr); - StAXOMBuilder builder = new StAXOMBuilder(inputReader); + OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(inputReader); // Create the JAXBCustomBuilder JAXBDSContext jdsContext = new JAXBDSContext(contextPackages); @@ -101,7 +103,7 @@ public class JAXBCustomBuilderTests exte // Register the JAXBCustomBuilder...this will intercept the payload // and build a jaxb element - builder.registerCustomBuilderForPayload(jcb); + ((CustomBuilderSupport)builder).registerCustomBuilder(jcb, jcb); // Get the OM element OMElement om = builder.getDocumentElement(); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBDSContextTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBDSContextTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBDSContextTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/JAXBDSContextTests.java Sun Dec 17 22:34:08 2017 @@ -20,53 +20,23 @@ package org.apache.axis2.jaxws.message; import junit.framework.TestCase; + import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.OMException; import org.apache.axiom.om.OMOutputFormat; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.axiom.om.impl.MTOMXMLStreamWriter; +import org.apache.axiom.om.ds.AbstractPushOMDataSource; import org.apache.axis2.datasource.jaxb.JAXBDSContext; -import org.apache.axis2.datasource.jaxb.JAXBDataSource; -import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext; -import org.apache.axis2.jaxws.message.databinding.JAXBUtils; -import org.apache.axis2.jaxws.message.factory.BlockFactory; -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.SourceBlockFactory; -import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory; -import org.apache.axis2.jaxws.message.util.Reader2Writer; -import org.apache.axis2.jaxws.registry.FactoryRegistry; import org.apache.axis2.jaxws.unitTest.TestLogger; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; import test.Data; import test.ObjectFactory; -import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBIntrospector; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.util.JAXBSource; +import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamSource; -import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.StringWriter; import java.util.TreeSet; /** @@ -75,21 +45,6 @@ import java.util.TreeSet; * These are not client/server tests. */ public class JAXBDSContextTests extends TestCase { - - - private static XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - private static XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); - - - public JAXBDSContextTests() { - super(); - } - - public JAXBDSContextTests(String arg0) { - super(arg0); - } - - /** * Create a Block representing an JAXB and simulate a * normal Dispatch<JAXB> flow @@ -100,7 +55,7 @@ public class JAXBDSContextTests extends // Create a JAXBDSContext for the package containing Data TreeSet<String> packages = new TreeSet<String>(); packages.add(Data.class.getPackage().getName()); - JAXBDSContext context = new JAXBDSContext(packages); + final JAXBDSContext context = new JAXBDSContext(packages); TestLogger.logger.debug(context.getJAXBContext().toString()); @@ -114,21 +69,31 @@ public class JAXBDSContextTests extends // Create a JAXBElement QName qName = new QName("urn://sample", "data"); - JAXBElement jaxbElement = new JAXBElement(qName, Data.class, value); + final JAXBElement<Data> jaxbElement = new JAXBElement<Data>(qName, Data.class, value); // Create a writer ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat format = new OMOutputFormat(); format.setDoOptimize(true); - MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, format); // Marshal the value - writer.writeStartDocument(); - writer.writeStartElement("root"); - context.marshal(jaxbElement, writer); - writer.writeEndElement(); - writer.writeEndDocument(); - writer.flush(); + OMAbstractFactory.getOMFactory().createOMElement(new AbstractPushOMDataSource() { + @Override + public void serialize(XMLStreamWriter writer) throws XMLStreamException { + writer.writeStartElement("", "root", ""); + try { + context.marshal(jaxbElement, writer); + } catch (JAXBException ex) { + throw new OMException(ex); + } + writer.writeEndElement(); + } + + @Override + public boolean isDestructiveWrite() { + return false; + } + }).serialize(baos, format); assertTrue(baos.toString().indexOf("Hello World") > 0); assertTrue(baos.toString().indexOf("</root>") > 0); @@ -144,7 +109,7 @@ public class JAXBDSContextTests extends // Create a JAXBDSContext for the package containing Data TreeSet<String> packages = new TreeSet<String>(); packages.add(Data.class.getPackage().getName()); - JAXBDSContext context = new JAXBDSContext(packages); + final JAXBDSContext context = new JAXBDSContext(packages); TestLogger.logger.debug(context.getJAXBContext().toString()); @@ -166,20 +131,31 @@ public class JAXBDSContextTests extends // an OccurrenceArray QName qName = new QName("urn://sample", "data"); OccurrenceArray occurrenceArray = new OccurrenceArray(value); - JAXBElement jaxbElement = new JAXBElement(qName, Data[].class, occurrenceArray); + final JAXBElement jaxbElement = new JAXBElement(qName, Data[].class, occurrenceArray); // Create a writer ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat format = new OMOutputFormat(); format.setDoOptimize(true); - MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, format); // Marshal the value - writer.writeStartElement("root"); - context.marshal(jaxbElement, writer); - writer.writeEndElement(); - - writer.flush(); + OMAbstractFactory.getOMFactory().createOMElement(new AbstractPushOMDataSource() { + @Override + public void serialize(XMLStreamWriter writer) throws XMLStreamException { + writer.writeStartElement("", "root", ""); + try { + context.marshal(jaxbElement, writer); + } catch (JAXBException ex) { + throw new OMException(ex); + } + writer.writeEndElement(); + } + + @Override + public boolean isDestructiveWrite() { + return false; + } + }).serialize(baos, format); String outputText = baos.toString(); String subText = outputText; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java Sun Dec 17 22:34:08 2017 @@ -21,14 +21,14 @@ package org.apache.axis2.jaxws.message; import junit.framework.TestCase; -import org.apache.axiom.om.OMAttachmentAccessor; import org.apache.axiom.om.OMDataSource; import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMNode; import org.apache.axiom.om.OMOutputFormat; import org.apache.axiom.om.OMSourcedElement; -import org.apache.axiom.om.OMXMLStreamReader; -import org.apache.axiom.om.util.CopyUtils; +import org.apache.axiom.om.OMText; import org.apache.axiom.soap.SOAPBody; +import org.apache.axiom.soap.SOAPCloneOptions; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axis2.Constants; import org.apache.axis2.Constants.Configuration; @@ -61,6 +61,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.util.Iterator; /** * These tests simulate the outbound processing @@ -88,6 +89,14 @@ public class MessagePersistanceTests ext imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image); } + private static SOAPEnvelope copy(SOAPEnvelope sourceEnv) { + SOAPCloneOptions options = new SOAPCloneOptions(); + options.setFetchDataHandlers(true); + options.setPreserveModel(true); + options.setCopyOMDataSources(true); + return (SOAPEnvelope)sourceEnv.clone(options); + } + /** * Create a JAXBBlock containing a JAX-B business object and simulate a normal Dispatch<Object> * output flow @@ -291,7 +300,7 @@ public class MessagePersistanceTests ext assertTrue(ds instanceof JAXBBlockImpl); // Now simulate persisting the message in memory - SOAPEnvelope env2 = CopyUtils.copy(env); + SOAPEnvelope env2 = copy(env); // Make sure the Axiom structure is intact. env = axisMC.getEnvelope(); @@ -506,22 +515,14 @@ public class MessagePersistanceTests ext env = restoredMC.getEnvelope(); env.build(); - // Use tree as input to XMLStreamReader - OMXMLStreamReader xmlStreamReader = (OMXMLStreamReader) env.getXMLStreamReader(); - - // Issue XOP:Include events for optimized MTOM text nodes - xmlStreamReader.setInlineMTOM(false); - DataHandler dh = null; - while(xmlStreamReader.hasNext()) { - xmlStreamReader.next(); - if (xmlStreamReader.isStartElement()) { - QName qName =xmlStreamReader.getName(); - if (XOP_INCLUDE.equals(qName)) { - String hrefValue = xmlStreamReader.getAttributeValue("", "href"); - if (hrefValue != null) { - dh =((OMAttachmentAccessor)xmlStreamReader).getDataHandler(hrefValue); - } + for (Iterator<OMNode> it = env.getDescendants(false); it.hasNext(); ) { + OMNode node = it.next(); + if (node instanceof OMText) { + OMText text = (OMText)node; + if (text.isBinary()) { + dh = text.getDataHandler(); + break; } } } @@ -585,7 +586,7 @@ public class MessagePersistanceTests ext assertTrue(ds instanceof JAXBBlockImpl); // Now simulate persisting the message in memory - SOAPEnvelope env2 = CopyUtils.copy(env); + SOAPEnvelope env2 = copy(env); // Make sure the Axiom structure is intact. env = axisMC.getEnvelope(); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageRPCTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageRPCTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageRPCTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageRPCTests.java Sun Dec 17 22:34:08 2017 @@ -22,8 +22,9 @@ package org.apache.axis2.jaxws.message; import junit.framework.TestCase; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMOutputFormat; +import org.apache.axiom.om.OMXMLBuilderFactory; import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; +import org.apache.axiom.soap.SOAPModelBuilder; import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext; import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory; import org.apache.axis2.jaxws.message.factory.MessageFactory; @@ -261,7 +262,7 @@ public class MessageRPCTests extends Tes // simulates what Axis2 will be doing with the inbound message. StringReader sr = new StringReader(sampleJAXBEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // Create a SOAP 1.1 Message from the sample incoming XML @@ -339,7 +340,7 @@ public class MessageRPCTests extends Tes // simulates what Axis2 will be doing with the inbound message. StringReader sr = new StringReader(xml); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // Create a SOAP 1.1 Message from the sample incoming XML Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/MessageTests.java Sun Dec 17 22:34:08 2017 @@ -23,8 +23,10 @@ import junit.framework.TestCase; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMOutputFormat; import org.apache.axiom.om.OMSourcedElement; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.om.ds.custombuilder.CustomBuilderSupport; import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; +import org.apache.axiom.soap.SOAPModelBuilder; import org.apache.axis2.datasource.jaxb.JAXBCustomBuilder; import org.apache.axis2.datasource.jaxb.JAXBDSContext; import org.apache.axis2.datasource.jaxb.JAXBDataSource; @@ -438,7 +440,7 @@ public class MessageTests extends TestCa // OM StringReader sr = new StringReader(sampleEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -497,7 +499,7 @@ public class MessageTests extends TestCa // OM StringReader sr = new StringReader(sampleEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -571,7 +573,7 @@ public class MessageTests extends TestCa // OM StringReader sr = new StringReader(sampleEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -633,7 +635,7 @@ public class MessageTests extends TestCa // OM StringReader sr = new StringReader(sampleEnvelopeNoHeader); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -901,14 +903,14 @@ public class MessageTests extends TestCa // simulates what Axis2 will be doing with the inbound message. StringReader sr = new StringReader(sampleJAXBEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); JAXBDSContext jds = null; if (installJAXBCustomBuilder) { jds = new JAXBDSContext(EchoStringResponse.class.getPackage().getName()); JAXBCustomBuilder jcb = new JAXBCustomBuilder(jds); - builder.registerCustomBuilderForPayload(jcb); + ((CustomBuilderSupport)builder).registerCustomBuilder(jcb, jcb); } // Create a SOAP 1.1 Message from the sample incoming XML @@ -1019,7 +1021,7 @@ public class MessageTests extends TestCa if (persist == SAVE_AND_PERSIST) { sr = new StringReader(saveMsgText); XMLStreamReader saveMsgReader = inputFactory.createXMLStreamReader(sr); - builder = new StAXSOAPModelBuilder(saveMsgReader, null); + builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(saveMsgReader); omElement = builder.getSOAPEnvelope(); m = mf.createFrom(omElement, null); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SAAJConverterTests.java Sun Dec 17 22:34:08 2017 @@ -24,7 +24,8 @@ import org.apache.axiom.om.OMAbstractFac import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.soap.SOAPModelBuilder; import org.apache.axis2.jaxws.message.factory.SAAJConverterFactory; import org.apache.axis2.jaxws.message.util.SAAJConverter; import org.apache.axis2.jaxws.registry.FactoryRegistry; @@ -98,7 +99,7 @@ public class SAAJConverterTests extends // Bootstrap: Create an OM SOAPEnvelope from the sample text StringReader sr = new StringReader(sampleEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope(); // Step 1: Get the SAAJConverter object from the Factory @@ -137,7 +138,7 @@ public class SAAJConverterTests extends // Bootstrap: Create an OM SOAPEnvelope from the sample text. StringReader sr = new StringReader(sampleEnvelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope(); // Bootstrap: Get an OMElement from the body @@ -203,7 +204,7 @@ public class SAAJConverterTests extends // Bootstrap: Create an OM SOAPEnvelope from the sample text StringReader sr = new StringReader(sampleEnvelope1); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); org.apache.axiom.soap.SOAPEnvelope omEnvelope = builder.getSOAPEnvelope(); // Step 1: Get the SAAJConverter object from the Factory Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java Sun Dec 17 22:34:08 2017 @@ -22,11 +22,11 @@ package org.apache.axis2.jaxws.message; import junit.framework.TestCase; import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMNamespace; +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.factory.MessageFactory; import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory; -import org.apache.axis2.jaxws.message.util.Reader2Writer; import org.apache.axis2.jaxws.registry.FactoryRegistry; import org.apache.axis2.jaxws.unitTest.TestLogger; import org.apache.log4j.BasicConfigurator; @@ -101,8 +101,7 @@ public class SOAP12Tests extends TestCas // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(om.getXMLStreamReader()); - String newText = r2w.getAsString(); + String newText = OMXMLBuilderFactory.createStAXOMBuilder(om.getXMLStreamReader()).getDocumentElement().toString(); TestLogger.logger.debug(newText); assertTrue(newText.contains(sampleText)); assertTrue(newText.contains("soap")); @@ -146,8 +145,7 @@ public class SOAP12Tests extends TestCas // To check that the output is correct, get the String contents of the // reader - Reader2Writer r2w = new Reader2Writer(om.getXMLStreamReaderWithoutCaching()); - String newText = r2w.getAsString(); + String newText = OMXMLBuilderFactory.createStAXOMBuilder(om.getXMLStreamReaderWithoutCaching()).getDocumentElement().toString(); TestLogger.logger.debug(newText); assertTrue(newText.contains(sampleText)); assertTrue(newText.contains("soap")); @@ -170,7 +168,7 @@ public class SOAP12Tests extends TestCas // OM StringReader sr = new StringReader(sampleSoap12Envelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM @@ -208,7 +206,7 @@ public class SOAP12Tests extends TestCas // OM StringReader sr = new StringReader(sampleSoap12Envelope); XMLStreamReader inflow = inputFactory.createXMLStreamReader(sr); - StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(inflow, null); + SOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(inflow); OMElement omElement = builder.getSOAPEnvelope(); // The JAX-WS layer creates a Message from the OM Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataHandlerChainTest.java Sun Dec 17 22:34:08 2017 @@ -536,7 +536,7 @@ public class ClientMetadataHandlerChainT String sep = "/"; configLoc = sep + "test-resources" + sep + "configuration" + sep + "handlers" + sep + fileName; 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(); Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java Sun Dec 17 22:34:08 2017 @@ -987,7 +987,7 @@ public class ClientMetadataTest 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/wsdl/schemareader/SchemaReaderTests.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/wsdl/schemareader/SchemaReaderTests.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/wsdl/schemareader/SchemaReaderTests.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jaxws/test/org/apache/axis2/jaxws/wsdl/schemareader/SchemaReaderTests.java Sun Dec 17 22:34:08 2017 @@ -46,7 +46,7 @@ public class SchemaReaderTests extends T 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/jibx/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/pom.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/pom.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/pom.xml Sun Dec 17 22:34:08 2017 @@ -23,9 +23,9 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.axis2</groupId> - <artifactId>axis2-parent</artifactId> - <version>1.7.0-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> + <artifactId>axis2</artifactId> + <version>1.8.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> </parent> <artifactId>axis2-jibx</artifactId> <name>Apache Axis2 - JiBX Data Binding</name> @@ -50,12 +50,9 @@ </dependency> <dependency> <groupId>org.apache.axis2</groupId> - <artifactId>axis2-codegen</artifactId> + <artifactId>axis2-jibx-codegen</artifactId> <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.jibx</groupId> - <artifactId>jibx-bind</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>org.jibx</groupId> @@ -110,23 +107,23 @@ <tasks unless="maven.test.skip"> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <classpath refid="maven.test.classpath" /> - <arg line="-uri src/test/wsdl/library.wsdl -o ${project.build.directory}/gen/library-unwrapped -d jibx -uw -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.unwrapped.client" /> + <arg line="-uri src/test/wsdl/library.wsdl -o '${project.build.directory}/gen/library-unwrapped' -d jibx -uw -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.unwrapped.client" /> </java> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <classpath refid="maven.test.classpath" /> - <arg line="-uri src/test/wsdl/library.wsdl -o ${project.build.directory}/gen/library-unwrapped -d jibx -ss -ssi -sd -uw -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.unwrapped.service" /> + <arg line="-uri src/test/wsdl/library.wsdl -o '${project.build.directory}/gen/library-unwrapped' -d jibx -ss -ssi -sd -uw -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.unwrapped.service" /> </java> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <classpath refid="maven.test.classpath" /> - <arg line="-uri src/test/wsdl/library.wsdl -o ${project.build.directory}/gen/library-wrapped -d jibx -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.wrapped.client" /> + <arg line="-uri src/test/wsdl/library.wsdl -o '${project.build.directory}/gen/library-wrapped' -d jibx -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.wrapped.client" /> </java> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <classpath refid="maven.test.classpath" /> - <arg line="-uri src/test/wsdl/library.wsdl -o ${project.build.directory}/gen/library-wrapped -d jibx -ss -ssi -sd -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.wrapped.service" /> + <arg line="-uri src/test/wsdl/library.wsdl -o '${project.build.directory}/gen/library-wrapped' -d jibx -ss -ssi -sd -Ebindingfile src/test/binding/library-binding.xml --noBuildXML -ns2p http://ws.sosnoski.com/library/wsdl=org.apache.axis2.jibx.library.wrapped.service" /> </java> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <classpath refid="maven.test.classpath" /> - <arg line="-uri src/test/wsdl/customer-echo.wsdl -o ${project.build.directory}/gen/customer-echo -d jibx -Ebindingfile src/test/binding/customer-binding.xml --noBuildXML -ns2p http://ws.apache.org/axis2/jibx/customer/wsdl=org.apache.axis2.jibx.customer" /> + <arg line="-uri src/test/wsdl/customer-echo.wsdl -o '${project.build.directory}/gen/customer-echo' -d jibx -Ebindingfile src/test/binding/customer-binding.xml --noBuildXML -ns2p http://ws.apache.org/axis2/jibx/customer/wsdl=org.apache.axis2.jibx.customer" /> </java> </tasks> </configuration> @@ -137,7 +134,7 @@ <configuration> <tasks unless="maven.test.skip"> <java classname="org.jibx.binding.Compile" fork="true"> - <classpath refid="maven.runtime.classpath" /> + <classpath refid="maven.test.classpath" /> <classpath location="target/test-classes" /> <!-- arg value="-v" /--> <arg value="src/test/binding/customer-binding.xml" /> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/src/test/repo/conf/axis2.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/src/test/repo/conf/axis2.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/src/test/repo/conf/axis2.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/jibx/src/test/repo/conf/axis2.xml Sun Dec 17 22:34:08 2017 @@ -80,12 +80,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/json/pom.xml URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/pom.xml?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/pom.xml (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/pom.xml Sun Dec 17 22:34:08 2017 @@ -23,9 +23,9 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.axis2</groupId> - <artifactId>axis2-parent</artifactId> - <version>1.7.0-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> + <artifactId>axis2</artifactId> + <version>1.8.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> </parent> <artifactId>axis2-json</artifactId> <name>Apache Axis2 - JSON</name> @@ -71,11 +71,25 @@ <artifactId>gson</artifactId> </dependency> <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-adb-codegen</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>axiom-truth</artifactId> + <scope>test</scope> + </dependency> </dependencies> <url>http://axis.apache.org/axis2/java/core/</url> <scm> @@ -119,10 +133,10 @@ <configuration> <tasks unless="maven.test.skip"> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> - <classpath refid="maven.test.classpath"/> - <arg line="-ss -sd -u -or -o ${project.build.directory}/gen -uri test-wsdl/LibraryService.wsdl"/> + <classpath refid="maven.test.classpath" /> + <arg line="-ss -sd -u -or -o '${project.build.directory}/gen' -uri test-wsdl/LibraryService.wsdl" /> </java> - <delete file="${project.build.directory}/gen/src/org/apache/axis2/json/adb/LibraryServiceSkeleton.java"/> + <delete file="${project.build.directory}/gen/src/org/apache/axis2/json/adb/LibraryServiceSkeleton.java" /> </tasks> </configuration> </execution> @@ -147,6 +161,33 @@ </executions> </plugin> <plugin> + <groupId>${project.groupId}</groupId> + <artifactId>axis2-repo-maven-plugin</artifactId> + <version>${project.version}</version> + <executions> + <execution> + <id>json-repo</id> + <goals> + <goal>create-test-repository</goal> + </goals> + <configuration> + <inputDirectory>test-repository/json</inputDirectory> + <outputDirectory>${project.build.directory}/repo/json</outputDirectory> + </configuration> + </execution> + <execution> + <id>gson-repo</id> + <goals> + <goal>create-test-repository</goal> + </goals> + <configuration> + <inputDirectory>test-repository/gson</inputDirectory> + <outputDirectory>${project.build.directory}/repo/gson</outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <artifactId>maven-resources-plugin</artifactId> <executions> <execution> @@ -156,12 +197,9 @@ <goal>copy-resources</goal> </goals> <configuration> - <outputDirectory>${project.build.directory}/repo</outputDirectory> + <outputDirectory>${project.build.directory}/repo/gson</outputDirectory> <resources> <resource> - <directory>src/test/repo</directory> - </resource> - <resource> <directory>${project.build.directory}/gen/resources</directory> <targetPath>services/json_adb_test.aar/META-INF</targetPath> </resource> Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/JSONUtil.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/JSONUtil.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/JSONUtil.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/JSONUtil.java Sun Dec 17 22:34:08 2017 @@ -35,8 +35,8 @@ public final class JSONUtil { Object value = service.getParameterValue("xmlToJsonNamespaceMap"); if (value != null) { if (value instanceof OMElement && ((OMElement)value).getLocalName().equals("mappings")) { - for (Iterator it = ((OMElement)value).getChildrenWithName(new QName("mapping")); it.hasNext(); ) { - OMElement mapping = (OMElement)it.next(); + for (Iterator<OMElement> it = ((OMElement)value).getChildrenWithName(new QName("mapping")); it.hasNext(); ) { + OMElement mapping = it.next(); ns2jnsMap.put(mapping.getAttributeValue(new QName("xmlNamespace")), mapping.getAttributeValue(new QName("jsonNamespace"))); } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java Sun Dec 17 22:34:08 2017 @@ -21,6 +21,7 @@ package org.apache.axis2.json.gson; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; +import org.apache.axis2.AxisFault; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.json.gson.factory.JSONType; import org.apache.axis2.json.gson.factory.JsonConstant; @@ -87,7 +88,7 @@ public class GsonXMLStreamReader impleme } public GsonXMLStreamReader(JsonReader jsonReader, QName elementQname, List<XmlSchema> xmlSchemaList, - ConfigurationContext configContext) { + ConfigurationContext configContext) throws AxisFault { this.jsonReader = jsonReader; initXmlStreamReader(elementQname, xmlSchemaList, configContext); } @@ -96,16 +97,20 @@ public class GsonXMLStreamReader impleme return jsonReader; } - public void initXmlStreamReader(QName elementQname, List<XmlSchema> xmlSchemaList, ConfigurationContext configContext) { + public void initXmlStreamReader(QName elementQname, List<XmlSchema> xmlSchemaList, ConfigurationContext configContext) throws AxisFault { this.elementQname = elementQname; this.xmlSchemaList = xmlSchemaList; this.configContext = configContext; - process(); + try { + process(); + } catch (AxisFault axisFault) { + throw new AxisFault("Error while initializing XMLStreamReader ", axisFault); + } isProcessed = true; } - private void process() { + private void process() throws AxisFault { Object ob = configContext.getProperty(JsonConstant.XMLNODES); if (ob != null) { Map<QName, XmlNode> nodeMap = (Map<QName, XmlNode>) ob; Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java Sun Dec 17 22:34:08 2017 @@ -653,9 +653,11 @@ public class GsonXMLStreamWriter impleme public void writeStartDocument(String encoding, String version) throws XMLStreamException { if (!isProcessed) { - xmlNodeGenerator.getMainXmlNode(); - queue = xmlNodeGenerator.getQueue(mainXmlNode); - isProcessed = true; + try { + process(); + } catch (IOException e) { + throw new XMLStreamException("Error occur while trying to write start document element", e); + } } } @@ -672,7 +674,7 @@ public class GsonXMLStreamWriter impleme try { process(); } catch (IOException e) { - throw new XMLStreamException("Error occur while trying to write first begin object "); + throw new XMLStreamException("Error occur while trying to write first begin object ", e); } } try { Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java Sun Dec 17 22:34:08 2017 @@ -20,22 +20,27 @@ package org.apache.axis2.json.gson; 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 org.apache.axis2.AxisFault; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.AxisOperation; import org.apache.axis2.engine.MessageReceiver; import org.apache.axis2.handlers.AbstractHandler; +import org.apache.axis2.json.gson.factory.JsonConstant; import org.apache.axis2.json.gson.rpc.JsonInOnlyRPCMessageReceiver; import org.apache.axis2.json.gson.rpc.JsonRpcMessageReceiver; -import org.apache.axis2.json.gson.factory.JsonConstant; import org.apache.axis2.wsdl.WSDLConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.ws.commons.schema.XmlSchema; import javax.xml.namespace.QName; import java.util.List; - public class JSONMessageHandler extends AbstractHandler { + Log log = LogFactory.getLog(JSONMessageHandler.class); + /** * This method will be called on each registered handler when a message * needs to be processed. If the message processing is paused by the @@ -53,33 +58,44 @@ public class JSONMessageHandler extends * @param msgContext the <code>MessageContext</code> to process with this * <code>Handler</code>. * @return An InvocationResponse that indicates what - * the next step in the message processing should be. + * the next step in the message processing should be. * @throws org.apache.axis2.AxisFault if the handler encounters an error */ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { - MessageReceiver messageReceiver = msgContext.getAxisOperation().getMessageReceiver(); - if (messageReceiver instanceof JsonRpcMessageReceiver || messageReceiver instanceof JsonInOnlyRPCMessageReceiver) { - // do not need to parse XMLSchema list, as this message receiver will not use GsonXMLStreamReader to read the inputStream. - } else { - Object tempObj = msgContext.getProperty(JsonConstant.IS_JSON_STREAM); - if (tempObj != null) { - boolean isJSON = Boolean.valueOf(tempObj.toString()); - Object o = msgContext.getProperty(JsonConstant.GSON_XML_STREAM_READER); - if (o != null) { - GsonXMLStreamReader gsonXMLStreamReader = (GsonXMLStreamReader) o; - QName elementQname = msgContext.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getElementQName(); - List<XmlSchema> schemas = msgContext.getAxisService().getSchema(); - gsonXMLStreamReader.initXmlStreamReader(elementQname, schemas, msgContext.getConfigurationContext()); - StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(gsonXMLStreamReader); - OMElement omElement = stAXOMBuilder.getDocumentElement(); - msgContext.getEnvelope().getBody().addChild(omElement); + AxisOperation axisOperation = msgContext.getAxisOperation(); + if (axisOperation != null) { + MessageReceiver messageReceiver = axisOperation.getMessageReceiver(); + if (messageReceiver instanceof JsonRpcMessageReceiver || messageReceiver instanceof JsonInOnlyRPCMessageReceiver) { + // do not need to parse XMLSchema list, as this message receiver will not use GsonXMLStreamReader to read the inputStream. + } else { + Object tempObj = msgContext.getProperty(JsonConstant.IS_JSON_STREAM); + if (tempObj != null) { + boolean isJSON = Boolean.valueOf(tempObj.toString()); + Object o = msgContext.getProperty(JsonConstant.GSON_XML_STREAM_READER); + if (o != null) { + GsonXMLStreamReader gsonXMLStreamReader = (GsonXMLStreamReader) o; + QName elementQname = msgContext.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getElementQName(); + List<XmlSchema> schemas = msgContext.getAxisService().getSchema(); + gsonXMLStreamReader.initXmlStreamReader(elementQname, schemas, msgContext.getConfigurationContext()); + OMXMLParserWrapper stAXOMBuilder = OMXMLBuilderFactory.createStAXOMBuilder(gsonXMLStreamReader); + OMElement omElement = stAXOMBuilder.getDocumentElement(); + msgContext.getEnvelope().getBody().addChild(omElement); + } else { + if (log.isDebugEnabled()) { + log.debug("GsonXMLStreamReader is null"); + } + throw new AxisFault("GsonXMLStreamReader should not be null"); + } } else { - throw new AxisFault("GsonXMLStreamReader should not be null"); + // request is not a JSON request so don't need to initialize GsonXMLStreamReader } - } else { - // request is not a JSON request so don't need to initialize GsonXMLStreamReader } + } else { + if (log.isDebugEnabled()) { + log.debug("Axis operation is null"); + } + // message hasn't been dispatched to operation, ignore it } return InvocationResponse.CONTINUE; } Modified: axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java?rev=1818518&r1=1818517&r2=1818518&view=diff ============================================================================== --- axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java (original) +++ axis/axis2/java/core/branches/AXIS2-4091/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java Sun Dec 17 22:34:08 2017 @@ -22,35 +22,42 @@ package org.apache.axis2.json.gson; import com.google.gson.stream.JsonReader; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMElement; -import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.builder.Builder; import org.apache.axis2.context.MessageContext; import org.apache.axis2.json.gson.factory.JsonConstant; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; public class JsonBuilder implements Builder { + Log log = LogFactory.getLog(JsonBuilder.class); public OMElement processDocument(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault { messageContext.setProperty(JsonConstant.IS_JSON_STREAM , true); JsonReader jsonReader; String charSetEncoding=null; - try { - charSetEncoding = (String) messageContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); - jsonReader = new JsonReader(new InputStreamReader(inputStream , charSetEncoding)); - GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader); - messageContext.setProperty(JsonConstant.GSON_XML_STREAM_READER , gsonXMLStreamReader); - // dummy envelop - SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory(); - SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope(); - return soapEnvelope; - } catch (UnsupportedEncodingException e) { - throw new AxisFault(charSetEncoding + " encoding is may not supported by json inputStream ", e); - } + if (inputStream != null) { + try { + charSetEncoding = (String) messageContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); + jsonReader = new JsonReader(new InputStreamReader(inputStream, charSetEncoding)); + GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader); + messageContext.setProperty(JsonConstant.GSON_XML_STREAM_READER, gsonXMLStreamReader); + } catch (UnsupportedEncodingException e) { + throw new AxisFault(charSetEncoding + " encoding is may not supported by json inputStream ", e); + } + } else { + if (log.isDebugEnabled()) { + log.debug("Inputstream is null, This is possible with GET request"); + } + } + // dummy envelop + SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory(); + return soapFactory.getDefaultEnvelope(); } }
