Modified: webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/FactorySelector.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/FactorySelector.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/FactorySelector.java (original) +++ webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/FactorySelector.java Tue May 5 22:34:47 2015 @@ -22,7 +22,7 @@ import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPFactory; -import org.apache.axiom.ts.soap.AdapterType; +import org.apache.axiom.testing.multiton.AdapterType; import org.apache.axiom.ts.soap.SOAPSpec; /**
Modified: webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SOAPSpecAdapterFactory.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SOAPSpecAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SOAPSpecAdapterFactory.java (original) +++ webservices/axiom/trunk/testing/saaj-testsuite/src/main/java/org/apache/axiom/ts/saaj/SOAPSpecAdapterFactory.java Tue May 5 22:34:47 2015 @@ -22,8 +22,8 @@ import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPException; -import org.apache.axiom.ts.soap.AdapterFactory; -import org.apache.axiom.ts.soap.Adapters; +import org.apache.axiom.testing.multiton.AdapterFactory; +import org.apache.axiom.testing.multiton.Adapters; import org.apache.axiom.ts.soap.SOAPSpec; public class SOAPSpecAdapterFactory implements AdapterFactory<SOAPSpec> { Modified: webservices/axiom/trunk/testing/soap-testsuite/pom.xml URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/pom.xml?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/pom.xml (original) +++ webservices/axiom/trunk/testing/soap-testsuite/pom.xml Tue May 5 22:34:47 2015 @@ -35,6 +35,11 @@ <dependencies> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>multiton</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/BooleanAttribute.java Tue May 5 22:34:47 2015 @@ -18,12 +18,14 @@ */ package org.apache.axiom.ts.soap; +import org.apache.axiom.testing.multiton.Multiton; + /** * Describes a boolean attribute that can appear on a SOAP header block. This includes the * <tt>mustUnderstand</tt> attribute in all SOAP versions as well as the <tt>relay</tt> attribute * defined by SOAP 1.2. */ -public abstract class BooleanAttribute extends Adaptable { +public abstract class BooleanAttribute extends Multiton { public static final BooleanAttribute MUST_UNDERSTAND = new BooleanAttribute() { public String getName() { return "mustUnderstand"; Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementType.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementType.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementType.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPElementType.java Tue May 5 22:34:47 2015 @@ -23,7 +23,9 @@ import java.util.List; import javax.xml.namespace.QName; -public abstract class SOAPElementType extends Adaptable { +import org.apache.axiom.testing.multiton.Multiton; + +public abstract class SOAPElementType extends Multiton { public static final SOAPElementType ENVELOPE = new SOAPElementType() { public QName getQName(SOAPSpec spec) { return spec.getEnvelopeQName(); Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSpec.java Tue May 5 22:34:47 2015 @@ -29,10 +29,12 @@ import javax.xml.transform.stream.Stream import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.apache.axiom.testing.multiton.Multiton; + /** * Describes the characteristics of a given SOAP version. */ -public abstract class SOAPSpec extends Adaptable { +public abstract class SOAPSpec extends Multiton { public static final SOAPSpec SOAP11 = new SOAPSpec("soap11", "text/xml", "http://schemas.xmlsoap.org/soap/envelope/", @@ -105,7 +107,7 @@ public abstract class SOAPSpec extends A private final String[] schemaResources; private Schema schema; - public SOAPSpec(String name, String contentType, String envelopeNamespaceURI, BooleanLiteral[] booleanLiterals, + private SOAPSpec(String name, String contentType, String envelopeNamespaceURI, BooleanLiteral[] booleanLiterals, QName faultCodeQName, QName faultValueQName, QName faultSubCodeQName, QName faultReasonQName, QName faultTextQName, QName faultNodeQName, QName faultRoleQName, QName faultDetailQName, String nextRoleURI, QName senderFaultCode, QName receiverFaultCode, Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessage.java Tue May 5 22:34:47 2015 @@ -29,6 +29,8 @@ import javax.xml.transform.TransformerFa import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.apache.axiom.testing.multiton.Instances; +import org.apache.axiom.testing.multiton.Multiton; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -37,24 +39,23 @@ import org.xml.sax.InputSource; /** * A SOAP test message. */ -public abstract class TestMessage extends Adaptable { - private static final List<TestMessage> instances = new ArrayList<TestMessage>(); - - static { - // Force instantiation of TestMessage objects related to TestMessageSets - TestMessageSet.getAll(); - } - +public abstract class TestMessage extends Multiton { private final SOAPSpec spec; private final String name; TestMessage(SOAPSpec spec, String name) { this.spec = spec; this.name = name; - instances.add(this); } - public static TestMessage[] getAll() { + @Instances + private static TestMessage[] instances() { + List<TestMessage> instances = new ArrayList<TestMessage>(); + for (TestMessageSet set : getInstances(TestMessageSet.class)) { + for (SOAPSpec spec : getInstances(SOAPSpec.class)) { + instances.add(set.getMessage(spec)); + } + } return instances.toArray(new TestMessage[instances.size()]); } Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/TestMessageSet.java Tue May 5 22:34:47 2015 @@ -18,15 +18,12 @@ */ package org.apache.axiom.ts.soap; -import java.util.ArrayList; -import java.util.List; +import org.apache.axiom.testing.multiton.Multiton; /** * A set of two equivalent SOAP messages, one for SOAP 1.1 and one for SOAP 1.2. */ -public final class TestMessageSet extends Adaptable { - private static final List<TestMessageSet> instances = new ArrayList<TestMessageSet>(); - +public final class TestMessageSet extends Multiton { /** * A simple SOAP message without header. */ @@ -69,13 +66,8 @@ public final class TestMessageSet extend private TestMessageSet(String name) { soap12Message = new SimpleTestMessage(SOAPSpec.SOAP12, "test-message/set/" + name + ".xml", "soap12/" + name); soap11Message = new ConvertedTestMessage(soap12Message, "soap11/" + name); - instances.add(this); } - public static TestMessageSet[] getAll() { - return instances.toArray(new TestMessageSet[instances.size()]); - } - /** * Get the test message for the given SOAP version. * Modified: webservices/axiom/trunk/testing/soap-testsuite/src/test/java/org/apache/axiom/ts/soap/ValidationTest.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/test/java/org/apache/axiom/ts/soap/ValidationTest.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/soap-testsuite/src/test/java/org/apache/axiom/ts/soap/ValidationTest.java (original) +++ webservices/axiom/trunk/testing/soap-testsuite/src/test/java/org/apache/axiom/ts/soap/ValidationTest.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.transform.stream.StreamSource; import junit.framework.TestCase; @@ -38,7 +40,7 @@ public class ValidationTest extends Test public static TestSuite suite() { TestSuite suite = new TestSuite(); - for (TestMessage message : TestMessage.getAll()) { + for (TestMessage message : getInstances(TestMessage.class)) { suite.addTest(new ValidationTest(message)); } return suite; Modified: webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapter.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapter.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapter.java (original) +++ webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapter.java Tue May 5 22:34:47 2015 @@ -18,7 +18,7 @@ */ package org.apache.axiom.ts.springws; -import org.apache.axiom.ts.soap.AdapterType; +import org.apache.axiom.testing.multiton.AdapterType; @AdapterType public final class SOAPSpecAdapter { Modified: webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapterFactory.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapterFactory.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapterFactory.java (original) +++ webservices/axiom/trunk/testing/spring-ws-testsuite/src/main/java/org/apache/axiom/ts/springws/SOAPSpecAdapterFactory.java Tue May 5 22:34:47 2015 @@ -18,8 +18,8 @@ */ package org.apache.axiom.ts.springws; -import org.apache.axiom.ts.soap.AdapterFactory; -import org.apache.axiom.ts.soap.Adapters; +import org.apache.axiom.testing.multiton.AdapterFactory; +import org.apache.axiom.testing.multiton.Adapters; import org.apache.axiom.ts.soap.SOAPSpec; public class SOAPSpecAdapterFactory implements AdapterFactory<SOAPSpec> { Modified: webservices/axiom/trunk/testing/testutils/pom.xml URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/testutils/pom.xml?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/testutils/pom.xml (original) +++ webservices/axiom/trunk/testing/testutils/pom.xml Tue May 5 22:34:47 2015 @@ -51,6 +51,11 @@ <artifactId>${stax.impl.artifact}</artifactId> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>multiton</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> Modified: webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java?rev=1677901&r1=1677900&r2=1677901&view=diff ============================================================================== --- webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java (original) +++ webservices/axiom/trunk/testing/testutils/src/main/java/org/apache/axiom/testutils/conformance/ConformanceTestFile.java Tue May 5 22:34:47 2015 @@ -31,13 +31,13 @@ import javax.xml.stream.XMLStreamExcepti import javax.xml.stream.XMLStreamReader; import javax.xml.transform.stream.StreamSource; +import org.apache.axiom.testing.multiton.Multiton; +import org.apache.axiom.testing.multiton.Instances; import org.codehaus.stax2.DTDInfo; import com.ctc.wstx.stax.WstxInputFactory; -public final class ConformanceTestFile { - private static ConformanceTestFile[] instances; - +public final class ConformanceTestFile extends Multiton { private final String resourceName; private final String shortName; private final boolean hasDTD; @@ -87,51 +87,41 @@ public final class ConformanceTestFile { return ConformanceTestFile.class.getClassLoader().getResource(resourceName); } - public static synchronized ConformanceTestFile[] getConformanceTestFiles() { - if (instances == null) { - try { - BufferedReader in = new BufferedReader(new InputStreamReader( - ConformanceTestFile.class.getResourceAsStream("filelist"))); - List result = new ArrayList(10); - // We make use of Woodstox' DTDInfo interface here, but we want to be able to use system properties - // to specify the StAX implementation to be used by the tests. Therefore we need to create - // an instance of the Woodstox InputFactory implementation directly. - XMLInputFactory inputFactory = new WstxInputFactory(); - inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); - String name; - while ((name = in.readLine()) != null) { - String resourceName = "org/apache/axiom/testutils/conformance/" + name; - boolean hasDTD = false; - boolean hasExternalSubset = false; - boolean hasInternalSubset = false; - boolean hasEntityReferences = false; - try { - XMLStreamReader reader = inputFactory.createXMLStreamReader(new StreamSource( - ConformanceTestFile.class.getResource(name).toString())); - while (reader.hasNext()) { - switch (reader.next()) { - case XMLStreamReader.DTD: - hasDTD = true; - hasInternalSubset = reader.getText().length() > 0; - hasExternalSubset = ((DTDInfo)reader).getDTDSystemId() != null; - break; - case XMLStreamReader.ENTITY_REFERENCE: - hasEntityReferences = true; - break; - } - } - reader.close(); - } catch (XMLStreamException ex) { - throw new Error("Unable to parse " + resourceName); - } - result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasExternalSubset, hasInternalSubset, hasEntityReferences)); + @Instances + private static ConformanceTestFile[] instances() throws IOException, XMLStreamException { + BufferedReader in = new BufferedReader(new InputStreamReader( + ConformanceTestFile.class.getResourceAsStream("filelist"))); + List<ConformanceTestFile> result = new ArrayList<ConformanceTestFile>(10); + // We make use of Woodstox' DTDInfo interface here, but we want to be able to use system properties + // to specify the StAX implementation to be used by the tests. Therefore we need to create + // an instance of the Woodstox InputFactory implementation directly. + XMLInputFactory inputFactory = new WstxInputFactory(); + inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE); + String name; + while ((name = in.readLine()) != null) { + String resourceName = "org/apache/axiom/testutils/conformance/" + name; + boolean hasDTD = false; + boolean hasExternalSubset = false; + boolean hasInternalSubset = false; + boolean hasEntityReferences = false; + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StreamSource( + ConformanceTestFile.class.getResource(name).toString())); + while (reader.hasNext()) { + switch (reader.next()) { + case XMLStreamReader.DTD: + hasDTD = true; + hasInternalSubset = reader.getText().length() > 0; + hasExternalSubset = ((DTDInfo)reader).getDTDSystemId() != null; + break; + case XMLStreamReader.ENTITY_REFERENCE: + hasEntityReferences = true; + break; } - in.close(); - return (ConformanceTestFile[])result.toArray(new ConformanceTestFile[result.size()]); - } catch (IOException ex) { - throw new Error("Unable to load file list: " + ex.getMessage()); } + reader.close(); + result.add(new ConformanceTestFile(resourceName, name, hasDTD, hasExternalSubset, hasInternalSubset, hasEntityReferences)); } - return (ConformanceTestFile[])instances.clone(); + in.close(); + return result.toArray(new ConformanceTestFile[result.size()]); } }