1 19 20 package org.openide.util.lookup; 21 22 import org.openide.util.*; 23 24 import java.lang.ref.WeakReference ; 25 import java.util.*; 26 import junit.framework.*; 27 import org.netbeans.junit.*; 28 import java.io.Serializable ; 29 30 public class AbstractLookupArrayStorageTest extends AbstractLookupBaseHid { 31 public AbstractLookupArrayStorageTest(java.lang.String testName) { 32 super(testName, null); 33 } 34 35 public static void main(java.lang.String [] 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 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 (trash))); 101 } 102 } 103 104 105 } 106 } 107 | Popular Tags |