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/25 22:58:09 UTC

svn commit: r1681654 - in /webservices/axiom/trunk/testing: soap-testsuite/ soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ xml-testsuite/src/main/java/org/apache/axiom/ts/xml/

Author: veithen
Date: Mon May 25 20:58:09 2015
New Revision: 1681654

URL: http://svn.apache.org/r1681654
Log:
Integrate XMLSample, SOAPSample and MIMESample into a common class hierarchy.

Added:
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java
      - copied, changed from r1681650, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSample.java
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java   (with props)
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java   (with props)
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java   (with props)
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java   (with props)
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java   (with props)
Removed:
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSample.java
Modified:
    webservices/axiom/trunk/testing/soap-testsuite/pom.xml
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/MIMESample.java
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSample.java
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSampleSet.java
    webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleSOAPSample.java
    webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/XMLSample.java

Modified: webservices/axiom/trunk/testing/soap-testsuite/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/pom.xml?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/pom.xml (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/pom.xml Mon May 25 20:58:09 2015
@@ -36,7 +36,7 @@
     <dependencies>
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>multiton</artifactId>
+            <artifactId>xml-testsuite</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>

Copied: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java (from r1681650, webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSample.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java?p2=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java&p1=webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSample.java&r1=1681650&r2=1681654&rev=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSample.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/ConvertedSOAPSampleContent.java Mon May 25 20:58:09 2015
@@ -18,9 +18,8 @@
  */
 package org.apache.axiom.ts.soap;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 
 import javax.xml.XMLConstants;
 import javax.xml.namespace.QName;
@@ -29,6 +28,7 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.axiom.ts.xml.ComputedMessageContent;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -36,39 +36,28 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-final class ConvertedSOAPSample extends SOAPSample {
+final class ConvertedSOAPSampleContent extends ComputedMessageContent {
     private final SOAPSample soap12Message;
-    private byte[] content;
 
-    ConvertedSOAPSample(SOAPSample soap12Message, String name) {
-        super(SOAPSpec.SOAP11, name);
+    ConvertedSOAPSampleContent(SOAPSample soap12Message) {
         this.soap12Message = soap12Message;
     }
 
     @Override
-    public synchronized InputStream getInputStream() {
-        if (content == null) {
-            try {
-                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                factory.setNamespaceAware(true);
-                Document document;
-                InputStream in = soap12Message.getInputStream();
-                try {
-                    document = factory.newDocumentBuilder().parse(in);
-                } finally {
-                    in.close();
-                }
-                processSOAPElement(document.getDocumentElement(), SOAPElementType.ENVELOPE);
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                TransformerFactory.newInstance().newTransformer().transform(
-                        new DOMSource(document),
-                        new StreamResult(baos));
-                content = baos.toByteArray();
-            } catch (Exception ex) {
-                throw new Error("Error converting SOAP message", ex);
-            }
+    protected void buildContent(OutputStream out) throws Exception {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        Document document;
+        InputStream in = soap12Message.getInputStream();
+        try {
+            document = factory.newDocumentBuilder().parse(in);
+        } finally {
+            in.close();
         }
-        return new ByteArrayInputStream(content);
+        processSOAPElement(document.getDocumentElement(), SOAPElementType.ENVELOPE);
+        TransformerFactory.newInstance().newTransformer().transform(
+                new DOMSource(document),
+                new StreamResult(out));
     }
     
     private static void processSOAPElement(Element element, SOAPElementType type) {

Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/MIMESample.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/MIMESample.java?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/MIMESample.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/MIMESample.java Mon May 25 20:58:09 2015
@@ -29,25 +29,18 @@ import javax.mail.internet.ContentType;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.internet.ParseException;
 
-public abstract class MIMESample {
-    private final String name;
+import org.apache.axiom.ts.xml.MessageContent;
+import org.apache.axiom.ts.xml.MessageSample;
+
+public abstract class MIMESample extends MessageSample {
     private final String contentType;
     private MimeMultipart multipart;
     
     MIMESample(String name, String contentType) {
-        this.name = name;
+        super(MessageContent.fromClasspath(MIMESample.class, name));
         this.contentType = contentType;
     }
 
-    /**
-     * Get the content of this message.
-     * 
-     * @return an input stream with the content of this message
-     */
-    public InputStream getInputStream() {
-        return MIMESample.class.getResourceAsStream(name);
-    }
-
     public String getContentType() {
         return contentType;
     }

Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSample.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSample.java?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSample.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSample.java Mon May 25 20:58:09 2015
@@ -20,7 +20,6 @@ package org.apache.axiom.ts.soap;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -30,7 +29,8 @@ 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.apache.axiom.ts.xml.MessageContent;
+import org.apache.axiom.ts.xml.XMLSample;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -39,13 +39,12 @@ import org.xml.sax.InputSource;
 /**
  * A SOAP test message.
  */
-public abstract class SOAPSample extends Multiton {
+public class SOAPSample extends XMLSample {
     private final SOAPSpec spec;
-    private final String name;
     
-    SOAPSample(SOAPSpec spec, String name) {
+    SOAPSample(SOAPSpec spec, MessageContent content, String name) {
+        super(content, name);
         this.spec = spec;
-        this.name = name;
     }
     
     @Instances
@@ -68,22 +67,6 @@ public abstract class SOAPSample extends
         return spec;
     }
     
-    /**
-     * Get the name of this message (for use in test case naming e.g.).
-     * 
-     * @return the name of this test message
-     */
-    public final String getName() {
-        return name;
-    }
-    
-    /**
-     * Get the content of this message.
-     * 
-     * @return an input stream with the content of this message
-     */
-    public abstract InputStream getInputStream();
-    
     public final Element getEnvelope() {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(true);

Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSampleSet.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSampleSet.java?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSampleSet.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPSampleSet.java Mon May 25 20:58:09 2015
@@ -65,7 +65,7 @@ public final class SOAPSampleSet extends
     
     private SOAPSampleSet(String name) {
         soap12Message = new SimpleSOAPSample(SOAPSpec.SOAP12, "test-message/set/" + name + ".xml", "soap12/" + name);
-        soap11Message = new ConvertedSOAPSample(soap12Message, "soap11/" + name);
+        soap11Message = new SOAPSample(SOAPSpec.SOAP11, new ConvertedSOAPSampleContent(soap12Message), "soap11/" + name);
     }
 
     /**

Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleSOAPSample.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleSOAPSample.java?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleSOAPSample.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/SimpleSOAPSample.java Mon May 25 20:58:09 2015
@@ -18,23 +18,15 @@
  */
 package org.apache.axiom.ts.soap;
 
-import java.io.InputStream;
+import org.apache.axiom.ts.xml.MessageContent;
 
 // TODO: this should eventually have package access
 public final class SimpleSOAPSample extends SOAPSample {
-    private final String resourceName;
-
     public SimpleSOAPSample(SOAPSpec spec, String resourceName) {
         this(spec, resourceName, resourceName);
     }
     
     SimpleSOAPSample(SOAPSpec spec, String resourceName, String name) {
-        super(spec, name);
-        this.resourceName = resourceName;
-    }
-
-    @Override
-    public InputStream getInputStream() {
-        return SimpleSOAPSample.class.getClassLoader().getResourceAsStream(resourceName);
+        super(spec, MessageContent.fromClasspath(SimpleSOAPSample.class.getClassLoader(), resourceName), name);
     }
 }

Added: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java?rev=1681654&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java (added)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java Mon May 25 20:58:09 2015
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+
+import javax.activation.DataSource;
+
+import org.apache.axiom.testutils.net.protocol.mem.DataSourceRegistry;
+
+public abstract class ComputedMessageContent extends MessageContent {
+    private byte[] content;
+    private URL url;
+
+    @Override
+    public final synchronized InputStream getInputStream() {
+        if (content == null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            try {
+                buildContent(baos);
+            } catch (Exception ex) {
+                throw new MessageContentLoadingException(ex);
+            }
+            content = baos.toByteArray();
+        }
+        return new ByteArrayInputStream(content);
+    }
+
+    @Override
+    public final synchronized URL getURL() {
+        if (url == null) {
+            url = DataSourceRegistry.registerDataSource(new DataSource() {
+                @Override
+                public OutputStream getOutputStream() throws IOException {
+                    throw new UnsupportedOperationException();
+                }
+                
+                @Override
+                public String getName() {
+                    return null;
+                }
+                
+                @Override
+                public InputStream getInputStream() throws IOException {
+                    return ComputedMessageContent.this.getInputStream();
+                }
+                
+                @Override
+                public String getContentType() {
+                    return "application/octet-stream";
+                }
+            }).getURL();
+        }
+        return url;
+    }
+
+    protected abstract void buildContent(OutputStream out) throws Exception;
+}

Propchange: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/ComputedMessageContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java?rev=1681654&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java (added)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java Mon May 25 20:58:09 2015
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.xml;
+
+import java.io.InputStream;
+import java.net.URL;
+
+public abstract class MessageContent {
+    public static MessageContent fromURL(URL url) {
+        return new URLMessageContent(url);
+    }
+    
+    public static MessageContent fromClasspath(Class<?> clazz, String relativeResourceName) {
+        return fromURL(clazz.getResource(relativeResourceName));
+    }
+    
+    public static MessageContent fromClasspath(ClassLoader classLoader, String resourceName) {
+        return fromURL(classLoader.getResource(resourceName));
+    }
+    
+    MessageContent() {}
+    
+    public abstract InputStream getInputStream();
+    public abstract URL getURL();
+}

Propchange: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java?rev=1681654&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java (added)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java Mon May 25 20:58:09 2015
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.xml;
+
+public class MessageContentLoadingException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    public MessageContentLoadingException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageContentLoadingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java?rev=1681654&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java (added)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java Mon May 25 20:58:09 2015
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.xml;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.axiom.testing.multiton.Multiton;
+
+public abstract class MessageSample extends Multiton {
+    private final MessageContent content;
+
+    public MessageSample(MessageContent content) {
+        this.content = content;
+    }
+
+    /**
+     * Get the content of this message.
+     * 
+     * @return an input stream with the content of this message
+     */
+    public final InputStream getInputStream() {
+        return content.getInputStream();
+    }
+    
+    public final URL getUrl() {
+        return content.getURL();
+    }
+}

Propchange: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/MessageSample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java?rev=1681654&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java (added)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java Mon May 25 20:58:09 2015
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+final class URLMessageContent extends MessageContent {
+    private final URL url;
+
+    URLMessageContent(URL url) {
+        this.url = url;
+    }
+
+    @Override
+    public InputStream getInputStream() {
+        try {
+            return url.openStream();
+        } catch (IOException ex) {
+            throw new MessageContentLoadingException(ex);
+        }
+    }
+
+    @Override
+    public URL getURL() {
+        return url;
+    }
+}

Propchange: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/URLMessageContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/XMLSample.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/XMLSample.java?rev=1681654&r1=1681653&r2=1681654&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/XMLSample.java (original)
+++ webservices/axiom/trunk/testing/xml-testsuite/src/main/java/org/apache/axiom/ts/xml/XMLSample.java Mon May 25 20:58:09 2015
@@ -20,16 +20,13 @@ package org.apache.axiom.ts.xml;
 
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.axiom.testing.multiton.Instances;
-import org.apache.axiom.testing.multiton.Multiton;
 
-public final class XMLSample extends Multiton {
+public class XMLSample extends MessageSample {
     /**
      * A simple XML document without any particular features.
      */
@@ -40,16 +37,25 @@ public final class XMLSample extends Mul
      */
     public static final XMLSample LARGE = new XMLSample("large.xml");
     
-    private final String resourceName;
     private final String name;
     private XMLSampleProperties properties;
     
+    protected XMLSample(MessageContent content, String name) {
+        super(content);
+        this.name = name;
+    }
+    
     private XMLSample(String relativeResourceName) {
-        resourceName = "org/apache/axiom/ts/xml/" + relativeResourceName;
-        name = resourceName.substring(resourceName.lastIndexOf('/')+1);
+        this(MessageContent.fromClasspath(XMLSample.class, relativeResourceName),
+                relativeResourceName.substring(relativeResourceName.lastIndexOf('/')+1));
     }
 
-    public String getName() {
+    /**
+     * Get the name of this message (for use in test case naming e.g.).
+     * 
+     * @return the name of this test message
+     */
+    public final String getName() {
         return name;
     }
 
@@ -61,34 +67,26 @@ public final class XMLSample extends Mul
         return properties;
     }
 
-    public String getEncoding() {
+    public final String getEncoding() {
         return getProperties().getEncoding();
     }
 
-    public boolean hasDTD() {
+    public final boolean hasDTD() {
         return getProperties().hasDTD();
     }
 
-    public boolean hasExternalSubset() {
+    public final boolean hasExternalSubset() {
         return getProperties().hasExternalSubset();
     }
 
-    public boolean hasInternalSubset() {
+    public final boolean hasInternalSubset() {
         return getProperties().hasInternalSubset();
     }
 
-    public boolean hasEntityReferences() {
+    public final boolean hasEntityReferences() {
         return getProperties().hasEntityReferences();
     }
 
-    public InputStream getInputStream() {
-        return XMLSample.class.getClassLoader().getResourceAsStream(resourceName);
-    }
-    
-    public URL getUrl() {
-        return XMLSample.class.getClassLoader().getResource(resourceName);
-    }
-    
     @Instances
     private static XMLSample[] instances() throws IOException {
         BufferedReader in = new BufferedReader(new InputStreamReader(