You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/07/07 20:24:12 UTC

svn commit: r1358610 [10/10] - in /webservices/axiom/branches/AXIOM-201: ./ modules/axiom-api/ modules/axiom-api/src/main/java/org/apache/axiom/attachments/ modules/axiom-api/src/main/java/org/apache/axiom/locator/ modules/axiom-api/src/main/java/org/a...

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/envelope/TestGetSOAPBodyFirstElementLocalNameAndNSWithParser.java Sat Jul  7 18:24:00 2012
@@ -20,6 +20,7 @@ package org.apache.axiom.ts.soap.envelop
 
 import java.io.StringReader;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMElement;
@@ -38,8 +39,13 @@ import org.apache.axiom.ts.soap.SOAPTest
  * the name of the element without actually instantiating the corresponding {@link OMElement}.
  */
 public class TestGetSOAPBodyFirstElementLocalNameAndNSWithParser extends SOAPTestCase {
-    public TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(OMMetaFactory metaFactory, SOAPSpec spec) {
+    private final QName qname;
+    
+    public TestGetSOAPBodyFirstElementLocalNameAndNSWithParser(OMMetaFactory metaFactory, SOAPSpec spec, QName qname) {
         super(metaFactory, spec);
+        this.qname = qname;
+        addTestProperty("prefix", qname.getPrefix());
+        addTestProperty("uri", qname.getNamespaceURI());
     }
 
     protected void runTest() throws Throwable {
@@ -47,13 +53,18 @@ public class TestGetSOAPBodyFirstElement
         // doesn't contain any unwanted whitespace.
         SOAPFactory factory = spec.getFactory(metaFactory);
         SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
-        OMNamespace ns = factory.createOMNamespace("urn:test", "ns");
-        factory.createOMElement("echo", ns, orgEnvelope.getBody());
+        orgEnvelope.getBody().addChild(soapFactory.createOMElement(qname.getLocalPart(), qname.getNamespaceURI(), qname.getPrefix()));
         String message = orgEnvelope.toString();
         
         SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, new StringReader(message)).getSOAPEnvelope();
-        assertEquals("echo", envelope.getSOAPBodyFirstElementLocalName());
-        assertEquals(ns, envelope.getSOAPBodyFirstElementNS());
+        assertEquals(qname.getLocalPart(), envelope.getSOAPBodyFirstElementLocalName());
+        OMNamespace ns = envelope.getSOAPBodyFirstElementNS();
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(ns);
+        } else {
+            assertEquals(qname.getNamespaceURI(), ns.getNamespaceURI());
+            assertEquals(qname.getPrefix(), ns.getPrefix());
+        }
         
         // Also request an XMLStreamReader. The LLOM implementation triggers some special processing
         // in this case (because the getSOAPBodyFirstElementXXX calls put the builder in lookahead
@@ -64,8 +75,16 @@ public class TestGetSOAPBodyFirstElement
         assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
         assertEquals("Body", reader.getLocalName());
         assertEquals(XMLStreamReader.START_ELEMENT, reader.next());
-        assertEquals("echo", reader.getLocalName());
-        assertEquals("ns", reader.getPrefix());
-        assertEquals("urn:test", reader.getNamespaceURI());
+        assertEquals(qname.getLocalPart(), reader.getLocalName());
+        if (qname.getNamespaceURI().length() == 0) {
+            assertNull(reader.getNamespaceURI());
+        } else {
+            assertEquals(qname.getNamespaceURI(), reader.getNamespaceURI());
+        }
+        if (qname.getPrefix().length() == 0) {
+            assertNull(reader.getPrefix());
+        } else {
+            assertEquals(qname.getPrefix(), reader.getPrefix());
+        }
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/pom.xml?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/pom.xml (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/pom.xml Sat Jul  7 18:24:00 2012
@@ -62,4 +62,65 @@
             <artifactId>org.osgi.core</artifactId>
         </dependency>
     </dependencies>
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+            <resource>
+                <directory>${project.build.directory}/generated-resources</directory>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.gmaven</groupId>
+                <artifactId>gmaven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <source>
+                                <!-- This generates a list of the files in src/main/resources/org/apache/axiom/testutils/conformance.
+                                     This is useful when loading these files from the classpath. -->
+                                <![CDATA[
+                                    def filelist = new File(project.build.directory, "generated-resources/org/apache/axiom/testutils/conformance/filelist");
+                                    filelist.parentFile.mkdirs();
+                                    filelist.delete();
+                                    new File(project.basedir, "src/main/resources/org/apache/axiom/testutils/conformance").eachFile({
+                                        if (it.file) {
+                                            filelist.append("$it.name\n");
+                                        }
+                                    })
+                                ]]>
+                            </source>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <profiles>
+        <profile>
+            <id>apache-release</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.rat</groupId>
+                        <artifactId>apache-rat-plugin</artifactId>
+                        <configuration>
+                            <excludes>
+                                <!-- src/main/resources contains test files and they obviously cannot
+                                     all contain a valid license header -->
+                                <exclude>src/main/resources/**</exclude>
+                            </excludes>
+                        </configuration> 
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-testutils/src/main/java/org/apache/axiom/testutils/io/ExceptionInputStream.java Sat Jul  7 18:24:00 2012
@@ -25,35 +25,50 @@ import java.io.InputStream;
 import org.apache.commons.io.input.ProxyInputStream;
 
 /**
- * {@link InputStream} wrapper that throw an exception when the end of the
- * parent stream is reached.
+ * {@link InputStream} wrapper that throws an exception after a configurable number of bytes have
+ * been read from the stream or when the end of the stream is reached.
  */
 public class ExceptionInputStream extends ProxyInputStream {
+    private int remaining;
+    
     public ExceptionInputStream(InputStream in) {
+        this(in, Integer.MAX_VALUE);
+    }
+
+    public ExceptionInputStream(InputStream in, int maxBytes) {
         super(in);
+        remaining = maxBytes;
     }
 
     public int read() throws IOException {
+        if (remaining == 0) {
+            throw new IOException("Maximum number of bytes read");
+        }
         int b = super.read();
         if (b == -1) {
             throw new IOException("End of stream reached");
         }
+        remaining--;
         return b;
     }
 
     public int read(byte[] b) throws IOException {
-        int c = super.read(b);
-        if (c == -1) {
-            throw new IOException("End of stream reached");
-        }
-        return c;
+        return read(b, 0, b.length);
     }
 
     public int read(byte[] b, int off, int len) throws IOException {
-        int c = super.read(b, off, len);
+        if (remaining == 0) {
+            throw new IOException("Maximum number of bytes read");
+        }
+        // Note: We use a sort of throttling mechanism here where we reduce the
+        //       number of bytes read if we approach the point where we throw an
+        //       exception. This is useful when testing consumers that tend to
+        //       read too much in advance.
+        int c = super.read(b, off, Math.min(Math.max(1, remaining/2), len));
         if (c == -1) {
             throw new IOException("End of stream reached");
         }
+        remaining -= c;
         return c;
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/src/docbkx/userguide.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/src/docbkx/userguide.xml?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/src/docbkx/userguide.xml (original)
+++ webservices/axiom/branches/AXIOM-201/src/docbkx/userguide.xml Sat Jul  7 18:24:00 2012
@@ -1452,6 +1452,30 @@ while (iterator.hasNext()) {
                         to avoid depending on two different versions of Woodstox.
                     </para>
                 </section>
+                <section>
+                    <title>DOOM factories are now stateless</title>
+                    <para>
+                        In contrast to previous versions, the <classname>OMFactory</classname> implementations for DOOM are
+                        stateless in Axiom 1.2.14. This makes it easier to write application code that is portable between
+                        LLOM and DOOM (in the sense that code that is known to work with LLOM will usually work with DOOM without
+                        changes). However, this slightly changes the behavior of DOOM with respect to owner documents, which means that
+                        in some cases existing code written for DOOM may trigger <literal>WRONG_DOCUMENT_ERR</literal> exceptions
+                        if it uses the DOM API on a tree created or manipulated using the Axiom API.
+                    </para>
+                    <para>
+                        For more information about the new semantics, refer to the Javadoc of <classname>DOMMetaFactory</classname>
+                        and to <ulink url="https://issues.apache.org/jira/browse/AXIOM-412">AXIOM-412</ulink>.
+                    </para>
+                </section>
+                <section>
+                    <title>Removal of deprecated classes from core artifacts</title>
+                    <para>
+                        Several deprecated classes have been moved to a new JAR file named <filename>axiom-compat</filename> and are
+                        no longer included in the core artifacts (<filename>axiom-api</filename>, <filename>axiom-impl</filename>
+                        and <filename>axiom-dom</filename>). If you rely on these deprecated classes or get <classname>NoClassDefFoundError</classname>s
+                        after upgrading to Axiom 1.2.14, then you need to add this new JAR to your project's dependencies.
+                    </para>
+                </section>
             </section>
         </section>
     </chapter>

Modified: webservices/axiom/branches/AXIOM-201/src/site/apt/roadmap.apt
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/src/site/apt/roadmap.apt?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/src/site/apt/roadmap.apt (original)
+++ webservices/axiom/branches/AXIOM-201/src/site/apt/roadmap.apt Sat Jul  7 18:24:00 2012
@@ -71,6 +71,35 @@ API inconsistencies to be eliminated
      Since the document element is unique, these methods are not meaningful for <<<OMDocument>>>
      and they should be declared by <<<OMElement>>> instead.
 
+* Exception hierarchy
+
+  The way exceptions are used in Axiom 1.2.x is not very consistent. In addition it doesn't allow application
+  code to distinguish between different types of error cases. This should be improved in
+  Axiom 1.3 to meet the following requirements:
+  
+   * Although the two implementations of the Axiom API (LLOM and DOOM) use StAX as XML parser and serializer, this
+     is not a strict requirement. The only strict requirements are that the implementation is able to
+     construct a tree from a <<<XMLStreamReader>>> supplied by application code, is able to serialize
+     a tree to an <<<XMLStreamWriter>>> and is able to construct an <<<XMLStreamReader>>> from a tree.
+     Therefore methods defined by the Axiom API should only declare <<<XMLStreamException>>> if they interact
+     directly with a StAX object supplied by application code.
+     
+     A good example is the <<<OMContainer#serialize(OutputStream)>>> method. In Axiom 1.2.x this method
+     is declared to throw <<<XMLStreamException>>>. This assumes that the implementation necessarily uses
+     StAX as XML serializer. This is a wrong assumption, because the implementation is free to use its
+     own serializer. Also note that the method doesn't declare <<<IOException>>> which would be much more relevant.
+   
+   * Axiom should have well-defined (and distinct) exceptions for at least the following two error cases:
+   
+     * An I/O error occurs during a deferred parsing operation. In that case, the unchecked exception should
+       wrap the original <<<IOException>>> so that it can be extracted by application code.
+     
+     * A parser error occurs during a deferred parsing operation.
+   
+   * <<<OMException>>> should only be thrown by APIs in the <<<org.apache.axiom.om>>> and <<<org.apache.axiom.soap>>>
+     packages (and their subpackages). However, in Axiom 1.2.x that exception is used by the MIME/attachments API
+     as well.
+
 Removal of unnecessary or irrelevant APIs
 
   This section identifies APIs that have become unnecessary or irrelevant. Note that APIs that

Modified: webservices/axiom/branches/AXIOM-201/src/site/xdoc/download.xml.vm
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/src/site/xdoc/download.xml.vm?rev=1358610&r1=1358609&r2=1358610&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/src/site/xdoc/download.xml.vm (original)
+++ webservices/axiom/branches/AXIOM-201/src/site/xdoc/download.xml.vm Sat Jul  7 18:24:00 2012
@@ -64,7 +64,7 @@
 
                                 <br/>
                             </td>
-                            <td>02 - Apr - 2011</td>
+                            <td>02 - Apr - 2012</td>
                             <td>1.2.13 Release (Mirrored)</td>
                         </tr>