public void testSelfReferenceHandling() { Map.Entry entry = makeMapEntry(); try { entry.setValue(entry); assertSame(entry, entry.getValue()); } catch (Exception e) { fail("This Map.Entry implementation supports value self-reference."); } }
/** * Subclasses should override this method. * */ public void testConstructors() { // 1. test key-value constructor Map.Entry entry = new DefaultMapEntry(key, value); assertSame(key, entry.getKey()); assertSame(value, entry.getValue()); // 2. test pair constructor KeyValue pair = new DefaultKeyValue(key, value); assertSame(key, pair.getKey()); assertSame(value, pair.getValue()); // 3. test copy constructor Map.Entry entry2 = new DefaultMapEntry(entry); assertSame(key, entry2.getKey()); assertSame(value, entry2.getValue()); // test that the objects are independent entry.setValue(null); assertSame(value, entry2.getValue()); }
public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(TestDefaultKeyValue.suite()); suite.addTest(TestDefaultMapEntry.suite()); suite.addTest(TestMultiKey.suite()); suite.addTest(TestTiedMapEntry.suite()); suite.addTest(TestUnmodifiableMapEntry.suite()); return suite; }