You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/12/27 14:18:34 UTC
svn commit: r1426190 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/
Author: veithen
Date: Thu Dec 27 13:18:33 2012
New Revision: 1426190
URL: http://svn.apache.org/viewvc?rev=1426190&view=rev
Log:
AXIOM-311: Partially refactored MTOMStAXSOAPModelBuilderTest.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java?rev=1426190&r1=1426189&r2=1426190&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java Thu Dec 27 13:18:33 2012
@@ -32,11 +32,9 @@ import org.apache.axiom.om.TestConstants
import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axiom.util.stax.XMLStreamReaderUtils;
-import org.apache.axiom.util.stax.xop.XOPEncodedStream;
import org.apache.axiom.util.stax.xop.XOPUtils;
import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.io.BufferedInputStream;
@@ -49,9 +47,6 @@ import java.util.List;
public class MTOMStAXSOAPModelBuilderTest extends AbstractTestCase {
- private final static QName XOP_INCLUDE =
- new QName("http://www.w3.org/2004/08/xop/include", "Include");
-
protected void setUp() throws Exception {
super.setUp();
}
@@ -285,44 +280,6 @@ public class MTOMStAXSOAPModelBuilderTes
root.build();
}
- public void testCreateAndXMLStreamReader() throws Exception {
- OMElement root = createTestMTOMMessage();
-
- // Build tree
- root.build();
-
- // Use tree as input to XMLStreamReader
- // Issue XOP:Include events for optimized MTOM text nodes
- XOPEncodedStream xopEncodedStream = XOPUtils.getXOPEncodedStream(root.getXMLStreamReader());
- XMLStreamReader xmlStreamReader = xopEncodedStream.getReader();
-
- DataHandler dh = null;
- while(xmlStreamReader.hasNext() && dh == null) {
- xmlStreamReader.next();
- if (xmlStreamReader.isStartElement()) {
- QName qName =xmlStreamReader.getName();
- if (XOP_INCLUDE.equals(qName)) {
- String hrefValue = xmlStreamReader.getAttributeValue("", "href");
- if (hrefValue != null) {
- dh = xopEncodedStream.getMimePartProvider().getDataHandler(
- XOPUtils.getContentIDFromURL(hrefValue));
- }
- }
- }
- }
- assertTrue(dh != null);
-
- // Make sure next event is an an XOP_Include END element
- xmlStreamReader.next();
- assertTrue(xmlStreamReader.isEndElement());
- assertTrue(XOP_INCLUDE.equals(xmlStreamReader.getName()));
-
- // Make sure the next event is the end tag of name
- xmlStreamReader.next();
- assertTrue(xmlStreamReader.isEndElement());
- assertTrue("name".equals(xmlStreamReader.getLocalName()));
- }
-
private byte[] append(byte[] a, byte[] b) {
byte[] z = new byte[a.length + b.length];
System.arraycopy(a, 0, z, 0, a.length);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1426190&r1=1426189&r2=1426190&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Thu Dec 27 13:18:33 2012
@@ -267,5 +267,6 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap12.header.TestExamineMustUnderstandHeaderBlocksWithParser(metaFactory));
addTest(new org.apache.axiom.ts.soap12.header.TestGetHeaderBlocksWithNSURIWithParser(metaFactory));
addTest(new org.apache.axiom.ts.soap12.header.TestGetHeadersToProcessWithParser(metaFactory));
+ addTest(new org.apache.axiom.ts.soap12.mtom.TestGetXMLStreamReaderMTOMEncoded(metaFactory));
}
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java?rev=1426190&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java Thu Dec 27 13:18:33 2012
@@ -0,0 +1,84 @@
+/*
+ * 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.axiom.ts.soap12.mtom;
+
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.TestConstants;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.util.stax.xop.XOPEncodedStream;
+import org.apache.axiom.util.stax.xop.XOPUtils;
+
+public class TestGetXMLStreamReaderMTOMEncoded extends AxiomTestCase {
+ private final static QName XOP_INCLUDE =
+ new QName("http://www.w3.org/2004/08/xop/include", "Include");
+
+ public TestGetXMLStreamReaderMTOMEncoded(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ InputStream inStream = AbstractTestCase.getTestResource(TestConstants.MTOM_MESSAGE_2.getName());
+ Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_2.getContentType());
+ OMElement root = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, attachments).getDocumentElement();
+
+ // Build tree
+ root.build();
+
+ // Use tree as input to XMLStreamReader
+ // Issue XOP:Include events for optimized MTOM text nodes
+ XOPEncodedStream xopEncodedStream = XOPUtils.getXOPEncodedStream(root.getXMLStreamReader());
+ XMLStreamReader xmlStreamReader = xopEncodedStream.getReader();
+
+ DataHandler dh = null;
+ while(xmlStreamReader.hasNext() && dh == null) {
+ xmlStreamReader.next();
+ if (xmlStreamReader.isStartElement()) {
+ QName qName =xmlStreamReader.getName();
+ if (XOP_INCLUDE.equals(qName)) {
+ String hrefValue = xmlStreamReader.getAttributeValue("", "href");
+ if (hrefValue != null) {
+ dh = xopEncodedStream.getMimePartProvider().getDataHandler(
+ XOPUtils.getContentIDFromURL(hrefValue));
+ }
+ }
+ }
+ }
+ assertTrue(dh != null);
+
+ // Make sure next event is an an XOP_Include END element
+ xmlStreamReader.next();
+ assertTrue(xmlStreamReader.isEndElement());
+ assertTrue(XOP_INCLUDE.equals(xmlStreamReader.getName()));
+
+ // Make sure the next event is the end tag of name
+ xmlStreamReader.next();
+ assertTrue(xmlStreamReader.isEndElement());
+ assertTrue("name".equals(xmlStreamReader.getLocalName()));
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
------------------------------------------------------------------------------
svn:eol-style = native