You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2011/04/23 01:03:26 UTC

svn commit: r1096077 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java

Author: uschindler
Date: Fri Apr 22 23:03:26 2011
New Revision: 1096077

URL: http://svn.apache.org/viewvc?rev=1096077&view=rev
Log:
LUCENE-3042: Add a more specific test that can be backported to 3.x and prev

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java?rev=1096077&r1=1096076&r2=1096077&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestAttributeSource.java Fri Apr 22 23:03:26 2011
@@ -147,4 +147,14 @@ public class TestAttributeSource extends
       fail("Should throw IllegalArgumentException");
     } catch (IllegalArgumentException iae) {}
   }
+  
+  public void testLUCENE_3042() throws Exception {
+    final AttributeSource src1 = new AttributeSource();
+    src1.addAttribute(CharTermAttribute.class).append("foo");
+    int hash1 = src1.hashCode(); // this triggers a cached state
+    final AttributeSource src2 = new AttributeSource(src1);
+    src2.addAttribute(TypeAttribute.class).setType("bar");
+    assertTrue("The hashCode is identical, so the captured state was preserved.", hash1 != src1.hashCode());
+    assertEquals(src2.hashCode(), src1.hashCode());
+  }
 }