KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > TigerSubstitutesTest


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs;
21
22
23 import java.util.Map JavaDoc;
24
25 import junit.framework.TestCase;
26
27 /**
28  * @author pugh
29  */

30 public class TigerSubstitutesTest extends TestCase {
31     static class Foo {};
32     static Object JavaDoc bar;
33     static Object JavaDoc test = new Object JavaDoc() {
34         class Bar { };
35         {
36             bar = new Bar();
37         }
38         public String JavaDoc toString() {
39             return new Bar().toString();
40         }
41     };
42
43     public void testGetSimpleName() {
44     main(new String JavaDoc[0]);
45         check("a");
46         check(new int[1]);
47         check(new Object JavaDoc[1]);
48         check(new String JavaDoc[1]);
49         check(new Foo[1]);
50         check(Void.TYPE);
51         check(Integer.TYPE);
52         check(Foo.class);
53         check(Map.Entry JavaDoc.class);
54         // check(test);
55
check(bar);
56     }
57     public void check(Object JavaDoc o) {
58         check(o.getClass());
59     }
60     public void check(Class JavaDoc c) {
61     String JavaDoc sn = c.getSimpleName();
62     String JavaDoc ts = TigerSubstitutes.getSimpleName(c);
63     System.out.println( sn + " " + ts);
64         assertEquals(sn, ts);
65     }
66     
67     public static void main(String JavaDoc args[]) {
68         Class JavaDoc 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