mirror of https://github.com/apache/lucene.git
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:
parent
49ab81b316
commit
2714ba90ca
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue