Author: veithen
Date: Sun Dec 21 13:53:54 2008
New Revision: 728524

URL: http://svn.apache.org/viewvc?rev=728524&view=rev
Log:
WSCOMMONS-419: Refactored duplicate code in AttributeTest (DOOM) and 
AttributeImplTest (LLOM) into a common base class in axiom-api's tests.

Added:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml
    webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
    
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml?rev=728524&r1=728523&r2=728524&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml Sun Dec 
21 13:53:54 2008
@@ -99,6 +99,18 @@
                     </archive>
                 </configuration>
             </plugin>
+            <!-- Attach a JAR with the test classes so that we can reuse them 
in other modules
+                 (see 
http://maven.apache.org/guides/mini/guide-attached-tests.html). -->
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
             <plugin>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>

Added: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java?rev=728524&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
 (added)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
 Sun Dec 21 13:53:54 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.om;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+public class OMAttributeTestBase extends TestCase {
+    private final OMImplementation omImplementation;
+
+    public OMAttributeTestBase(OMImplementation omImplementation) {
+        this.omImplementation = omImplementation;
+    }
+    
+    /**
+     * Make sure getQName() works correctly on an OMAttribute implementation.
+     * @throws Exception
+     */
+    public void testQNames() throws Exception {
+        String ATTR = "attr";
+        String NSURI = "http://ns1";;
+        OMFactory fac = omImplementation.getOMFactory();
+        OMNamespace ns = fac.createOMNamespace(NSURI, null);
+        OMAttribute attr = fac.createOMAttribute(ATTR, ns, "value");
+        QName qname = attr.getQName();
+        assertEquals("Wrong namespace", NSURI, qname.getNamespaceURI());
+        assertEquals("Wrong localPart", ATTR, qname.getLocalPart());
+        assertEquals("Wrong prefix", "", qname.getPrefix());
+    }
+}

Propchange: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/OMAttributeTestBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml?rev=728524&r1=728523&r2=728524&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Sun Dec 
21 13:53:54 2008
@@ -55,6 +55,13 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-stax-api_1.0_spec</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <classifier>tests</classifier>
+            <version>${axiom.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <resources>

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java?rev=728524&r1=728523&r2=728524&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/AttributeTest.java
 Sun Dec 21 13:53:54 2008
@@ -19,28 +19,11 @@
 
 package org.apache.axiom.om.impl.dom;
 
-import junit.framework.TestCase;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.OMAttributeTestBase;
+import org.apache.axiom.om.impl.dom.factory.OMDOMImplementation;
 
-import javax.xml.namespace.QName;
-
-public class AttributeTest extends TestCase {
-    /**
-     * Make sure getQName() works correctly on AttrImpl
-     * @throws Exception
-     */
-    public void testQNames() throws Exception {
-        String ATTR = "attr";
-        String NSURI = "http://ns1";;
-        OMFactory fac = new OMDOMFactory();
-        OMNamespace ns = new NamespaceImpl(NSURI);
-        OMAttribute attr = fac.createOMAttribute(ATTR, ns, "value");
-        QName qname = attr.getQName();
-        assertEquals("Wrong namespace", NSURI, qname.getNamespaceURI());
-        assertEquals("Wrong localPart", ATTR, qname.getLocalPart());
-        assertEquals("Wrong prefix", "", qname.getPrefix());
+public class AttributeTest extends OMAttributeTestBase {
+    public AttributeTest() {
+        super(new OMDOMImplementation());
     }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml?rev=728524&r1=728523&r2=728524&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml 
(original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/pom.xml Sun Dec 
21 13:53:54 2008
@@ -59,6 +59,13 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-stax-api_1.0_spec</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <classifier>tests</classifier>
+            <version>${axiom.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <resources>

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java?rev=728524&r1=728523&r2=728524&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/test/java/org/apache/axiom/om/impl/llom/AttributeImplTest.java
 Sun Dec 21 13:53:54 2008
@@ -1,40 +1,30 @@
-package org.apache.axiom.om.impl.llom;
-
-import junit.framework.TestCase;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
 /*
- * Copyright 2007 The Apache Software Foundation.
+ * 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
  *
- * Licensed 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
  *
- *      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.
+ * 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.
  */
 
-public class AttributeImplTest extends TestCase {
-    public void testQNames() throws Exception {
-        String ATTR = "attr";
-        String NSURI = "http://ns1";;
-        OMFactory fac = new OMLinkedListImplFactory();
-        OMNamespace ns = fac.createOMNamespace(NSURI, null);
-        OMAttribute attr = new OMAttributeImpl(ATTR, ns, "value", fac);
-        QName qname = attr.getQName();
-        assertEquals("Wrong namespace", NSURI, qname.getNamespaceURI());
-        assertEquals("Wrong localPart", ATTR, qname.getLocalPart());
-        assertEquals("Wrong prefix", "", qname.getPrefix());
+package org.apache.axiom.om.impl.llom;
+
+import org.apache.axiom.om.OMAttributeTestBase;
+import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplementation;
 
+public class AttributeImplTest extends OMAttributeTestBase {
+    public AttributeImplTest() {
+        super(new OMLinkedListImplementation());
     }
+    
 }


Reply via email to