lookup/src/test/java/org/openide/util/lookup/ProxyLookup173975Test.java
changeset 972 a2947558c966
parent 971 b3ae88304dd0
child 973 5653a70ebb56
     1.1 --- a/lookup/src/test/java/org/openide/util/lookup/ProxyLookup173975Test.java	Wed Jan 27 17:46:23 2010 -0500
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,108 +0,0 @@
     1.4 -/*
     1.5 - * To change this template, choose Tools | Templates
     1.6 - * and open the template in the editor.
     1.7 - */
     1.8 -package org.openide.util.lookup;
     1.9 -
    1.10 -import java.util.Collection;
    1.11 -import java.util.Collections;
    1.12 -import org.junit.Assert;
    1.13 -import org.junit.Test;
    1.14 -import org.openide.util.Lookup;
    1.15 -import org.openide.util.LookupEvent;
    1.16 -import org.openide.util.LookupListener;
    1.17 -import org.openide.util.lookup.AbstractLookup.Storage;
    1.18 -
    1.19 -public class ProxyLookup173975Test {
    1.20 -
    1.21 -    public ProxyLookup173975Test() {
    1.22 -    }
    1.23 -
    1.24 -    boolean called = false;
    1.25 -
    1.26 -    @Test
    1.27 -    public void testAbstractLookupWithoutAllInstances() {
    1.28 -        registerLookupListenerAndAddSomething(false, false, false);
    1.29 -    }
    1.30 -
    1.31 -    @Test
    1.32 -    public void testAbstractLookupWithAllInstances() {
    1.33 -        registerLookupListenerAndAddSomething(false, true, false);
    1.34 -    }
    1.35 -
    1.36 -    @Test
    1.37 -    public void testAbstractLookupInheritanceTreeWithoutAllInstances() {
    1.38 -        registerLookupListenerAndAddSomething(false, false, true);
    1.39 -    }
    1.40 -
    1.41 -    @Test
    1.42 -    public void testAbstractLookupInheritanceTreeWithAllInstances() {
    1.43 -        registerLookupListenerAndAddSomething(false, true, true);
    1.44 -    }
    1.45 -
    1.46 -    @Test
    1.47 -    public void testProxyLookupWithoutAllInstances() {
    1.48 -        registerLookupListenerAndAddSomething(true, false, false);
    1.49 -    }
    1.50 -
    1.51 -    @Test
    1.52 -    public void testProxyLookupWithAllInstances() {
    1.53 -        registerLookupListenerAndAddSomething(true, true, false);
    1.54 -    }
    1.55 -
    1.56 -    @Test
    1.57 -    public void testProxyLookupInheritanceTreeWithoutAllInstances() {
    1.58 -        registerLookupListenerAndAddSomething(true, false, true);
    1.59 -    }
    1.60 -
    1.61 -    @Test
    1.62 -    public void testProxyLookupInheritanceTreeWithAllInstances() {
    1.63 -        registerLookupListenerAndAddSomething(true, true, true);
    1.64 -    }
    1.65 -
    1.66 -    private void registerLookupListenerAndAddSomething(boolean useProxy, boolean callAllInstances, boolean inheritanceTree) {
    1.67 -        called = false;
    1.68 -        InstanceContent aInstanceContent = new InstanceContent();
    1.69 -        Storage<?> s = inheritanceTree ? new InheritanceTree() : new ArrayStorage();
    1.70 -        Lookup aLookup = new AbstractLookup(aInstanceContent, s);
    1.71 -        if (useProxy) {
    1.72 -            aLookup = new ProxyLookup(aLookup);
    1.73 -        }
    1.74 -        Lookup.Result<ObjectInLookup> result = aLookup.lookupResult(ObjectInLookup.class);
    1.75 -        if (callAllInstances) {
    1.76 -            result.allInstances(); // TO GET SUCCESS
    1.77 -        }
    1.78 -        result.addLookupListener(new LookupListener() {
    1.79 -
    1.80 -            public void resultChanged(LookupEvent ev) {
    1.81 -                Lookup.Result aResult = (Lookup.Result) ev.getSource();
    1.82 -                Collection c = aResult.allInstances();
    1.83 -                if (!c.isEmpty()) {
    1.84 -                    called = true;
    1.85 -                }
    1.86 -            }
    1.87 -        });
    1.88 -
    1.89 -        aInstanceContent.set(Collections.singleton(
    1.90 -                new ObjectInLookup("Set Object in Lookup)")), null);
    1.91 -        Assert.assertTrue("Listener was notified", called);
    1.92 -    }
    1.93 -
    1.94 -    public class ObjectInLookup {
    1.95 -
    1.96 -        private final String name;
    1.97 -
    1.98 -        public ObjectInLookup(String name) {
    1.99 -            this.name = name;
   1.100 -        }
   1.101 -
   1.102 -        public String getName() {
   1.103 -            return this.name;
   1.104 -        }
   1.105 -
   1.106 -        @Override
   1.107 -        public String toString() {
   1.108 -            return "objectinlookup:" + getName();
   1.109 -        }
   1.110 -    }
   1.111 -}