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 2011/01/13 08:35:19 UTC

svn commit: r1058435 - in /webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts: AxiomTestSuiteBuilder.java om/attribute/TestEqualsHashCode.java

Author: veithen
Date: Thu Jan 13 07:35:19 2011
New Revision: 1058435

URL: http://svn.apache.org/viewvc?rev=1058435&view=rev
Log:
Added a test case for the equals and hashCode methods in OMAttribute implementations.

Added:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java?rev=1058435&r1=1058434&r2=1058435&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/AxiomTestSuiteBuilder.java Thu Jan 13 07:35:19 2011
@@ -44,6 +44,7 @@ public class AxiomTestSuiteBuilder {
         String[] conformanceFiles = AbstractTestCase.getConformanceTestFiles();
         suite = new TestSuite();
         addTest(new org.apache.axiom.ts.om.attribute.TestGetQName(metaFactory));
+        addTest(new org.apache.axiom.ts.om.attribute.TestEqualsHashCode(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElement(metaFactory));
         addTest(new org.apache.axiom.ts.om.builder.TestGetDocumentElementWithDiscardDocument(metaFactory));
         for (int i=0; i<conformanceFiles.length; i++) {

Added: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java?rev=1058435&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java Thu Jan 13 07:35:19 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.om.attribute;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.ts.AxiomTestCase;
+
+public class TestEqualsHashCode extends AxiomTestCase {
+    public TestEqualsHashCode(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace ns1 = factory.createOMNamespace("urn:ns1", "ns1");
+        OMNamespace ns2 = factory.createOMNamespace("urn:ns2", "ns2");
+        OMNamespace ns3 = factory.createOMNamespace("urn:ns1", "p");
+        OMAttribute attr1 = factory.createOMAttribute("attr", ns1, "value");
+        OMAttribute attr2 = factory.createOMAttribute("attr", ns1, "value");
+        assertEquals(attr1, attr1);
+        assertEquals(attr1, attr2);
+        assertEquals(attr1.hashCode(), attr2.hashCode());
+        assertFalse(attr1.equals(factory.createOMAttribute("otherattr", ns1, "value")));
+        assertFalse(attr1.equals(factory.createOMAttribute("attr", ns2, "value")));
+        assertFalse(attr1.equals(factory.createOMAttribute("attr", ns1, "othervalue")));
+        assertFalse(attr1.equals(factory.createOMAttribute("attr", ns3, "value")));
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/attribute/TestEqualsHashCode.java
------------------------------------------------------------------------------
    svn:eol-style = native