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 2015/05/06 00:34:48 UTC
svn commit: r1677901 [1/2] - in /webservices/axiom/trunk:
modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/
modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/
modules/axiom-compat/src/test/java/org/apache/axiom/om/imp...
Author: veithen
Date: Tue May 5 22:34:47 2015
New Revision: 1677901
URL: http://svn.apache.org/r1677901
Log:
Use a smarter way to manage multitons.
Added:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.testing.multiton.AdapterFactory
- copied unchanged from r1677866, webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
webservices/axiom/trunk/testing/multiton/pom.xml (with props)
webservices/axiom/trunk/testing/multiton/src/
webservices/axiom/trunk/testing/multiton/src/main/
webservices/axiom/trunk/testing/multiton/src/main/java/
webservices/axiom/trunk/testing/multiton/src/main/java/org/
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterFactory.java
- copied, changed from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterFactory.java
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterType.java
- copied, changed from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterType.java
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Adapters.java
- copied, changed from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adapters.java
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java (with props)
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Multiton.java
- copied, changed from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adaptable.java
webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java (with props)
webservices/axiom/trunk/testing/saaj-testsuite/src/main/resources/META-INF/services/org.apache.axiom.testing.multiton.AdapterFactory
- copied unchanged from r1677866, webservices/axiom/trunk/testing/saaj-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/resources/META-INF/services/org.apache.axiom.testing.multiton.AdapterFactory
- copied unchanged from r1677866, webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
Removed:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/Strategies.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
webservices/axiom/trunk/testing/saaj-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adaptable.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterFactory.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterType.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adapters.java
webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/resources/META-INF/services/org.apache.axiom.ts.soap.AdapterFactory
Modified:
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java
webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
webservices/axiom/trunk/modules/axiom-compat/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/SAXResultSAXParserTest.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/AddAttributeStrategy.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/BuilderFactory.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ElementContext.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ExpansionStrategy.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/NoNamespaceStrategy.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializationStrategy.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromSAXSource.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromXMLStreamReader.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToOutputStream.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToWriter.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToXMLStreamWriter.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAccessor.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAdapterFactory.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/FactorySelector.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpecAdapterFactory.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java
webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
webservices/axiom/trunk/testing/multiton/ (props changed)
webservices/axiom/trunk/testing/pom.xml
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/FactorySelector.java
webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SOAPSpecAdapterFactory.java
webservices/axiom/trunk/testing/soap-testsuite/pom.xml
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementType.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java
webservices/axiom/trunk/testing/soap-testsuite/src/test/java/org/apache/axiom/ts/soap/ValidationTest.java
webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapter.java
webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapterFactory.java
webservices/axiom/trunk/testing/testutils/pom.xml
webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java
Modified: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/serialize/StreamingOMSerializerTest.java Tue May 5 22:34:47 2015
@@ -21,6 +21,7 @@ package org.apache.axiom.om.impl.seriali
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
@@ -31,6 +32,7 @@ import javax.xml.transform.stream.Stream
import junit.framework.TestSuite;
import org.apache.axiom.om.AbstractTestCase;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.util.stax.dialect.StAXDialect;
@@ -66,9 +68,8 @@ public class StreamingOMSerializerTest e
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite();
- ConformanceTestFile[] files = ConformanceTestFile.getConformanceTestFiles();
- for (int i=0; i<files.length; i++) {
- ConformanceTestFile file = files[i];
+ for (Iterator it = Multiton.getInstances(ConformanceTestFile.class).iterator(); it.hasNext(); ) {
+ ConformanceTestFile file = (ConformanceTestFile)it.next();
suite.addTest(new StreamingOMSerializerTest(file.getShortName(), file));
}
return suite;
Modified: webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/modules/axiom-api/src/test/java/org/apache/axiom/util/stax/dialect/DialectTestSuiteBuilder.java Tue May 5 22:34:47 2015
@@ -24,6 +24,7 @@ import java.util.List;
import javax.xml.stream.XMLStreamConstants;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
@@ -41,7 +42,6 @@ public class DialectTestSuiteBuilder ext
}
private void addTests(StAXImplementation staxImpl) {
- ConformanceTestFile[] conformanceTestFiles = ConformanceTestFile.getConformanceTestFiles();
addTest(new TestCloseInputStream(staxImpl));
addTest(new TestCloseReader(staxImpl));
addTest(new TestCreateXMLEventWriterWithNullEncoding(staxImpl));
@@ -94,8 +94,8 @@ public class DialectTestSuiteBuilder ext
addTest(new TestGetNameIllegalStateException(staxImpl, XMLStreamConstants.DTD, true));
addTest(new TestGetNameIllegalStateException(staxImpl, XMLStreamConstants.CDATA, true));
addTest(new TestGetNamespaceContextImplicitNamespaces(staxImpl));
- for (int i=0; i<conformanceTestFiles.length; i++) {
- ConformanceTestFile file = conformanceTestFiles[i];
+ for (Iterator it = Multiton.getInstances(ConformanceTestFile.class).iterator(); it.hasNext(); ) {
+ ConformanceTestFile file = (ConformanceTestFile)it.next();
// Some parsers have problems with external subsets; anyway the test files with
// DTDs are not essential for this test.
if (!file.hasExternalSubset()) {
Modified: webservices/axiom/trunk/modules/axiom-compat/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-compat/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-compat/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java (original)
+++ webservices/axiom/trunk/modules/axiom-compat/src/test/java/org/apache/axiom/om/impl/jaxp/StreamSourceToOMResultTest.java Tue May 5 22:34:47 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.om.impl.jaxp;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
import javax.xml.transform.stream.StreamSource;
@@ -27,6 +28,7 @@ import junit.framework.TestSuite;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.XMLAssertEx;
import org.apache.axiom.testutils.conformance.ConformanceTestFile;
import org.apache.axiom.testutils.suite.MatrixTestCase;
@@ -57,10 +59,9 @@ public class StreamSourceToOMResultTest
public static TestSuite suite() {
TestSuite suite = new TestSuite();
- ConformanceTestFile[] files = ConformanceTestFile.getConformanceTestFiles();
for (int i=0; i<axiomImplementations.length; i++) {
- for (int j=0; j<files.length; j++) {
- suite.addTest(new StreamSourceToOMResultTest(axiomImplementations[i], files[j]));
+ for (Iterator it = Multiton.getInstances(ConformanceTestFile.class).iterator(); it.hasNext(); ) {
+ suite.addTest(new StreamSourceToOMResultTest(axiomImplementations[i], (ConformanceTestFile)it.next()));
}
}
return suite;
Modified: webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/SAXResultSAXParserTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/SAXResultSAXParserTest.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/SAXResultSAXParserTest.java (original)
+++ webservices/axiom/trunk/systests/integration-tests/src/test/java/org/apache/axiom/om/SAXResultSAXParserTest.java Tue May 5 22:34:47 2015
@@ -19,6 +19,8 @@
package org.apache.axiom.om;
+import static org.apache.axiom.testing.multiton.Multiton.getInstances;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -66,7 +68,7 @@ public class SAXResultSAXParserTest exte
}
private static void addTests(TestSuite suite, SAXParserFactory factory, String name) throws Exception {
- for (ConformanceTestFile file : ConformanceTestFile.getConformanceTestFiles()) {
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
suite.addTest(new SAXResultSAXParserTest(
file.getShortName() + " - " + name, factory, file));
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/AddAttributeStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/AddAttributeStrategy.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/AddAttributeStrategy.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/AddAttributeStrategy.java Tue May 5 22:34:47 2015
@@ -22,6 +22,7 @@ import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
@@ -29,12 +30,12 @@ import org.apache.axiom.testutils.suite.
* Defines a strategy (in terms of usage of particular API methods) to add an attribute to an
* element.
*/
-public interface AddAttributeStrategy extends Dimension {
+public abstract class AddAttributeStrategy extends Multiton implements Dimension {
/**
* Creates the attribute using {@link OMFactory#createOMAttribute(String, OMNamespace, String)}
* and then adds it using {@link OMElement#addAttribute(OMAttribute)}.
*/
- AddAttributeStrategy FACTORY = new AddAttributeStrategy() {
+ public static final AddAttributeStrategy FACTORY = new AddAttributeStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("addAttribute", "factory");
}
@@ -49,7 +50,7 @@ public interface AddAttributeStrategy ex
/**
* Adds the attribute using {@link OMElement#addAttribute(String, String, OMNamespace)}.
*/
- AddAttributeStrategy DIRECT = new AddAttributeStrategy() {
+ public static final AddAttributeStrategy DIRECT = new AddAttributeStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("addAttribute", "direct");
}
@@ -59,5 +60,7 @@ public interface AddAttributeStrategy ex
}
};
- OMAttribute addAttribute(OMElement element, String localName, OMNamespace ns, String value);
+ private AddAttributeStrategy() {}
+
+ public abstract OMAttribute addAttribute(OMElement element, String localName, OMNamespace ns, String value);
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/BuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/BuilderFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/BuilderFactory.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/BuilderFactory.java Tue May 5 22:34:47 2015
@@ -26,6 +26,7 @@ import javax.xml.transform.sax.SAXSource
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.stax.XMLStreamReaderComparator;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
@@ -36,12 +37,12 @@ import org.xml.sax.InputSource;
/**
* Defines a strategy to create an {@link OMXMLParserWrapper} from a given test file.
*/
-public interface BuilderFactory extends Dimension {
+public abstract class BuilderFactory extends Multiton implements Dimension {
/**
* Creates an {@link OMXMLParserWrapper} directly from the given {@link InputSource}, i.e. let
* instantiate an appropriate parser.
*/
- BuilderFactory PARSER = new BuilderFactory() {
+ public static final BuilderFactory PARSER = new BuilderFactory() {
public boolean isDeferredParsing() {
return true;
}
@@ -63,7 +64,7 @@ public interface BuilderFactory extends
* Creates an {@link OMXMLParserWrapper} by parsing the input using DOM and passing it as a DOM
* tree to Axiom.
*/
- BuilderFactory DOM = new BuilderFactory() {
+ public static final BuilderFactory DOM = new BuilderFactory() {
public boolean isDeferredParsing() {
return true;
}
@@ -91,7 +92,7 @@ public interface BuilderFactory extends
/**
* Creates an {@link OMXMLParserWrapper} by passing a {@link SAXSource} to Axiom.
*/
- BuilderFactory SAX = new BuilderFactory() {
+ public static final BuilderFactory SAX = new BuilderFactory() {
public boolean isDeferredParsing() {
return false;
}
@@ -116,6 +117,8 @@ public interface BuilderFactory extends
}
};
+ private BuilderFactory() {}
+
/**
* Determines if the builder created by this strategy supports deferred parsing.
*
@@ -123,9 +126,9 @@ public interface BuilderFactory extends
* builder doesn't support deferred parsing and will build the document all in once
* (this is the case for SAX only)
*/
- boolean isDeferredParsing();
+ public abstract boolean isDeferredParsing();
- void configureXMLStreamReaderComparator(XMLStreamReaderComparator comparator);
+ public abstract void configureXMLStreamReaderComparator(XMLStreamReaderComparator comparator);
- OMXMLParserWrapper getBuilder(OMMetaFactory metaFactory, InputSource inputSource) throws Exception;
+ public abstract OMXMLParserWrapper getBuilder(OMMetaFactory metaFactory, InputSource inputSource) throws Exception;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ElementContext.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ElementContext.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ElementContext.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ElementContext.java Tue May 5 22:34:47 2015
@@ -30,6 +30,7 @@ import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
import org.junit.Assert;
@@ -42,8 +43,8 @@ import org.xml.sax.InputSource;
* this interface wraps an {@link OMElement} in a container of a specific type ({@link OMDocument}
* or {@link OMElement}) in a specific state.
*/
-public interface ElementContext extends Dimension {
- ElementContext ORPHAN = new ElementContext() {
+public abstract class ElementContext extends Multiton implements Dimension {
+ public static final ElementContext ORPHAN = new ElementContext() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("container", "none");
}
@@ -60,7 +61,7 @@ public interface ElementContext extends
/**
* The {@link OMElement} is a child of another (programmatically created) {@link OMElement}.
*/
- ElementContext ELEMENT = new ElementContext() {
+ public static final ElementContext ELEMENT = new ElementContext() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("container", "element");
testCase.addTestParameter("complete", true);
@@ -88,7 +89,7 @@ public interface ElementContext extends
* The {@link OMElement} is a child of another {@link OMElement} created from a parser and that
* is incomplete.
*/
- ElementContext INCOMPLETE_ELEMENT = new ElementContext() {
+ public static final ElementContext INCOMPLETE_ELEMENT = new ElementContext() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("container", "element");
testCase.addTestParameter("complete", "false");
@@ -115,7 +116,9 @@ public interface ElementContext extends
}
};
- OMContainer wrap(OMElement element);
+ private ElementContext() {}
- InputSource getControl(InputSource xml) throws Exception;
+ public abstract OMContainer wrap(OMElement element);
+
+ public abstract InputSource getControl(InputSource xml) throws Exception;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ExpansionStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ExpansionStrategy.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ExpansionStrategy.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/ExpansionStrategy.java Tue May 5 22:34:47 2015
@@ -23,6 +23,7 @@ import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMSourcedElement;
import org.apache.axiom.om.ds.AbstractPullOMDataSource;
import org.apache.axiom.om.ds.AbstractPushOMDataSource;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
@@ -32,11 +33,11 @@ import org.junit.Assert;
* Defines if and how an {@link OMContainer} is to be built or expanded during the execution of a
* test case.
*/
-public interface ExpansionStrategy extends Dimension {
+public abstract class ExpansionStrategy extends Multiton implements Dimension {
/**
* Don't build the {@link OMContainer}.
*/
- ExpansionStrategy DONT_EXPAND = new ExpansionStrategy() {
+ public static final ExpansionStrategy DONT_EXPAND = new ExpansionStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("expand", "no");
}
@@ -62,7 +63,7 @@ public interface ExpansionStrategy exten
/**
* Partially build the {@link OMContainer}.
*/
- ExpansionStrategy PARTIAL = new ExpansionStrategy() {
+ public static final ExpansionStrategy PARTIAL = new ExpansionStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("expand", "partially");
}
@@ -87,7 +88,7 @@ public interface ExpansionStrategy exten
/**
* Fully build the {@link OMContainer}.
*/
- ExpansionStrategy FULL = new ExpansionStrategy() {
+ public static final ExpansionStrategy FULL = new ExpansionStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("expand", "fully");
}
@@ -110,12 +111,14 @@ public interface ExpansionStrategy exten
}
};
+ private ExpansionStrategy() {}
+
/**
* Apply the expansion strategy to the given {@link OMContainer}.
*
* @param element
*/
- void apply(OMContainer container);
+ public abstract void apply(OMContainer container);
/**
* Determines if serializing the {@link OMSourcedElement} after applying this expansion strategy
@@ -134,7 +137,7 @@ public interface ExpansionStrategy exten
* @return <code>true</code> if serializing the {@link OMSourcedElement} will consume it,
* <code>false</code> if the {@link OMSourcedElement} can be serialized multiple times
*/
- boolean isConsumedAfterSerialization(boolean pushDS, boolean destructiveDS, SerializationStrategy serializationStrategy);
+ public abstract boolean isConsumedAfterSerialization(boolean pushDS, boolean destructiveDS, SerializationStrategy serializationStrategy);
/**
* Determines if the {@link OMSourcedElement} to which this expansion strategy has been applied
@@ -152,5 +155,5 @@ public interface ExpansionStrategy exten
*
* @return the expected value of {@link OMSourcedElement#isExpanded()} after serialization
*/
- boolean isExpandedAfterSerialization(boolean pushDS, boolean destructiveDS, SerializationStrategy serializationStrategy);
+ public abstract boolean isExpandedAfterSerialization(boolean pushDS, boolean destructiveDS, SerializationStrategy serializationStrategy);
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/NoNamespaceStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/NoNamespaceStrategy.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/NoNamespaceStrategy.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/NoNamespaceStrategy.java Tue May 5 22:34:47 2015
@@ -20,11 +20,12 @@ package org.apache.axiom.ts.dimension;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.testing.multiton.Multiton;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
-public interface NoNamespaceStrategy extends Dimension {
- NoNamespaceStrategy NULL = new NoNamespaceStrategy() {
+public abstract class NoNamespaceStrategy extends Multiton implements Dimension {
+ public static final NoNamespaceStrategy NULL = new NoNamespaceStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("ns", "null");
}
@@ -34,7 +35,7 @@ public interface NoNamespaceStrategy ext
}
};
- NoNamespaceStrategy NULL_PREFIX = new NoNamespaceStrategy() {
+ public static final NoNamespaceStrategy NULL_PREFIX = new NoNamespaceStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("ns", "nullPrefix");
}
@@ -44,7 +45,7 @@ public interface NoNamespaceStrategy ext
}
};
- NoNamespaceStrategy EMPTY = new NoNamespaceStrategy() {
+ public static final NoNamespaceStrategy EMPTY = new NoNamespaceStrategy() {
public void addTestParameters(MatrixTestCase testCase) {
testCase.addTestParameter("ns", "empty");
}
@@ -54,5 +55,7 @@ public interface NoNamespaceStrategy ext
}
};
- OMNamespace createOMNamespace(OMFactory factory);
+ private NoNamespaceStrategy() {}
+
+ public abstract OMNamespace createOMNamespace(OMFactory factory);
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializationStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializationStrategy.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializationStrategy.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializationStrategy.java Tue May 5 22:34:47 2015
@@ -19,12 +19,16 @@
package org.apache.axiom.ts.dimension.serialization;
import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.testing.multiton.Multiton;
+import org.apache.axiom.testing.multiton.Instances;
import org.apache.axiom.testutils.suite.Dimension;
/**
* Defines a strategy to serialize an {@link OMContainer} instance to XML.
*/
-public interface SerializationStrategy extends Dimension {
+public abstract class SerializationStrategy extends Multiton implements Dimension {
+ SerializationStrategy() {}
+
/**
* Serialize the given {@link OMContainer}.
*
@@ -33,7 +37,7 @@ public interface SerializationStrategy e
* @return the serialized XML
* @throws Exception
*/
- XML serialize(OMContainer container) throws Exception;
+ public abstract XML serialize(OMContainer container) throws Exception;
/**
* Determine if this serialization strategy works in pull or push mode.
@@ -41,7 +45,7 @@ public interface SerializationStrategy e
* @return <code>true</code> if the serialization is driven by Axiom, <code>false</code> if the
* serialization is driven by the application code
*/
- boolean isPush();
+ public abstract boolean isPush();
/**
* Determine if this serialization strategy consumes the content of the {@link OMContainer}.
@@ -49,7 +53,7 @@ public interface SerializationStrategy e
* @return <code>true</code> if the strategy preserves the content, <code>false</code> if it
* consumes the content
*/
- boolean isCaching();
+ public abstract boolean isCaching();
/**
* Determine if this serialization strategy is able to correctly serialize the internal subset
@@ -58,5 +62,20 @@ public interface SerializationStrategy e
* @return <code>true</code> if this strategy correctly serializes the internal subset of a DTD,
* <code>false</code> otherwise
*/
- boolean supportsInternalSubset();
+ public abstract boolean supportsInternalSubset();
+
+ @Instances
+ private static SerializationStrategy[] instances() {
+ return new SerializationStrategy[] {
+ new SerializeToOutputStream(true),
+ new SerializeToOutputStream(false),
+ new SerializeToWriter(true),
+ new SerializeToWriter(false),
+ new SerializeToXMLStreamWriter(true),
+ new SerializeToXMLStreamWriter(false),
+ new SerializeFromXMLStreamReader(true),
+ new SerializeFromXMLStreamReader(false),
+ new SerializeFromSAXSource(true),
+ new SerializeFromSAXSource(false) };
+ }
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromSAXSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromSAXSource.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromSAXSource.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromSAXSource.java Tue May 5 22:34:47 2015
@@ -31,10 +31,10 @@ import org.xml.sax.XMLReader;
* Serializes an {@link OMContainer} by processing the result of
* {@link OMContainer#getSAXSource(boolean)}.
*/
-public class SerializeFromSAXSource implements SerializationStrategy {
+public class SerializeFromSAXSource extends SerializationStrategy {
private final boolean cache;
- public SerializeFromSAXSource(boolean cache) {
+ SerializeFromSAXSource(boolean cache) {
this.cache = cache;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromXMLStreamReader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromXMLStreamReader.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromXMLStreamReader.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeFromXMLStreamReader.java Tue May 5 22:34:47 2015
@@ -29,10 +29,10 @@ import org.apache.axiom.testutils.suite.
* Serializes an {@link OMContainer} by processing the result of
* {@link OMContainer#getXMLStreamReader(boolean)}.
*/
-public class SerializeFromXMLStreamReader implements SerializationStrategy {
+public class SerializeFromXMLStreamReader extends SerializationStrategy {
private final boolean cache;
- public SerializeFromXMLStreamReader(boolean cache) {
+ SerializeFromXMLStreamReader(boolean cache) {
this.cache = cache;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToOutputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToOutputStream.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToOutputStream.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToOutputStream.java Tue May 5 22:34:47 2015
@@ -28,10 +28,10 @@ import org.apache.axiom.testutils.suite.
* Serializes an {@link OMContainer} using {@link OMContainer#serialize(OutputStream)} or
* {@link OMContainer#serializeAndConsume(OutputStream)}.
*/
-public class SerializeToOutputStream implements SerializationStrategy {
+public class SerializeToOutputStream extends SerializationStrategy {
private final boolean cache;
- public SerializeToOutputStream(boolean cache) {
+ SerializeToOutputStream(boolean cache) {
this.cache = cache;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToWriter.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToWriter.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToWriter.java Tue May 5 22:34:47 2015
@@ -28,10 +28,10 @@ import org.apache.axiom.testutils.suite.
* Serializes an {@link OMContainer} using {@link OMContainer#serialize(Writer)} or
* {@link OMContainer#serializeAndConsume(Writer)}.
*/
-public class SerializeToWriter implements SerializationStrategy {
+public class SerializeToWriter extends SerializationStrategy {
private final boolean cache;
- public SerializeToWriter(boolean cache) {
+ SerializeToWriter(boolean cache) {
this.cache = cache;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToXMLStreamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToXMLStreamWriter.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToXMLStreamWriter.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/dimension/serialization/SerializeToXMLStreamWriter.java Tue May 5 22:34:47 2015
@@ -30,10 +30,10 @@ import org.apache.axiom.testutils.suite.
* Serializes an {@link OMContainer} using {@link OMContainer#serialize(XMLStreamWriter)} or
* {@link OMContainer#serializeAndConsume(XMLStreamWriter)}.
*/
-public class SerializeToXMLStreamWriter implements SerializationStrategy {
+public class SerializeToXMLStreamWriter extends SerializationStrategy {
private final boolean cache;
- public SerializeToXMLStreamWriter(boolean cache) {
+ SerializeToXMLStreamWriter(boolean cache) {
this.cache = cache;
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java Tue May 5 22:34:47 2015
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.om;
+import static org.apache.axiom.testing.multiton.Multiton.getInstances;
+
import java.lang.reflect.Method;
import javax.xml.namespace.QName;
@@ -31,7 +33,6 @@ import org.apache.axiom.ts.dimension.Bui
import org.apache.axiom.ts.dimension.ElementContext;
import org.apache.axiom.ts.dimension.ExpansionStrategy;
import org.apache.axiom.ts.dimension.NoNamespaceStrategy;
-import org.apache.axiom.ts.dimension.Strategies;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
import org.apache.axiom.ts.om.container.OMContainerFactory;
import org.apache.axiom.ts.om.container.OMElementFactory;
@@ -43,11 +44,6 @@ import org.apache.axiom.ts.om.xpath.AXIO
import org.apache.axiom.ts.om.xpath.TestAXIOMXPath;
public class OMTestSuiteBuilder extends MatrixTestSuiteBuilder {
- private static final BuilderFactory[] builderFactories = {
- BuilderFactory.PARSER,
- BuilderFactory.DOM,
- BuilderFactory.SAX };
-
private static final OMContainerFactory[] containerFactories = {
OMContainerFactory.DOCUMENT,
new OMElementFactory(false),
@@ -67,12 +63,6 @@ public class OMTestSuiteBuilder extends
}
protected void addTests() {
- ConformanceTestFile[] conformanceFiles = ConformanceTestFile.getConformanceTestFiles();
- SerializationStrategy[] serializationStrategies = Strategies.getSerializationStrategies();
- ElementContext[] elementContexts = Strategies.getElementContexts();
- ExpansionStrategy[] expansionStrategies = Strategies.getExpansionStrategies();
- AddAttributeStrategy[] addAttributeStrategies = Strategies.getAddattributestrategies();
- NoNamespaceStrategy[] noNamespaceStrategies = Strategies.getNoNamespaceStrategies();
addTest(new org.apache.axiom.ts.om.attribute.TestDigestWithNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.attribute.TestDigestWithoutNamespace(metaFactory));
addTest(new org.apache.axiom.ts.om.attribute.TestEqualsHashCode(metaFactory));
@@ -109,8 +99,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.builder.TestCloseWithInputStream(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestCloseWithReader(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestCloseWithXMLStreamReader(metaFactory));
- for (int i=0; i<conformanceFiles.length; i++) {
- ConformanceTestFile file = conformanceFiles[i];
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
if (file.hasEntityReferences()) {
addTest(new org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOM(metaFactory, file, Boolean.TRUE));
addTest(new org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOM(metaFactory, file, Boolean.FALSE));
@@ -126,8 +115,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.builder.TestCreateStAXOMBuilderIncorrectState(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestCreateStAXOMBuilderNamespaceRepairing(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestCreateStAXOMBuilderNamespaceRepairing2(metaFactory));
- for (int i=0; i<builderFactories.length; i++) {
- BuilderFactory bf = builderFactories[i];
+ for (BuilderFactory bf : getInstances(BuilderFactory.class)) {
addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory, bf, null));
addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory, bf, Boolean.FALSE));
addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory, bf, Boolean.TRUE));
@@ -141,20 +129,17 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.builder.TestReadAttachmentBeforeRootPartComplete(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestRootPartStreaming(metaFactory));
addTest(new org.apache.axiom.ts.om.builder.TestStandaloneConfiguration(metaFactory));
- for (int i=0; i<conformanceFiles.length; i++) {
- ConformanceTestFile file = conformanceFiles[i];
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
for (int j=0; j<containerFactories.length; j++) {
OMContainerFactory cf = containerFactories[j];
- for (int k=0; k<builderFactories.length; k++) {
- BuilderFactory bf = builderFactories[k];
+ for (BuilderFactory bf : getInstances(BuilderFactory.class)) {
addTest(new org.apache.axiom.ts.om.container.TestGetXMLStreamReader(metaFactory, file, bf, cf, true));
addTest(new org.apache.axiom.ts.om.container.TestGetXMLStreamReader(metaFactory, file, bf, cf, false));
}
// On a document containing entity references, serialization tests will only work correctly if
// the entire document is serialized (so that the DTD is available)
if (!file.hasEntityReferences() || cf == OMContainerFactory.DOCUMENT) {
- for (int k=0; k<serializationStrategies.length; k++) {
- SerializationStrategy ss = serializationStrategies[k];
+ for (SerializationStrategy ss : getInstances(SerializationStrategy.class)) {
if (ss.supportsInternalSubset() || !file.hasInternalSubset()) {
addTest(new org.apache.axiom.ts.om.container.TestSerialize(metaFactory, file, containerFactories[j], ss));
}
@@ -165,8 +150,8 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.document.TestAddChildIncomplete(metaFactory));
addTest(new org.apache.axiom.ts.om.document.TestAddChildWithExistingDocumentElement(metaFactory));
addTest(new org.apache.axiom.ts.om.document.TestBuild(metaFactory));
- for (int i=0; i<conformanceFiles.length; i++) {
- addTest(new org.apache.axiom.ts.om.document.TestClone(metaFactory, conformanceFiles[i]));
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
+ addTest(new org.apache.axiom.ts.om.document.TestClone(metaFactory, file));
}
addTest(new org.apache.axiom.ts.om.document.TestDigest(metaFactory, "digest1.xml", "MD5", "3e5d68c6607bc56c9c171560e4f19db9"));
addTest(new org.apache.axiom.ts.om.document.TestDigest(metaFactory, "digest2.xml", "SHA1", "3c47a807517d867d42ffacb2d3e9da81895d5aac"));
@@ -178,8 +163,8 @@ public class OMTestSuiteBuilder extends
for (int i=0; i<XSLTImplementation.INSTANCES.length; i++) {
XSLTImplementation xsltImplementation = XSLTImplementation.INSTANCES[i];
if (xsltImplementation.supportsLexicalHandlerWithStreamSource()) {
- for (int j=0; j<conformanceFiles.length; j++) {
- addTest(new org.apache.axiom.ts.om.document.TestGetSAXResult(metaFactory, xsltImplementation, conformanceFiles[j]));
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
+ addTest(new org.apache.axiom.ts.om.document.TestGetSAXResult(metaFactory, xsltImplementation, file));
}
}
}
@@ -207,16 +192,15 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeReuseExistingPrefix(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithInvalidNamespace1(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithInvalidNamespace2(metaFactory));
- for (int i=0; i<addAttributeStrategies.length; i++) {
- AddAttributeStrategy strategy = addAttributeStrategies[i];
+ for (AddAttributeStrategy strategy : getInstances(AddAttributeStrategy.class)) {
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeMultiple(metaFactory, strategy));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeReplace(metaFactory, strategy));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationInScope(metaFactory, strategy));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithExistingNamespaceDeclarationOnSameElement(metaFactory, strategy));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithMaskedNamespaceDeclaration(metaFactory, strategy));
addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithoutExistingNamespaceDeclaration(metaFactory, strategy));
- for (int j=0; j<noNamespaceStrategies.length; j++) {
- addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithoutNamespace(metaFactory, strategy, noNamespaceStrategies[j]));
+ for (NoNamespaceStrategy noNamespaceStrategy : getInstances(NoNamespaceStrategy.class)) {
+ addTest(new org.apache.axiom.ts.om.element.TestAddAttributeWithoutNamespace(metaFactory, strategy, noNamespaceStrategy));
}
}
addTest(new org.apache.axiom.ts.om.element.TestAddChild(metaFactory));
@@ -229,8 +213,7 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.TestBuildDiscarded(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestChildReDeclaringGrandParentsDefaultNSWithPrefix(metaFactory));
addTest(new org.apache.axiom.ts.om.element.TestChildReDeclaringParentsDefaultNSWithPrefix(metaFactory));
- for (int i=0; i<conformanceFiles.length; i++) {
- ConformanceTestFile file = conformanceFiles[i];
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
if (!file.hasEntityReferences()) {
addTest(new org.apache.axiom.ts.om.element.TestCloneOMElement2(metaFactory, file));
}
@@ -410,16 +393,14 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.element.sr.TestClose(metaFactory, false));
addTest(new org.apache.axiom.ts.om.element.sr.TestCloseAndContinueBuilding(metaFactory, true));
addTest(new org.apache.axiom.ts.om.element.sr.TestCloseAndContinueBuilding(metaFactory, false));
- for (int i=0; i<builderFactories.length; i++) {
- BuilderFactory bf = builderFactories[i];
+ for (BuilderFactory bf : getInstances(BuilderFactory.class)) {
addTest(new org.apache.axiom.ts.om.element.sr.TestCommentEvent(metaFactory, bf, true));
addTest(new org.apache.axiom.ts.om.element.sr.TestCommentEvent(metaFactory, bf, false));
}
addTest(new org.apache.axiom.ts.om.element.sr.TestGetDataHandlerFromElement(metaFactory, true));
addTest(new org.apache.axiom.ts.om.element.sr.TestGetDataHandlerFromElement(metaFactory, false));
addTest(new org.apache.axiom.ts.om.element.sr.TestGetElementText(metaFactory));
- for (int i=0; i<builderFactories.length; i++) {
- BuilderFactory bf = builderFactories[i];
+ for (BuilderFactory bf : getInstances(BuilderFactory.class)) {
addTest(new org.apache.axiom.ts.om.element.sr.TestGetElementTextFromParser(metaFactory, bf, true, 0));
for (int build=0; build<6; build++) {
addTest(new org.apache.axiom.ts.om.element.sr.TestGetElementTextFromParser(metaFactory, bf, false, build));
@@ -554,12 +535,9 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.sourcedelement.TestPushOMDataSourceExpansion(metaFactory, PushOMDataSourceScenario.INSTANCES[i]));
}
addTest(new org.apache.axiom.ts.om.sourcedelement.TestRemoveChildrenUnexpanded(metaFactory));
- for (int i = 0; i < elementContexts.length; i++) {
- ElementContext ec = elementContexts[i];
- for (int j = 0; j < expansionStrategies.length; j++) {
- ExpansionStrategy es = expansionStrategies[j];
- for (int k = 0; k < serializationStrategies.length; k++) {
- SerializationStrategy ss = serializationStrategies[k];
+ for (ElementContext ec : getInstances(ElementContext.class)) {
+ for (ExpansionStrategy es : getInstances(ExpansionStrategy.class)) {
+ for (SerializationStrategy ss : getInstances(SerializationStrategy.class)) {
for (int count = 1; count <= 2; count++) {
addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, false, false, ec, es, ss, false, count));
addTest(new org.apache.axiom.ts.om.sourcedelement.TestSerialize(metaFactory, false, true, ec, es, ss, false, count));
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAccessor.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAccessor.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAccessor.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAccessor.java Tue May 5 22:34:47 2015
@@ -19,6 +19,7 @@
package org.apache.axiom.ts.soap;
import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.testing.multiton.AdapterType;
/**
* {@link BooleanAttribute} adapter that allows to invoke the getter and setter methods for the
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAdapterFactory.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttributeAdapterFactory.java Tue May 5 22:34:47 2015
@@ -19,6 +19,8 @@
package org.apache.axiom.ts.soap;
import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.testing.multiton.AdapterFactory;
+import org.apache.axiom.testing.multiton.Adapters;
public class BooleanAttributeAdapterFactory implements AdapterFactory<BooleanAttribute> {
public void createAdapters(BooleanAttribute attribute, Adapters adapters) {
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/FactorySelector.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/FactorySelector.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/FactorySelector.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/FactorySelector.java Tue May 5 22:34:47 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.ts.soap;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.testing.multiton.AdapterType;
/**
* {@link SOAPSpec} adapter that allows to retrieve the {@link SOAPFactory} corresponding to the
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapter.java Tue May 5 22:34:47 2015
@@ -20,6 +20,7 @@ package org.apache.axiom.ts.soap;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.testing.multiton.AdapterType;
import org.apache.axiom.testutils.suite.Dimension;
import org.apache.axiom.testutils.suite.MatrixTestCase;
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementTypeAdapterFactory.java Tue May 5 22:34:47 2015
@@ -33,6 +33,8 @@ import org.apache.axiom.soap.SOAPFaultSu
import org.apache.axiom.soap.SOAPFaultText;
import org.apache.axiom.soap.SOAPFaultValue;
import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.testing.multiton.AdapterFactory;
+import org.apache.axiom.testing.multiton.Adapters;
import org.apache.axiom.ts.soap.SOAPElementTypeAdapter.Getter;
import org.apache.axiom.ts.soap.SOAPElementTypeAdapter.Setter;
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpecAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpecAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpecAdapterFactory.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpecAdapterFactory.java Tue May 5 22:34:47 2015
@@ -23,6 +23,8 @@ import org.apache.axiom.soap.SOAP11Versi
import org.apache.axiom.soap.SOAP12Version;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPVersion;
+import org.apache.axiom.testing.multiton.AdapterFactory;
+import org.apache.axiom.testing.multiton.Adapters;
public class SOAPSpecAdapterFactory implements AdapterFactory<SOAPSpec> {
public void createAdapters(SOAPSpec spec, Adapters adapters) {
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Tue May 5 22:34:47 2015
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.soap;
+import static org.apache.axiom.testing.multiton.Multiton.getInstances;
+
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMMetaFactory;
@@ -28,7 +30,6 @@ import org.apache.axiom.soap.SOAP12Const
import org.apache.axiom.soap.SOAPConstants;
import org.apache.axiom.testutils.suite.MatrixTestSuiteBuilder;
import org.apache.axiom.ts.dimension.ExpansionStrategy;
-import org.apache.axiom.ts.dimension.Strategies;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
public class SOAPTestSuiteBuilder extends MatrixTestSuiteBuilder {
@@ -72,11 +73,6 @@ public class SOAPTestSuiteBuilder extend
new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, "NoFault", SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
new QName(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, "NoFault", SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX) };
- private static final BooleanAttribute[] booleanAttributes = {
- BooleanAttribute.MUST_UNDERSTAND,
- BooleanAttribute.RELAY,
- };
-
private final OMMetaFactory metaFactory;
private final boolean supportsOMSourcedElement;
private final boolean supportsBodyElementNameOptimization;
@@ -98,7 +94,6 @@ public class SOAPTestSuiteBuilder extend
}
private void addTests(SOAPSpec spec) {
- SerializationStrategy[] serializationStrategies = Strategies.getSerializationStrategies();
BooleanLiteral[] booleanLiterals = spec.getBooleanLiterals();
String[] invalidBooleanLiterals = spec.getInvalidBooleanLiterals();
addTest(new org.apache.axiom.ts.soap.body.TestAddFault1(metaFactory, spec));
@@ -185,8 +180,7 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.factory.TestGetDefaultFaultEnvelope(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.factory.TestGetMetaFactory(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.factory.TestGetNamespace(metaFactory, spec));
- for (int i=0; i<serializationStrategies.length; i++) {
- SerializationStrategy ss = serializationStrategies[i];
+ for (SerializationStrategy ss : getInstances(SerializationStrategy.class)) {
addTest(new org.apache.axiom.ts.soap.fault.TestChildOrder(metaFactory, spec,
new SOAPFaultChild[] { SOAPFaultChild.REASON, SOAPFaultChild.CODE }, ss));
addTest(new org.apache.axiom.ts.soap.fault.TestChildOrder(metaFactory, spec,
@@ -235,8 +229,7 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.header.TestExtractAllHeaderBlocks(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.header.TestGetHeaderBlocksWithNSURI(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.header.TestGetHeadersToProcessWithNamespace(metaFactory, spec));
- for (int i=0; i<booleanAttributes.length; i++) {
- BooleanAttribute attribute = booleanAttributes[i];
+ for (BooleanAttribute attribute : getInstances(BooleanAttribute.class)) {
if (attribute.isSupported(spec)) {
for (int j=0; j<booleanLiterals.length; j++) {
addTest(new org.apache.axiom.ts.soap.headerblock.TestGetBooleanAttribute(metaFactory, spec, attribute, booleanLiterals[j]));
@@ -299,8 +292,6 @@ public class SOAPTestSuiteBuilder extend
protected void addTests() {
addTests(SOAPSpec.SOAP11);
addTests(SOAPSpec.SOAP12);
- SerializationStrategy[] serializationStrategies = Strategies.getSerializationStrategies();
- ExpansionStrategy[] expansionStrategies = Strategies.getExpansionStrategies();
for (int i=0; i<badSOAPFiles.length; i++) {
addTest(new org.apache.axiom.ts.soap.builder.BadInputTest(metaFactory, badSOAPFiles[i]));
}
@@ -312,10 +303,10 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.envelope.TestClone(metaFactory, msg));
}
for (int i=0; i<goodSOAPFiles.length; i++) {
- for (int j=0; j<expansionStrategies.length; j++) {
- for (int k=0; k<serializationStrategies.length; k++) {
- addTest(new org.apache.axiom.ts.soap.envelope.TestSerialize(metaFactory, goodSOAPFiles[i], expansionStrategies[j], serializationStrategies[k]));
- addTest(new org.apache.axiom.ts.soap.message.TestSerialize(metaFactory, goodSOAPFiles[i], expansionStrategies[j], serializationStrategies[k]));
+ for (ExpansionStrategy expansionStrategy : getInstances(ExpansionStrategy.class)) {
+ for (SerializationStrategy serializationStrategy : getInstances(SerializationStrategy.class)) {
+ addTest(new org.apache.axiom.ts.soap.envelope.TestSerialize(metaFactory, goodSOAPFiles[i], expansionStrategy, serializationStrategy));
+ addTest(new org.apache.axiom.ts.soap.message.TestSerialize(metaFactory, goodSOAPFiles[i], expansionStrategy, serializationStrategy));
}
}
}
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapter.java Tue May 5 22:34:47 2015
@@ -24,6 +24,7 @@ import org.apache.axiom.soap.SOAPEnvelop
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.SOAPModelBuilder;
+import org.apache.axiom.testing.multiton.AdapterType;
import org.junit.Assert;
import org.xml.sax.InputSource;
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageAdapterFactory.java Tue May 5 22:34:47 2015
@@ -18,6 +18,9 @@
*/
package org.apache.axiom.ts.soap;
+import org.apache.axiom.testing.multiton.AdapterFactory;
+import org.apache.axiom.testing.multiton.Adapters;
+
public class TestMessageAdapterFactory implements AdapterFactory<TestMessage> {
public void createAdapters(TestMessage testMessage, Adapters adapters) {
adapters.add(new TestMessageAdapter(testMessage));
Modified: webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/dom-testsuite/src/main/java/org/apache/axiom/ts/dom/DOMTestSuiteBuilder.java Tue May 5 22:34:47 2015
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.dom;
+import static org.apache.axiom.testing.multiton.Multiton.getInstances;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
@@ -65,7 +67,6 @@ public final class DOMTestSuiteBuilder e
protected void addTests() {
DocumentBuilderFactory dbf = dbff.newInstance();
dbf.setNamespaceAware(true);
- ConformanceTestFile[] conformanceFiles = ConformanceTestFile.getConformanceTestFiles();
addTest(new org.apache.axiom.ts.dom.attr.TestCloneNode(dbf, true));
addTest(new org.apache.axiom.ts.dom.attr.TestCloneNode(dbf, false));
addTest(new org.apache.axiom.ts.dom.attr.TestGetChildNodes(dbf));
@@ -82,8 +83,8 @@ public final class DOMTestSuiteBuilder e
addTest(new org.apache.axiom.ts.dom.document.TestAdoptNodeWithParent(dbf));
addTest(new org.apache.axiom.ts.dom.document.TestAllowedChildren(dbf));
addTest(new org.apache.axiom.ts.dom.document.TestAppendChildWrongDocument(dbf));
- for (int i=0; i<conformanceFiles.length; i++) {
- addTest(new org.apache.axiom.ts.dom.document.TestCloneNode(dbf, conformanceFiles[i]));
+ for (ConformanceTestFile file : getInstances(ConformanceTestFile.class)) {
+ addTest(new org.apache.axiom.ts.dom.document.TestCloneNode(dbf, file));
}
addTest(new org.apache.axiom.ts.dom.document.TestCreateAttribute(dbf));
for (int i=0; i<validAttrQNames.length; i++) {
Propchange: webservices/axiom/trunk/testing/multiton/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May 5 22:34:47 2015
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target
Added: webservices/axiom/trunk/testing/multiton/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/pom.xml?rev=1677901&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/multiton/pom.xml (added)
+++ webservices/axiom/trunk/testing/multiton/pom.xml Tue May 5 22:34:47 2015
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>testing</artifactId>
+ <version>1.2.15-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>multiton</artifactId>
+
+ <name>Multiton pattern implementation</name>
+ <description>
+ Implementation of the multiton pattern used in the test suites.
+ </description>
+</project>
Propchange: webservices/axiom/trunk/testing/multiton/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterFactory.java (from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterFactory.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterFactory.java?p2=webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterFactory.java&p1=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterFactory.java&r1=1677866&r2=1677901&rev=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterFactory.java (original)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterFactory.java Tue May 5 22:34:47 2015
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.ts.soap;
+package org.apache.axiom.testing.multiton;
-public interface AdapterFactory<T extends Adaptable> {
+public interface AdapterFactory<T extends Multiton> {
void createAdapters(T instance, Adapters adapters);
}
Copied: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterType.java (from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterType.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterType.java?p2=webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterType.java&p1=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterType.java&r1=1677866&r2=1677901&rev=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/AdapterType.java (original)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/AdapterType.java Tue May 5 22:34:47 2015
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.ts.soap;
+package org.apache.axiom.testing.multiton;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Copied: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Adapters.java (from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adapters.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Adapters.java?p2=webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Adapters.java&p1=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adapters.java&r1=1677866&r2=1677901&rev=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adapters.java (original)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Adapters.java Tue May 5 22:34:47 2015
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.ts.soap;
+package org.apache.axiom.testing.multiton;
import java.util.HashMap;
import java.util.HashSet;
Added: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java?rev=1677901&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java (added)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java Tue May 5 22:34:47 2015
@@ -0,0 +1,34 @@
+/*
+ * 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.testing.multiton;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that the method returns a set of instances for a multiton. See the Javadoc of the
+ * {@link Multiton} class for more details.
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Instances {
+
+}
Propchange: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Instances.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Multiton.java (from r1677866, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adaptable.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Multiton.java?p2=webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Multiton.java&p1=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adaptable.java&r1=1677866&r2=1677901&rev=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/Adaptable.java (original)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/Multiton.java Tue May 5 22:34:47 2015
@@ -16,26 +16,45 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.axiom.ts.soap;
+package org.apache.axiom.testing.multiton;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
+/**
+ * Base class for multitons. A multiton is a class that has a fixed set of instances. The base class
+ * also provides a simple mechanism that allows to extend the behavior of a multiton using adapters.
+ * <p>
+ * The set of instances of a multiton is determined by:
+ * <ul>
+ * <li>The values of all public static final fields in the multiton class that have types that are
+ * assignment compatible with the multiton class.
+ * <li>The array elements returned by methods in the multiton class annotated with
+ * {@link Instances}. These methods must be private static, have no parameters and return an array
+ * with an component type assignment compatible with the multiton class.
+ * </ul>
+ */
@SuppressWarnings({"rawtypes", "unchecked"})
-public abstract class Adaptable {
+public abstract class Multiton {
+ private static final Map<Class<?>,List<?>> instancesMap = new HashMap<Class<?>,List<?>>();
private static final Map<Class,List<AdapterFactory>> adapterFactoryMap = new HashMap<Class,List<AdapterFactory>>();
private final Adapters adapters = new Adapters();
static {
- for (Iterator<AdapterFactory> it = ServiceLoader.load(AdapterFactory.class, Adaptable.class.getClassLoader()).iterator(); it.hasNext(); ) {
+ for (Iterator<AdapterFactory> it = ServiceLoader.load(AdapterFactory.class, Multiton.class.getClassLoader()).iterator(); it.hasNext(); ) {
AdapterFactory adapterFactory = it.next();
// TODO: only works in the basic case where the factory directly implements AdapterFactory as the first interface
- Class clazz = ((Class<?>)((ParameterizedType)adapterFactory.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]).asSubclass(Adaptable.class);
+ Class clazz = ((Class<?>)((ParameterizedType)adapterFactory.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]).asSubclass(Multiton.class);
List<AdapterFactory> adapterFactories = adapterFactoryMap.get(clazz);
if (adapterFactories == null) {
adapterFactories = new ArrayList<AdapterFactory>();
@@ -44,12 +63,66 @@ public abstract class Adaptable {
adapterFactories.add(adapterFactory);
}
}
+
+ /**
+ * Get all instances of the given multiton. See the Javadoc of the {@link Multiton} class for
+ * information about how the instances are determined.
+ *
+ * @param multitonClass the multiton class
+ * @return the list of instances
+ * @throws MultitonInstantiationException if an error occurred
+ */
+ public static synchronized <T extends Multiton> List<T> getInstances(Class<T> multitonClass) {
+ List<T> instances = (List<T>)instancesMap.get(multitonClass);
+ if (instances == null) {
+ instances = new ArrayList<T>();
+ for (Field field : multitonClass.getDeclaredFields()) {
+ int mod = field.getModifiers();
+ if (Modifier.isPublic(mod) && Modifier.isStatic(mod) && Modifier.isFinal(mod)
+ && multitonClass.isAssignableFrom(field.getType())) {
+ try {
+ instances.add(multitonClass.cast(field.get(null)));
+ } catch (IllegalAccessException ex) {
+ throw new MultitonInstantiationException(ex);
+ }
+ }
+ }
+ for (Method method : multitonClass.getDeclaredMethods()) {
+ if (method.getAnnotation(Instances.class) != null) {
+ int mod = method.getModifiers();
+ if (!Modifier.isPrivate(mod) || !Modifier.isStatic(mod)) {
+ throw new MultitonInstantiationException("Methods annotated with @Instances must be private static");
+ }
+ if (method.getParameterTypes().length > 0) {
+ throw new MultitonInstantiationException("Methods annotated with @Instances must not take any parameters");
+ }
+ Class<?> returnType = method.getReturnType();
+ if (!returnType.isArray() || !multitonClass.isAssignableFrom(returnType.getComponentType())) {
+ throw new MultitonInstantiationException("Invalid return type for method annotated with @Instances");
+ }
+ method.setAccessible(true);
+ try {
+ for (Object instance : (Object[])method.invoke(null)) {
+ instances.add(multitonClass.cast(instance));
+ }
+ } catch (IllegalAccessException ex) {
+ throw new MultitonInstantiationException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new MultitonInstantiationException(ex.getCause());
+ }
+ }
+ }
+ instances = Collections.unmodifiableList(instances);
+ instancesMap.put(multitonClass, instances);
+ }
+ return instances;
+ }
public final <T> T getAdapter(Class<T> type) {
synchronized (adapters) {
if (!adapters.initialized()) {
Class<?> clazz = getClass();
- while (clazz != Adaptable.class) {
+ while (clazz != Multiton.class) {
List<AdapterFactory> adapterFactories = adapterFactoryMap.get(clazz);
if (adapterFactories != null) {
for (AdapterFactory adapterFactory : adapterFactories) {
Added: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java?rev=1677901&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java (added)
+++ webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java Tue May 5 22:34:47 2015
@@ -0,0 +1,31 @@
+/*
+ * 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.testing.multiton;
+
+public class MultitonInstantiationException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public MultitonInstantiationException(String msg) {
+ super(msg);
+ }
+
+ public MultitonInstantiationException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: webservices/axiom/trunk/testing/multiton/src/main/java/org/apache/axiom/testing/multiton/MultitonInstantiationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/testing/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/pom.xml?rev=1677901&r1=1677900&r2=1677901&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/pom.xml (original)
+++ webservices/axiom/trunk/testing/pom.xml Tue May 5 22:34:47 2015
@@ -35,6 +35,7 @@
<module>axiom-testsuite</module>
<module>dom-testsuite</module>
<module>jaxen-testsuite</module>
+ <module>multiton</module>
<module>saaj-testsuite</module>
<module>soap-testsuite</module>
<module>spring-ws-testsuite</module>