LUCENE-3042: Add a more specific test that can be backported to 3.x and prev

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1096077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2011-04-22 23:03:26 +00:00
parent 49ab81b316
commit 2714ba90ca
1 changed files with 10 additions and 0 deletions

View File

@ -147,4 +147,14 @@ public class TestAttributeSource extends LuceneTestCase {
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());
}
}