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 di...@apache.org on 2007/06/19 04:55:41 UTC
svn commit: r548566 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/ axiom-api/src/main/java/org/apache/axiom/om/impl/
axiom-api/src/test/ axiom-api/src/test/java/ axiom-api/src/test/java/org/
axiom-api/src/test/java/org/apache/ axiom-...
Author: dims
Date: Mon Jun 18 19:55:39 2007
New Revision: 548566
URL: http://svn.apache.org/viewvc?view=rev&rev=548566
Log:
Fix for WSCOMMONS-189 - NamespaceImpl and OMNamespaceImpl violate hashCode contract
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/NamespaceImplTestCase.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/
- copied from r548162, webservices/commons/trunk/modules/axiom/modules/axiom-dom/test/
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceImplTestCase.java
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-dom/test/
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNamespaceImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml
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?view=diff&rev=548566&r1=548565&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/pom.xml Mon Jun 18 19:55:39 2007
@@ -35,5 +35,22 @@
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNamespaceImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNamespaceImpl.java?view=diff&rev=548566&r1=548565&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNamespaceImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/OMNamespaceImpl.java Mon Jun 18 19:55:39 2007
@@ -83,4 +83,8 @@
public String getNamespaceURI() {
return uri;
}
+
+ public int hashCode() {
+ return uri.hashCode() ^ (prefix != null ? prefix.hashCode() : 0);
+ }
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/NamespaceImplTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/NamespaceImplTestCase.java?view=auto&rev=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/NamespaceImplTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/test/java/org/apache/axiom/om/impl/NamespaceImplTestCase.java Mon Jun 18 19:55:39 2007
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.impl;
+
+public final class NamespaceImplTestCase extends junit.framework.TestCase {
+ public void testEqualsHashCodeContract() {
+ assertEquals(
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"),
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"));
+
+ assertEquals(
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix").hashCode(),
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix").hashCode());
+ }
+}
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?view=diff&rev=548566&r1=548565&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/pom.xml Mon Jun 18 19:55:39 2007
@@ -44,6 +44,7 @@
<configuration>
<includes>
<include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
</includes>
</configuration>
</plugin>
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceImpl.java?view=diff&rev=548566&r1=548565&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NamespaceImpl.java Mon Jun 18 19:55:39 2007
@@ -77,4 +77,8 @@
public String getNamespaceURI() {
return this.nsUri;
}
+
+ public int hashCode() {
+ return nsUri.hashCode() ^ (nsPrefix != null ? nsPrefix.hashCode() : 0);
+ }
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceImplTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceImplTestCase.java?view=auto&rev=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceImplTestCase.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceImplTestCase.java Mon Jun 18 19:55:39 2007
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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
+ *
+ * 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.impl.dom;
+
+public final class NamespaceImplTestCase extends junit.framework.TestCase {
+ public void testEqualsHashCodeContract() {
+ assertEquals(
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI"),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI"));
+
+
+ assertEquals(
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"));
+
+
+ assertEquals(
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"),
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"));
+
+
+ assertEquals(
+ new org.apache.axiom.om.impl.OMNamespaceImpl("anyURI", "prefix"),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix"));
+
+
+ assertEquals(
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI").hashCode(),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI").hashCode());
+
+
+ assertEquals(
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix").hashCode(),
+ new org.apache.axiom.om.impl.dom.NamespaceImpl("anyURI", "prefix").hashCode());
+ }
+}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceTest.java?view=diff&rev=548566&r1=548162&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/NamespaceTest.java Mon Jun 18 19:55:39 2007
@@ -41,7 +41,7 @@
ns1 = new NamespaceImpl(URI1);
ns2 = new NamespaceImpl("http://testuri1");
URI2 = URI2 + "testuri1"; // Make sure the strings don't intern to the same place
- assertTrue(ns1.equals(URI2, ""));
+ assertTrue(ns1.equals(URI2, null));
assertTrue(ns1.equals(ns2));
}
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?view=diff&rev=548566&r1=548565&r2=548566
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-tests/pom.xml Mon Jun 18 19:55:39 2007
@@ -72,6 +72,7 @@
<configuration>
<includes>
<include>**/*Test.java</include>
+ <include>**/*TestCase.java</include>
</includes>
<excludes>
<exclude>**/*AbstractOMSerializationTest.java</exclude>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org