1 19 20 package edu.umd.cs.findbugs; 21 22 23 import java.util.Map ; 24 25 import junit.framework.TestCase; 26 27 30 public class TigerSubstitutesTest extends TestCase { 31 static class Foo {}; 32 static Object bar; 33 static Object test = new Object () { 34 class Bar { }; 35 { 36 bar = new Bar(); 37 } 38 public String toString() { 39 return new Bar().toString(); 40 } 41 }; 42 43 public void testGetSimpleName() { 44 main(new String [0]); 45 check("a"); 46 check(new int[1]); 47 check(new Object [1]); 48 check(new String [1]); 49 check(new Foo[1]); 50 check(Void.TYPE); 51 check(Integer.TYPE); 52 check(Foo.class); 53 check(Map.Entry .class); 54 check(bar); 56 } 57 public void check(Object o) { 58 check(o.getClass()); 59 } 60 public void check(Class c) { 61 String sn = c.getSimpleName(); 62 String ts = TigerSubstitutes.getSimpleName(c); 63 System.out.println( sn + " " + ts); 64 assertEquals(sn, ts); 65 } 66 67 public static void main(String args[]) { 68 Class c = test.getClass(); 69 System.out.println(c.getName()); 70 System.out.println(c.getCanonicalName()); 71 System.out.println(c.getSimpleName()); 72 System.out.println(TigerSubstitutes.getSimpleName(c)); 73 System.out.println(System.getProperty("java.version")); 74 System.out.println(System.getProperty("java.vendor")); 75 76 } 77 78 } 79 | Popular Tags |