Exemplo n.º 1
0
 /** Test one string operation using the string cache. */
 void testString() {
   String a = randomString();
   if (returnNew) {
     String b = StringUtils.fromCacheOrNew(a);
     try {
       assertEquals(a, b);
     } catch (Exception e) {
       TestBase.logError("error", e);
     }
     if (a != null && a == b && a.length() > 0) {
       throw new AssertionError(
           "a=" + System.identityHashCode(a) + " b=" + System.identityHashCode(b));
     }
   } else {
     String b;
     if (useIntern) {
       b = a == null ? null : a.intern();
     } else {
       b = StringUtils.cache(a);
     }
     try {
       assertEquals(a, b);
     } catch (Exception e) {
       TestBase.logError("error", e);
     }
   }
 }