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/05/04 13:40:26 UTC
svn commit: r1333884 - in
/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap:
./ body/
Author: veithen
Date: Fri May 4 11:40:26 2012
New Revision: 1333884
URL: http://svn.apache.org/viewvc?rev=1333884&view=rev
Log:
Added some unit tests to more thoroughly test the optimization implemented by AXIOM-282 so that we can safely modify that code to take into account AXIOM-399.
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java (with props)
Modified:
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-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=1333884&r1=1333883&r2=1333884&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 Fri May 4 11:40:26 2012
@@ -63,6 +63,15 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.body.TestAddFault2(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.body.TestGetFault(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.body.TestGetFaultWithParser(metaFactory, spec));
+ for (int i=0; i<qnames.length; i++) {
+ QName qname = qnames[i];
+ addTest(new org.apache.axiom.ts.soap.body.TestGetFirstElementLocalNameWithParser(metaFactory, spec,
+ qname, supportsBodyElementNameOptimization));
+ addTest(new org.apache.axiom.ts.soap.body.TestGetFirstElementNSWithParser(metaFactory, spec,
+ qname, supportsBodyElementNameOptimization));
+ addTest(new org.apache.axiom.ts.soap.body.TestHasFaultWithParserNoFault(metaFactory, spec,
+ qname, supportsBodyElementNameOptimization));
+ }
addTest(new org.apache.axiom.ts.soap.body.TestHasFault(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.body.TestHasFaultWithParser(metaFactory, spec));
if (supportsBodyElementNameOptimization) {
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java?rev=1333884&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java Fri May 4 11:40:26 2012
@@ -0,0 +1,76 @@
+/*
+ * 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.body;
+
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.impl.builder.CustomBuilder;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPModelBuilder;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+public abstract class FirstElementNameWithParserTestCase extends SOAPTestCase {
+ protected final QName qname;
+ private final boolean supportsOptimization;
+
+ public FirstElementNameWithParserTestCase(OMMetaFactory metaFactory,
+ SOAPSpec spec, QName qname, boolean supportsOptimization) {
+ super(metaFactory, spec);
+ this.qname = qname;
+ addTestProperty("prefix", qname.getPrefix());
+ addTestProperty("uri", qname.getNamespaceURI());
+ this.supportsOptimization = supportsOptimization;
+ }
+
+ protected final void runTest() throws Throwable {
+ SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
+ orgEnvelope.getBody().addChild(soapFactory.createOMElement(
+ qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
+ SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
+ new StringReader(orgEnvelope.toString()));
+ if (supportsOptimization) {
+ // To detect if the child element is instantiated or not, we register a custom
+ // builder that throws an exception.
+ ((StAXSOAPModelBuilder)builder).registerCustomBuilderForPayload(new CustomBuilder() {
+ public OMElement create(String namespace, String localPart,
+ OMContainer parent, XMLStreamReader reader, OMFactory factory)
+ throws OMException {
+ throw new AssertionFailedError("Custom builder called.");
+ }
+ });
+ }
+ runTest(builder.getSOAPEnvelope().getBody());
+ }
+
+ protected abstract void runTest(SOAPBody body) throws Throwable;
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/FirstElementNameWithParserTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java?rev=1333884&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java Fri May 4 11:40:26 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.body;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.ts.soap.SOAPSpec;
+
+/**
+ * Tests {@link SOAPBody#getFirstElementLocalName()}, in particular the optimization described by <a
+ * href="https://issues.apache.org/jira/browse/AXIOM-282">AXIOM-282</a>.
+ */
+public class TestGetFirstElementLocalNameWithParser extends FirstElementNameWithParserTestCase {
+ public TestGetFirstElementLocalNameWithParser(OMMetaFactory metaFactory,
+ SOAPSpec spec, QName qname, boolean supportsOptimization) {
+ super(metaFactory, spec, qname, supportsOptimization);
+ }
+
+ protected void runTest(SOAPBody body) throws Throwable {
+ assertEquals(qname.getLocalPart(), body.getFirstElementLocalName());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementLocalNameWithParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java?rev=1333884&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java Fri May 4 11:40:26 2012
@@ -0,0 +1,47 @@
+/*
+ * 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.body;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.ts.soap.SOAPSpec;
+
+/**
+ * Tests {@link SOAPBody#getFirstElementNS()}, in particular the optimization described by <a
+ * href="https://issues.apache.org/jira/browse/AXIOM-282">AXIOM-282</a>.
+ */
+public class TestGetFirstElementNSWithParser extends FirstElementNameWithParserTestCase {
+ public TestGetFirstElementNSWithParser(OMMetaFactory metaFactory,
+ SOAPSpec spec, QName qname, boolean supportsOptimization) {
+ super(metaFactory, spec, qname, supportsOptimization);
+ }
+
+ protected void runTest(SOAPBody body) throws Throwable {
+ OMNamespace ns = body.getFirstElementNS();
+ if (qname.getNamespaceURI().length() == 0) {
+ assertNull(ns);
+ } else {
+ assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+ assertEquals(qname.getPrefix(), ns.getPrefix());
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestGetFirstElementNSWithParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java?rev=1333884&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java Fri May 4 11:40:26 2012
@@ -0,0 +1,41 @@
+/*
+ * 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.body;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.ts.soap.SOAPSpec;
+
+/**
+ * Tests {@link SOAPBody#hasFault()} in the case where the body doesn't contain a SOAP fault. In
+ * particular the test validates the optimization described by <a
+ * href="https://issues.apache.org/jira/browse/AXIOM-282">AXIOM-282</a>.
+ */
+public class TestHasFaultWithParserNoFault extends FirstElementNameWithParserTestCase {
+ public TestHasFaultWithParserNoFault(OMMetaFactory metaFactory,
+ SOAPSpec spec, QName qname, boolean supportsOptimization) {
+ super(metaFactory, spec, qname, supportsOptimization);
+ }
+
+ protected void runTest(SOAPBody body) throws Throwable {
+ assertFalse(body.hasFault());
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/body/TestHasFaultWithParserNoFault.java
------------------------------------------------------------------------------
svn:eol-style = native