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/02/24 21:37:24 UTC
svn commit: r1293403 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/
axiom-testsuite/src/main/java/org/apache/axiom/ts/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/
Author: veithen
Date: Fri Feb 24 20:37:24 2012
New Revision: 1293403
URL: http://svn.apache.org/viewvc?rev=1293403&view=rev
Log:
Increased test coverage.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java (with props)
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/SOAPTestSuiteBuilder.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java?rev=1293403&r1=1293402&r2=1293403&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMContainerHelper.java Fri Feb 24 20:37:24 2012
@@ -46,6 +46,8 @@ class OMContainerHelper {
if (builder != null && builder instanceof StAXOMBuilder) {
if (!container.isComplete()) {
if (((StAXOMBuilder) builder).isLookahead()) {
+ // TODO: not sure if this is actually still relevant;
+ // there is no test case that fails when this is removed
container.buildNext();
}
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/SOAPTestSuiteBuilder.java?rev=1293403&r1=1293402&r2=1293403&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/SOAPTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/SOAPTestSuiteBuilder.java Fri Feb 24 20:37:24 2012
@@ -49,6 +49,7 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeader(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestGetHeaderWithParser(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNS(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.envelope.TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestHasFault(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.envelope.TestHasFaultWithParser(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPEnvelope(metaFactory, spec));
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java?rev=1293403&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java Fri Feb 24 20:37:24 2012
@@ -0,0 +1,69 @@
+/*
+ * 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.soap.envelope;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests the behavior of {@link SOAPEnvelope#getSOAPBodyFirstElementLocalName()} and
+ * {@link SOAPEnvelope#getSOAPBodyFirstElementNS()} for a {@link SOAPEnvelope} constructed from a
+ * parser. In this case, the Axiom implementation may choose to use a special optimization to get
+ * the name of the element without actually instantiating the corresponding {@link OMElement}.
+ */
+public class TestGetSOAPBodyFirstElementLocalNameAndNSWithParser extends SOAPTestCase {
+ public TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ protected void runTest() throws Throwable {
+ // Prepare the message. Note that we do this programmatically to make sure that the message
+ // doesn't contain any unwanted whitespace.
+ SOAPFactory factory = spec.getFactory(metaFactory);
+ SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
+ OMNamespace ns = factory.createOMNamespace("urn:test", "ns");
+ factory.createOMElement("echo", ns, orgEnvelope.getBody());
+ String message = orgEnvelope.toString();
+
+ SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(message)).getSOAPEnvelope();
+ assertEquals("echo", envelope.getSOAPBodyFirstElementLocalName());
+ assertEquals(ns, envelope.getSOAPBodyFirstElementNS());
+
+ // Also request an XMLStreamReader. The LLOM implementation triggers some special processing
+ // in this case (because the getSOAPBodyFirstElementXXX calls put the builder in lookahead
+ // mode).
+ XMLStreamReader reader = envelope.getBody().getXMLStreamReader();
+ assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+ assertEquals("Body", reader.getLocalName());
+ assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
+ assertEquals("echo", reader.getLocalName());
+ assertEquals("ns", reader.getPrefix());
+ assertEquals("urn:test", reader.getNamespaceURI());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
------------------------------------------------------------------------------
svn:eol-style = native