KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > util > lookup > AbstractLookupArrayStorageTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.util.lookup;
21
22 import org.openide.util.*;
23
24 import java.lang.ref.WeakReference JavaDoc;
25 import java.util.*;
26 import junit.framework.*;
27 import org.netbeans.junit.*;
28 import java.io.Serializable JavaDoc;
29
30 public class AbstractLookupArrayStorageTest extends AbstractLookupBaseHid {
31     public AbstractLookupArrayStorageTest(java.lang.String JavaDoc testName) {
32         super(testName, null);
33     }
34
35     public static void main(java.lang.String JavaDoc[] args) {
36         junit.textui.TestRunner.run(suite ());
37     }
38
39     public static TestSuite suite () {
40         NbTestSuite suite = new NbTestSuite ();
41         suite.addTest (new PL (2));
42         suite.addTest (new AL (1));
43         suite.addTest (new AL (-1));
44         suite.addTest (new PL (-1));
45         suite.addTest (new AL (5));
46         suite.addTest (new PL (3));
47         suite.addTest (new AL (2000));
48         suite.addTest (new PL (2000));
49         return suite;
50     }
51
52     public static final class AL extends ArrayTestSuite {
53         public AL (int trash) {
54             super (trash);
55         }
56         
57         public Lookup createLookup (Lookup lookup) {
58             return lookup;
59         }
60         
61         public void clearCaches () {
62         }
63         
64     }
65     
66     public static final class PL extends ArrayTestSuite {
67         public PL (int trash) {
68             super (trash);
69         }
70         
71         public Lookup createLookup (Lookup lookup) {
72             return new ProxyLookup (new Lookup[] { lookup });
73         }
74         
75         public void clearCaches () {
76         }
77         
78     }
79     
80     private static abstract class ArrayTestSuite extends NbTestSuite
81     implements AbstractLookupBaseHid.Impl {
82         private int trash;
83         
84         public ArrayTestSuite (int trash) {
85             super (AbstractLookupArrayStorageTest.class);
86             this.trash = trash;
87             
88             int cnt = this.countTestCases();
89             for (int i = 0; i < cnt; i++) {
90                 Object JavaDoc o = this.testAt (i);
91                 AbstractLookupBaseHid t = (AbstractLookupBaseHid)o;
92                 t.impl = this;
93             }
94         }
95         
96         public Lookup createInstancesLookup (InstanceContent ic) {
97             if (trash == -1) {
98                 return new AbstractLookup (ic, new ArrayStorage ());
99             } else {
100                 return new AbstractLookup (ic, new ArrayStorage (new Integer JavaDoc (trash)));
101             }
102         }
103         
104         
105     }
106 }
107
Popular Tags