You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2007/03/02 11:35:54 UTC
svn commit: r513695 - in /myfaces/core/branches/jsf12/impl/src:
main/java/org/apache/myfaces/util/AbstractAttributeMap.java
test/java/org/apache/myfaces/util/
test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java
Author: mbr
Date: Fri Mar 2 02:35:53 2007
New Revision: 513695
URL: http://svn.apache.org/viewvc?view=rev&rev=513695
Log:
multiple calls to AbstractAttributeMap.hashCode must return the same value (if not modified)
Added:
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/
myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java (with props)
Modified:
myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/AbstractAttributeMap.java
Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/AbstractAttributeMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/AbstractAttributeMap.java?view=diff&rev=513695&r1=513694&r2=513695
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/AbstractAttributeMap.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/util/AbstractAttributeMap.java Fri Mar 2 02:35:53 2007
@@ -352,5 +352,36 @@
{
return AbstractAttributeMap.this.put(_currentKey, value);
}
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((_currentKey == null) ? 0 : _currentKey.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final EntrySetEntry other = (EntrySetEntry) obj;
+ if (_currentKey == null)
+ {
+ if (other._currentKey != null)
+ return false;
+ }
+ else if (!_currentKey.equals(other._currentKey))
+ return false;
+ return true;
+ }
+
+
}
}
Added: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java?view=auto&rev=513695
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java (added)
+++ myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java Fri Mar 2 02:35:53 2007
@@ -0,0 +1,69 @@
+/*
+ * 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.myfaces.util;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Mathias Broekelmann (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class AbstractAttributeMapTest extends TestCase
+{
+ /**
+ * Test method for {@link java.util.AbstractMap#hashCode()}.
+ */
+ public void testHashCodeEquals()
+ {
+ TestAttributeMap map = new TestAttributeMap();
+ assertEquals(map.hashCode(), map.hashCode());
+ }
+
+ private static final class TestAttributeMap extends AbstractAttributeMap
+ {
+ @Override
+ protected Object getAttribute(String key)
+ {
+ return "value";
+ }
+
+ @Override
+ protected Enumeration getAttributeNames()
+ {
+ return Collections.enumeration(Arrays.asList(new String[] { "attr1", "attr2" }));
+ }
+
+ @Override
+ protected void removeAttribute(String key)
+ {
+ fail();
+ }
+
+ @Override
+ protected void setAttribute(String key, Object value)
+ {
+ fail();
+ }
+ }
+
+}
Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/core/branches/jsf12/impl/src/test/java/org/apache/myfaces/util/AbstractAttributeMapTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL