KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > FunctionalTest


1 /**
2  * This is a place where people put copyright headers - these need to be preserved
3  */

4 import java.awt.Component JavaDoc;
5 import java.io.File JavaDoc;
6 import java.io.*;
7 import java.io.IOException JavaDoc;
8 import java.lang.reflect.Modifier JavaDoc;
9 import java.net.*;
10 import java.net.URL JavaDoc;
11 import java.net.URLConnection JavaDoc;
12 import java.util.*;
13 import java.util.Map.Entry;
14 import javax.swing.JLabel JavaDoc;
15 import javax.swing.JTextField JavaDoc;
16
17 /**
18  * This class encapsulates an piece of code on which to run importscrubber
19  */

20 public class FunctionalTest implements Runnable JavaDoc {
21
22    public static class Bar extends JTextField JavaDoc {
23       private static final FilePermission BIF = new FilePermission("/etc/passwd", "foo");
24       private static final FilePermission BIF2 = new FilePermission("Hello world", "bar");
25    }
26
27
28
29    public class Foo extends JLabel JavaDoc {
30       public String JavaDoc getText() {
31          return super.getText();
32       }
33    }
34
35    private static final ArrayList[] STATIC_FOO = new ArrayList[0];
36    private HashSet set = new HashSet();
37
38    public FunctionalTest() throws IOException JavaDoc {
39       Vector v = new Vector();
40       for (Enumeration e = v.elements(); e.hasMoreElements();) { }
41       IOException JavaDoc e = new IOException JavaDoc();
42
43       // this is to test excluding literals
44
String JavaDoc buz = "text/plain";
45
46       // this is to test array handling
47
ArrayList[] foo = new ArrayList[0];
48       ArrayList bar = new ArrayList();
49       bar.add(HashSet.class);
50       bar.add(Integer JavaDoc.class);
51       File JavaDoc[] files = (File JavaDoc[])bar.toArray(new File JavaDoc[0]);
52
53       // this is to test imports of inner classes
54
HashMap biv = new HashMap();
55       Set set = biv.entrySet();
56       Iterator iter = set.iterator();
57       bar.add((Entry)iter.next());
58
59
60
61       // this is to test inclusion of classes from java.lang.reflect
62
Modifier JavaDoc m = new Modifier JavaDoc();
63
64
65       // This next one can't be picked up by importscrubber because the compiler inlines it
66
// System.out.println("A JOptionPane thingy " + JOptionPane.CANCEL_OPTION);
67
// bummer!
68

69       // this is to test importing a class and only calling a static method on it
70
//Buz.doSomething();
71

72       // this is to test NOT importing classes which are fully qualified in the class body
73
//java.sql.Date sqlDate = new java.sql.Date(20);
74
//Date javaDate = new Date();
75

76       throw new IllegalArgumentException JavaDoc();
77    }
78
79    // this is to test method argument/return value types
80
public SocketOptions bar(URL JavaDoc aURL, URLConnection JavaDoc aConn) {
81       return null;
82    }
83
84    public Component JavaDoc getComp() {
85       return null;
86    }
87
88    public void run() {}
89 }
90
91
Popular Tags