/** * Test the same strong reference is returned for any * of string instances that are equal to each other. */ @Test public void testStrongIntern() { String strongInternLiteralABC = strongIntern("ABC"); String strongInternSubstringABC = strongIntern("ABCDE".substring(0,3)); String strongInternHeapABC = strongIntern(new String("ABC")); assertSame(strongInternLiteralABC, strongInternSubstringABC); assertSame(strongInternLiteralABC, strongInternHeapABC); assertSame(strongInternSubstringABC, strongInternHeapABC); }
/** * Test the same strong reference is returned for any * of string instances that are equal to each other. */ @Test public void testStrongIntern() { String strongInternLiteralABC = strongIntern("ABC"); String strongInternSubstringABC = strongIntern("ABCDE".substring(0,3)); String strongInternHeapABC = strongIntern(new String("ABC")); assertSame(strongInternLiteralABC, strongInternSubstringABC); assertSame(strongInternLiteralABC, strongInternHeapABC); assertSame(strongInternSubstringABC, strongInternHeapABC); }