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 2014/06/29 17:22:29 UTC
svn commit: r1606522 - in /webservices/axiom/trunk/modules:
axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/
axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/
axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
axiom-testsuite/src/ma...
Author: veithen
Date: Sun Jun 29 15:22:28 2014
New Revision: 1606522
URL: http://svn.apache.org/r1606522
Log:
Increase SOAPFactory test coverage.
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/CreateSOAPElementWithoutParentTestCase.java
- copied, changed from r1605161, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java (with props)
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java (with props)
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFaultChildAdapter.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java
Modified: webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-dom/src/test/java/org/apache/axiom/soap/impl/dom/SOAPImplementationTest.java Sun Jun 29 15:22:28 2014
@@ -23,11 +23,15 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
import org.apache.axiom.ts.soap.SOAPTestSuiteBuilder;
+import org.apache.axiom.ts.soap.factory.TestCreateSOAPElementWithNullParent;
public class SOAPImplementationTest extends TestCase {
public static TestSuite suite() {
SOAPTestSuiteBuilder builder = new SOAPTestSuiteBuilder(new OMDOMMetaFactory(), false, false);
+ // TODO: need to decide what the correct behavior is (other OMFactory methods allow null parents)
+ builder.exclude(TestCreateSOAPElementWithNullParent.class);
+
return builder.build();
}
}
Modified: webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-impl/src/test/java/org/apache/axiom/soap/impl/llom/SOAPImplementationTest.java Sun Jun 29 15:22:28 2014
@@ -24,6 +24,7 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListMetaFactory;
import org.apache.axiom.ts.soap.SOAPTestSuiteBuilder;
import org.apache.axiom.ts.soap.envelope.TestClone;
+import org.apache.axiom.ts.soap.factory.TestCreateSOAPElementWithNullParent;
public class SOAPImplementationTest extends TestCase {
public static TestSuite suite() {
@@ -32,6 +33,9 @@ public class SOAPImplementationTest exte
// TODO
builder.exclude(TestClone.class, "(message=soap/soap11/soapfault2.xml)");
+ // TODO: need to decide what the correct behavior is (other OMFactory methods allow null parents)
+ builder.exclude(TestCreateSOAPElementWithNullParent.class);
+
return builder.build();
}
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java Sun Jun 29 15:22:28 2014
@@ -40,4 +40,5 @@ public abstract class SOAPElementTypeAda
}
public abstract OMElement create(SOAPFactory factory);
+ public abstract OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java Sun Jun 29 15:22:28 2014
@@ -40,24 +40,48 @@ public class SOAPElementTypeAdapterFacto
public OMElement create(SOAPFactory factory) {
return factory.createSOAPEnvelope();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ throw new UnsupportedOperationException();
+ }
});
} else if (type == SOAPElementType.HEADER) {
adapters.add(new SOAPElementTypeAdapter(SOAPHeader.class) {
public OMElement create(SOAPFactory factory) {
return factory.createSOAPHeader();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPHeader((SOAPEnvelope)parent);
+ }
});
} else if (type == SOAPElementType.BODY) {
adapters.add(new SOAPElementTypeAdapter(SOAPBody.class) {
public OMElement create(SOAPFactory factory) {
return factory.createSOAPBody();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPBody((SOAPEnvelope)parent);
+ }
});
} else if (type == SOAPElementType.FAULT) {
adapters.add(new SOAPElementTypeAdapter(SOAPFault.class) {
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFault();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFault((SOAPBody)parent);
+ }
});
} else if (type == SOAPFaultChild.CODE) {
adapters.add(new SOAPFaultChildAdapter(SOAPFaultCode.class) {
@@ -65,8 +89,9 @@ public class SOAPElementTypeAdapterFacto
return factory.createSOAPFaultCode();
}
- public OMElement create(SOAPFactory factory, SOAPFault parent) {
- return factory.createSOAPFaultCode(parent);
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultCode((SOAPFault)parent);
}
public void set(SOAPFault fault, OMElement element) {
@@ -78,12 +103,32 @@ public class SOAPElementTypeAdapterFacto
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultValue();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ if (parentType == SOAPFaultChild.CODE) {
+ return factory.createSOAPFaultValue((SOAPFaultCode)parent);
+ } else {
+ return factory.createSOAPFaultValue((SOAPFaultSubCode)parent);
+ }
+ }
});
} else if (type == SOAPElementType.SUB_CODE) {
adapters.add(new SOAPElementTypeAdapter(SOAPFaultSubCode.class) {
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultSubCode();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ if (parentType == SOAPFaultChild.CODE) {
+ return factory.createSOAPFaultSubCode((SOAPFaultCode)parent);
+ } else {
+ return factory.createSOAPFaultSubCode((SOAPFaultSubCode)parent);
+ }
+ }
});
} else if (type == SOAPFaultChild.REASON) {
adapters.add(new SOAPFaultChildAdapter(SOAPFaultReason.class) {
@@ -91,8 +136,9 @@ public class SOAPElementTypeAdapterFacto
return factory.createSOAPFaultReason();
}
- public OMElement create(SOAPFactory factory, SOAPFault parent) {
- return factory.createSOAPFaultReason(parent);
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultReason((SOAPFault)parent);
}
public void set(SOAPFault fault, OMElement element) {
@@ -104,6 +150,12 @@ public class SOAPElementTypeAdapterFacto
public OMElement create(SOAPFactory factory) {
return factory.createSOAPFaultText();
}
+
+ @Override
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultText((SOAPFaultReason)parent);
+ }
});
} else if (type == SOAPFaultChild.NODE) {
adapters.add(new SOAPFaultChildAdapter(SOAPFaultNode.class) {
@@ -111,8 +163,9 @@ public class SOAPElementTypeAdapterFacto
return factory.createSOAPFaultNode();
}
- public OMElement create(SOAPFactory factory, SOAPFault parent) {
- return factory.createSOAPFaultNode(parent);
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultNode((SOAPFault)parent);
}
public void set(SOAPFault fault, OMElement element) {
@@ -125,8 +178,9 @@ public class SOAPElementTypeAdapterFacto
return factory.createSOAPFaultRole();
}
- public OMElement create(SOAPFactory factory, SOAPFault parent) {
- return factory.createSOAPFaultRole(parent);
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultRole((SOAPFault)parent);
}
public void set(SOAPFault fault, OMElement element) {
@@ -139,8 +193,9 @@ public class SOAPElementTypeAdapterFacto
return factory.createSOAPFaultDetail();
}
- public OMElement create(SOAPFactory factory, SOAPFault parent) {
- return factory.createSOAPFaultDetail(parent);
+ public OMElement create(SOAPFactory factory, SOAPElementType parentType,
+ OMElement parent) {
+ return factory.createSOAPFaultDetail((SOAPFault)parent);
}
public void set(SOAPFault fault, OMElement element) {
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFaultChildAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFaultChildAdapter.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFaultChildAdapter.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFaultChildAdapter.java Sun Jun 29 15:22:28 2014
@@ -19,7 +19,6 @@
package org.apache.axiom.ts.soap;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
@AdapterType
@@ -28,6 +27,5 @@ public abstract class SOAPFaultChildAdap
super(type);
}
- public abstract OMElement create(SOAPFactory factory, SOAPFault parent);
public abstract void set(SOAPFault fault, OMElement element);
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sun Jun 29 15:22:28 2014
@@ -172,6 +172,12 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPEnvelopeWithCustomPrefix(metaFactory, spec));
for (SOAPElementType type : SOAPElementType.getAll()) {
addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPElement(metaFactory, spec, type));
+ for (SOAPElementType childType : type.getChildTypes()) {
+ addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPElementWithNullParent(metaFactory, spec, childType, type));
+ if (type.getQName(spec) != null) {
+ addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPElementWithParent(metaFactory, spec, childType, type));
+ }
+ }
}
addTest(new org.apache.axiom.ts.soap.factory.TestCreateSOAPFaultWithParent(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.factory.TestFactoryIsSingleton(metaFactory, spec));
Copied: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/CreateSOAPElementWithoutParentTestCase.java (from r1605161, webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/CreateSOAPElementWithoutParentTestCase.java?p2=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/CreateSOAPElementWithoutParentTestCase.java&p1=webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java&r1=1605161&r2=1606522&rev=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/CreateSOAPElementWithoutParentTestCase.java Sun Jun 29 15:22:28 2014
@@ -26,44 +26,38 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAPConstants;
-import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.ts.soap.SOAPElementType;
import org.apache.axiom.ts.soap.SOAPElementTypeAdapter;
import org.apache.axiom.ts.soap.SOAPSpec;
import org.apache.axiom.ts.soap.SOAPTestCase;
-/**
- * Tests {@link SOAPFactory#createSOAPEnvelope()}, {@link SOAPFactory#createSOAPFaultCode()},
- * {@link SOAPFactory#createSOAPFaultValue()}, {@link SOAPFactory#createSOAPFaultSubCode()},
- * {@link SOAPFactory#createSOAPFaultReason()}, {@link SOAPFactory#createSOAPFaultText()},
- * {@link SOAPFactory#createSOAPFaultRole()} and {@link SOAPFactory#createSOAPFaultDetail()}.
- */
-public class TestCreateSOAPElement extends SOAPTestCase {
- private final SOAPElementType type;
+public abstract class CreateSOAPElementWithoutParentTestCase extends SOAPTestCase {
+ protected final SOAPElementType type;
- public TestCreateSOAPElement(OMMetaFactory metaFactory, SOAPSpec spec, SOAPElementType type) {
+ public CreateSOAPElementWithoutParentTestCase(OMMetaFactory metaFactory, SOAPSpec spec, SOAPElementType type) {
super(metaFactory, spec);
this.type = type;
type.getAdapter(SOAPElementTypeAdapter.class).addTestParameters(this);
}
- protected void runTest() throws Throwable {
+ protected final void runTest() throws Throwable {
QName expectedName = type.getQName(spec);
if (expectedName == null) {
try {
- type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
+ createSOAPElement();
fail("Expect UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// Expected
}
} else {
String expectedPrefix = expectedName.getNamespaceURI().length() == 0 ? "" : SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX;
- OMElement child = type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
- QName actualName = child.getQName();
+ OMElement element = createSOAPElement();
+ assertTrue(element.isComplete());
+ QName actualName = element.getQName();
assertEquals(expectedName, actualName);
assertEquals(expectedPrefix, actualName.getPrefix());
- assertNull(child.getParent());
- Iterator it = child.getAllDeclaredNamespaces();
+ assertNull(element.getParent());
+ Iterator it = element.getAllDeclaredNamespaces();
if (expectedPrefix.length() != 0) {
assertTrue(it.hasNext());
OMNamespace ns = (OMNamespace)it.next();
@@ -71,8 +65,10 @@ public class TestCreateSOAPElement exten
assertEquals(expectedPrefix, ns.getPrefix());
}
assertFalse(it.hasNext());
- assertFalse(child.getAllAttributes().hasNext());
- assertNull(child.getFirstOMChild());
+ assertFalse(element.getAllAttributes().hasNext());
+ assertNull(element.getFirstOMChild());
}
}
+
+ protected abstract OMElement createSOAPElement();
}
Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java?rev=1606522&r1=1606521&r2=1606522&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java (original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElement.java Sun Jun 29 15:22:28 2014
@@ -18,61 +18,28 @@
*/
package org.apache.axiom.ts.soap.factory;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPConstants;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.ts.soap.SOAPElementType;
import org.apache.axiom.ts.soap.SOAPElementTypeAdapter;
import org.apache.axiom.ts.soap.SOAPSpec;
-import org.apache.axiom.ts.soap.SOAPTestCase;
/**
- * Tests {@link SOAPFactory#createSOAPEnvelope()}, {@link SOAPFactory#createSOAPFaultCode()},
- * {@link SOAPFactory#createSOAPFaultValue()}, {@link SOAPFactory#createSOAPFaultSubCode()},
- * {@link SOAPFactory#createSOAPFaultReason()}, {@link SOAPFactory#createSOAPFaultText()},
+ * Tests {@link SOAPFactory#createSOAPEnvelope()}, {@link SOAPFactory#createSOAPHeader()},
+ * {@link SOAPFactory#createSOAPBody()}, {@link SOAPFactory#createSOAPFault()},
+ * {@link SOAPFactory#createSOAPFaultCode()}, {@link SOAPFactory#createSOAPFaultValue()},
+ * {@link SOAPFactory#createSOAPFaultSubCode()}, {@link SOAPFactory#createSOAPFaultReason()},
+ * {@link SOAPFactory#createSOAPFaultText()}, {@link SOAPFactory#createSOAPFaultNode()},
* {@link SOAPFactory#createSOAPFaultRole()} and {@link SOAPFactory#createSOAPFaultDetail()}.
*/
-public class TestCreateSOAPElement extends SOAPTestCase {
- private final SOAPElementType type;
-
+public class TestCreateSOAPElement extends CreateSOAPElementWithoutParentTestCase {
public TestCreateSOAPElement(OMMetaFactory metaFactory, SOAPSpec spec, SOAPElementType type) {
- super(metaFactory, spec);
- this.type = type;
- type.getAdapter(SOAPElementTypeAdapter.class).addTestParameters(this);
+ super(metaFactory, spec, type);
}
- protected void runTest() throws Throwable {
- QName expectedName = type.getQName(spec);
- if (expectedName == null) {
- try {
- type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
- fail("Expect UnsupportedOperationException");
- } catch (UnsupportedOperationException ex) {
- // Expected
- }
- } else {
- String expectedPrefix = expectedName.getNamespaceURI().length() == 0 ? "" : SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX;
- OMElement child = type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
- QName actualName = child.getQName();
- assertEquals(expectedName, actualName);
- assertEquals(expectedPrefix, actualName.getPrefix());
- assertNull(child.getParent());
- Iterator it = child.getAllDeclaredNamespaces();
- if (expectedPrefix.length() != 0) {
- assertTrue(it.hasNext());
- OMNamespace ns = (OMNamespace)it.next();
- assertEquals(expectedName.getNamespaceURI(), ns.getNamespaceURI());
- assertEquals(expectedPrefix, ns.getPrefix());
- }
- assertFalse(it.hasNext());
- assertFalse(child.getAllAttributes().hasNext());
- assertNull(child.getFirstOMChild());
- }
+ @Override
+ protected OMElement createSOAPElement() {
+ return type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
}
}
Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java?rev=1606522&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java Sun Jun 29 15:22:28 2014
@@ -0,0 +1,61 @@
+/*
+ * 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.factory;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultReason;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.ts.soap.SOAPElementType;
+import org.apache.axiom.ts.soap.SOAPElementTypeAdapter;
+import org.apache.axiom.ts.soap.SOAPSpec;
+
+/**
+ * Tests {@link SOAPFactory#createSOAPHeader(SOAPEnvelope)},
+ * {@link SOAPFactory#createSOAPBody(SOAPEnvelope)}, {@link SOAPFactory#createSOAPFault(SOAPBody)},
+ * {@link SOAPFactory#createSOAPFaultCode(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultValue(SOAPFaultCode)},
+ * {@link SOAPFactory#createSOAPFaultValue(SOAPFaultSubCode)},
+ * {@link SOAPFactory#createSOAPFaultSubCode(SOAPFaultCode)},
+ * {@link SOAPFactory#createSOAPFaultSubCode(SOAPFaultSubCode)},
+ * {@link SOAPFactory#createSOAPFaultReason(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultText(SOAPFaultReason)},
+ * {@link SOAPFactory#createSOAPFaultNode(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultRole(SOAPFault)} and
+ * {@link SOAPFactory#createSOAPFaultDetail(SOAPFault)} with a null parent.
+ */
+public class TestCreateSOAPElementWithNullParent extends CreateSOAPElementWithoutParentTestCase {
+ private final SOAPElementType parentType;
+
+ public TestCreateSOAPElementWithNullParent(OMMetaFactory metaFactory, SOAPSpec spec, SOAPElementType type, SOAPElementType parentType) {
+ super(metaFactory, spec, type);
+ this.parentType = parentType;
+ addTestParameter("parentType", parentType.getAdapter(SOAPElementTypeAdapter.class).getType().getSimpleName());
+ }
+
+ @Override
+ protected OMElement createSOAPElement() {
+ return type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory, parentType, null);
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithNullParent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java?rev=1606522&view=auto
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java (added)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java Sun Jun 29 15:22:28 2014
@@ -0,0 +1,90 @@
+/*
+ * 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.factory;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPConstants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFault;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultReason;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.ts.soap.SOAPElementType;
+import org.apache.axiom.ts.soap.SOAPElementTypeAdapter;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests {@link SOAPFactory#createSOAPHeader(SOAPEnvelope)},
+ * {@link SOAPFactory#createSOAPBody(SOAPEnvelope)}, {@link SOAPFactory#createSOAPFault(SOAPBody)},
+ * {@link SOAPFactory#createSOAPFaultCode(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultValue(SOAPFaultCode)},
+ * {@link SOAPFactory#createSOAPFaultValue(SOAPFaultSubCode)},
+ * {@link SOAPFactory#createSOAPFaultSubCode(SOAPFaultCode)},
+ * {@link SOAPFactory#createSOAPFaultSubCode(SOAPFaultSubCode)},
+ * {@link SOAPFactory#createSOAPFaultReason(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultText(SOAPFaultReason)},
+ * {@link SOAPFactory#createSOAPFaultNode(SOAPFault)},
+ * {@link SOAPFactory#createSOAPFaultRole(SOAPFault)} and
+ * {@link SOAPFactory#createSOAPFaultDetail(SOAPFault)} with a non null parent.
+ */
+public class TestCreateSOAPElementWithParent extends SOAPTestCase {
+ private final SOAPElementType type;
+ private final SOAPElementType parentType;
+
+ public TestCreateSOAPElementWithParent(OMMetaFactory metaFactory, SOAPSpec spec, SOAPElementType type, SOAPElementType parentType) {
+ super(metaFactory, spec);
+ this.type = type;
+ this.parentType = parentType;
+ addTestParameter("type", type.getAdapter(SOAPElementTypeAdapter.class).getType().getSimpleName());
+ addTestParameter("parentType", parentType.getAdapter(SOAPElementTypeAdapter.class).getType().getSimpleName());
+ }
+
+ protected void runTest() throws Throwable {
+ OMElement parent = parentType.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory);
+ QName expectedName = type.getQName(spec);
+ if (expectedName == null) {
+ try {
+ type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory, parentType, parent);
+ fail("Expect UnsupportedOperationException");
+ } catch (UnsupportedOperationException ex) {
+ // Expected
+ }
+ } else {
+ String expectedPrefix = expectedName.getNamespaceURI().length() == 0 ? "" : SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX;
+ OMElement child = type.getAdapter(SOAPElementTypeAdapter.class).create(soapFactory, parentType, parent);
+ assertTrue(child.isComplete());
+ QName actualName = child.getQName();
+ assertEquals(expectedName, actualName);
+ assertEquals(expectedPrefix, actualName.getPrefix());
+ assertSame(parent, child.getParent());
+ assertSame(child, parent.getFirstOMChild());
+ assertNull(child.getNextOMSibling());
+ // All relevant namespaces have already been declared on the parent
+ assertFalse(child.getAllDeclaredNamespaces().hasNext());
+ assertFalse(child.getAllAttributes().hasNext());
+ assertNull(child.getFirstOMChild());
+ }
+ }
+}
Propchange: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/factory/TestCreateSOAPElementWithParent.java
------------------------------------------------------------------------------
svn:eol-style = native