openide.util/test/unit/src/org/openide/util/lookup/SimpleProxyLookupTest.java
author Jesse Glick <jglick@netbeans.org>
Fri, 09 Oct 2009 15:11:13 -0400
changeset 833 0e00857c5827
parent 829 3b2ed3e1f01b
permissions -rw-r--r--
Warnings.
jtulach@99
     1
/*
jtulach@302
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jtulach@99
     3
 *
mzlamal@829
     4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
jtulach@99
     5
 *
jtulach@302
     6
 * The contents of this file are subject to the terms of either the GNU
jtulach@302
     7
 * General Public License Version 2 only ("GPL") or the Common
jtulach@302
     8
 * Development and Distribution License("CDDL") (collectively, the
jtulach@302
     9
 * "License"). You may not use this file except in compliance with the
jtulach@302
    10
 * License. You can obtain a copy of the License at
jtulach@302
    11
 * http://www.netbeans.org/cddl-gplv2.html
jtulach@302
    12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jtulach@302
    13
 * specific language governing permissions and limitations under the
jtulach@302
    14
 * License.  When distributing the software, include this License Header
jtulach@302
    15
 * Notice in each file and include the License file at
jtulach@302
    16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
jtulach@302
    17
 * particular file as subject to the "Classpath" exception as provided
jtulach@302
    18
 * by Sun in the GPL Version 2 section of the License file that
jtulach@302
    19
 * accompanied this code. If applicable, add the following below the
jtulach@302
    20
 * License Header, with the fields enclosed by brackets [] replaced by
jtulach@302
    21
 * your own identifying information:
jtulach@189
    22
 * "Portions Copyrighted [year] [name of copyright owner]"
jtulach@189
    23
 *
jtulach@302
    24
 * Contributor(s):
jtulach@302
    25
 *
jtulach@189
    26
 * The Original Software is NetBeans. The Initial Developer of the Original
jtulach@189
    27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
jtulach@99
    28
 * Microsystems, Inc. All Rights Reserved.
jtulach@302
    29
 *
jtulach@302
    30
 * If you wish your version of this file to be governed by only the CDDL
jtulach@302
    31
 * or only the GPL Version 2, indicate your decision by adding
jtulach@302
    32
 * "[Contributor] elects to include this software in this distribution
jtulach@302
    33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
jtulach@302
    34
 * single choice of license, a recipient has the option to distribute
jtulach@302
    35
 * your version of this file under either the CDDL, the GPL Version 2 or
jtulach@302
    36
 * to extend the choice of license to its licensees as provided above.
jtulach@302
    37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
jtulach@302
    38
 * Version 2 license, then the option applies only if the new code is
jtulach@302
    39
 * made subject to such option by the copyright holder.
jtulach@99
    40
 */
jtulach@99
    41
jtulach@99
    42
package org.openide.util.lookup;
jtulach@99
    43
jtulach@99
    44
import java.lang.ref.WeakReference;
jtulach@99
    45
import org.netbeans.junit.NbTestCase;
jtulach@99
    46
import org.openide.util.Lookup;
jtulach@99
    47
import org.openide.util.Lookup.Provider;
jtulach@99
    48
jtulach@99
    49
/**
jtulach@99
    50
 *
jtulach@99
    51
 * @author Jan Lahoda
jtulach@99
    52
 */
jglick@833
    53
@SuppressWarnings("unchecked") // XXX ought to be corrected, just a lot of them
jtulach@99
    54
public class SimpleProxyLookupTest extends NbTestCase {
jtulach@189
    55
jtulach@99
    56
    public SimpleProxyLookupTest(String testName) {
jtulach@99
    57
        super(testName);
jtulach@99
    58
    }
jtulach@99
    59
jtulach@99
    60
    public void test69810() throws Exception {
jtulach@99
    61
        Lookup.Template t = new Lookup.Template(String.class);
jtulach@99
    62
        SimpleProxyLookup spl = new SimpleProxyLookup(new Provider() {
jtulach@99
    63
            public Lookup getLookup() {
jtulach@99
    64
                return Lookups.fixed(new Object[] {"test1", "test2"});
jtulach@99
    65
            }
jtulach@99
    66
        });
jtulach@99
    67
        
jtulach@99
    68
        assertGC("", new WeakReference(spl.lookup(t)));
jtulach@99
    69
        
jtulach@99
    70
        spl.lookup(new Lookup.Template(Object.class)).allInstances();
jtulach@99
    71
    }
jtulach@99
    72
    
jtulach@99
    73
}