You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/07/29 22:26:51 UTC

svn commit: r799059 - in /webservices/commons/trunk/modules/axiom: ./ modules/axiom-parser-tests/ modules/axiom-parser-tests/src/ modules/axiom-parser-tests/src/test/ modules/axiom-parser-tests/src/test/java/ modules/axiom-tests/

Author: veithen
Date: Wed Jul 29 20:26:50 2009
New Revision: 799059

URL: http://svn.apache.org/viewvc?rev=799059&view=rev
Log:
Added a parser compatibility test suite. It simply executes the existing unit tests with different StAX implementations.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java   (with props)
    webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml
    webservices/commons/trunk/modules/axiom/pom.xml

Added: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml?rev=799059&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml Wed Jul 29 20:26:50 2009
@@ -0,0 +1,166 @@
+<?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>axiom</artifactId>
+        <version>1.2.9-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>axiom-parser-tests</artifactId>
+    <name>Axiom Parser Compatibility Test Suite</name>
+    <description>
+        This module executes the existing unit tests of some of the other modules using different
+        StAX implementations.
+    </description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>${version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>${stax.impl.groupid}</groupId>
+                    <artifactId>${stax.impl.artifact}</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-dom</artifactId>
+            <version>${version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>${stax.impl.groupid}</groupId>
+                    <artifactId>${stax.impl.artifact}</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>xalan</groupId>
+            <artifactId>xalan</artifactId>
+            <version>2.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <testResources>
+            <testResource>
+                <directory>test-resources</directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-test-jars</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.ws.commons.axiom</groupId>
+                                    <artifactId>axiom-api</artifactId>
+                                    <classifier>tests</classifier>
+                                    <version>${version}</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.ws.commons.axiom</groupId>
+                                    <artifactId>axiom-impl</artifactId>
+                                    <classifier>tests</classifier>
+                                    <version>${version}</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.ws.commons.axiom</groupId>
+                                    <artifactId>axiom-dom</artifactId>
+                                    <classifier>tests</classifier>
+                                    <version>${version}</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.ws.commons.axiom</groupId>
+                                    <artifactId>axiom-tests</artifactId>
+                                    <classifier>tests</classifier>
+                                    <version>${version}</version>
+                                </artifactItem>
+                            </artifactItems>
+                            <outputDirectory>${project.build.directory}/test-jars</outputDirectory>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>copy-parsers</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.codehaus.woodstox</groupId>
+                                    <artifactId>wstx-asl</artifactId>
+                                    <version>3.2.9</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>com.sun.xml.stream</groupId>
+                                    <artifactId>sjsxp</artifactId>
+                                    <version>1.0.1</version>
+                                </artifactItem>
+                            </artifactItems>
+                            <outputDirectory>${project.build.directory}/parsers</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java?rev=799059&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java Wed Jul 29 20:26:50 2009
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class ParserTest extends TestCase {
+    public static Test suite() throws Exception {
+        ClassLoader parentClassLoader = ParserTest.class.getClassLoader();
+        File targetDir = new File("target");
+        FilenameFilter jarFilter = new FilenameFilter() {
+            public boolean accept(File dir, String name) {
+                return name.endsWith(".jar");
+            }
+        };
+        File[] testJars = new File(targetDir, "test-jars").listFiles(jarFilter);
+        
+        // Build the class loader. We use a single class loader for all test JARs because there
+        // are dependencies between them.
+        URL[] testJarUrls = new URL[testJars.length];
+        for (int i=0; i<testJars.length; i++) {
+            testJarUrls[i] = testJars[i].toURL();
+        }
+        ClassLoader testClassLoader = new URLClassLoader(testJarUrls, parentClassLoader);
+        
+        // Scan the test JARs for test cases/suites and build a test suite from them
+        TestSuite suite = new TestSuite();
+        for (int i=0; i<testJars.length; i++) {
+            JarInputStream jar = new JarInputStream(new FileInputStream(testJars[i]));
+            try {
+                JarEntry entry;
+                while ((entry = jar.getNextJarEntry()) != null) {
+                    String name = entry.getName();
+                    if (name.endsWith("Test.class")) {
+                        Class testClass = testClassLoader.loadClass(name.substring(0, name.length()-6).replace('/', '.'));
+                        if (TestCase.class.isAssignableFrom(testClass) && !Modifier.isAbstract(testClass.getModifiers())) {
+                            try {
+                                Method suiteMethod = testClass.getMethod("suite", new Class[0]);
+                                int modifiers = suiteMethod.getModifiers();
+                                if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)
+                                        && Test.class.isAssignableFrom(suiteMethod.getReturnType())) {
+                                    suite.addTest((Test)suiteMethod.invoke(null, new Object[0]));
+                                }
+                            } catch (NoSuchMethodException e) {
+                                suite.addTest(new TestSuite(testClass));
+                            }
+                        }
+                    }
+                }
+            } finally {
+                jar.close();
+            }
+        }
+        
+        // Build decorators that execute the test suite using different StAX implementations
+        File[] parserJars = new File(targetDir, "parsers").listFiles(jarFilter);
+        TestSuite superSuite = new TestSuite();
+        for (int i=0; i<parserJars.length; i++) {
+            ClassLoader parserClassLoader = new URLClassLoader(new URL[] { parserJars[i].toURL() }, parentClassLoader);
+            superSuite.addTest(new SetContextClassLoaderTestWrapper(suite, parserClassLoader));
+        }
+        return superSuite;
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/ParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java?rev=799059&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java Wed Jul 29 20:26:50 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+import junit.extensions.TestDecorator;
+import junit.framework.Test;
+import junit.framework.TestResult;
+
+public class SetContextClassLoaderTestWrapper extends TestDecorator {
+    private final ClassLoader classLoader;
+    
+    public SetContextClassLoaderTestWrapper(Test test, ClassLoader classLoader) {
+        super(test);
+        this.classLoader = classLoader;
+    }
+
+    public void run(TestResult result) {
+        Thread currentThread = Thread.currentThread();
+        ClassLoader savedClassLoader = currentThread.getContextClassLoader();
+        currentThread.setContextClassLoader(classLoader);
+        try {
+            super.run(result);
+        } finally {
+            currentThread.setContextClassLoader(savedClassLoader);
+        }
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-parser-tests/src/test/java/SetContextClassLoaderTestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml?rev=799059&r1=799058&r2=799059&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml Wed Jul 29 20:26:50 2009
@@ -102,5 +102,17 @@
                 <directory>test-resources</directory>
             </testResource>
         </testResources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
     </build>
 </project>

Modified: webservices/commons/trunk/modules/axiom/pom.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/pom.xml?rev=799059&r1=799058&r2=799059&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/pom.xml Wed Jul 29 20:26:50 2009
@@ -714,6 +714,7 @@
         <module>modules/axiom-c14n</module>
         <module>modules/axiom-tests</module>
         <module>modules/axiom-osgi</module>
+        <module>modules/axiom-parser-tests</module>
     </modules>
     <properties>
         <axiom.version>${pom.version}</axiom.version>