001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * If you wish your version of this file to be governed by only the CDDL
025: * or only the GPL Version 2, indicate your decision by adding
026: * "[Contributor] elects to include this software in this distribution
027: * under the [CDDL or GPL Version 2] license." If you do not indicate a
028: * single choice of license, a recipient has the option to distribute
029: * your version of this file under either the CDDL, the GPL Version 2 or
030: * to extend the choice of license to its licensees as provided above.
031: * However, if you add GPL Version 2 code and therefore, elected the GPL
032: * Version 2 license, then the option applies only if the new code is
033: * made subject to such option by the copyright holder.
034: *
035: * Contributor(s):
036: *
037: * Portions Copyrighted 2007 Sun Microsystems, Inc.
038: */
039:
040: package org.netbeans.modules.project.ui;
041:
042: import java.io.IOException;
043: import java.util.Collections;
044: import java.util.Iterator;
045: import java.util.concurrent.CountDownLatch;
046: import java.util.logging.Level;
047: import org.netbeans.api.project.Project;
048: import org.netbeans.junit.Log;
049: import org.netbeans.junit.MockServices;
050: import org.netbeans.junit.NbTestCase;
051: import org.netbeans.modules.project.ui.actions.TestSupport;
052: import org.netbeans.modules.project.ui.actions.TestSupport.TestProject;
053: import org.netbeans.spi.project.ProjectFactory;
054: import org.netbeans.spi.project.ProjectState;
055: import org.netbeans.spi.project.ui.LogicalViewProvider;
056: import org.openide.filesystems.FileObject;
057: import org.openide.loaders.DataObject;
058: import org.openide.nodes.AbstractNode;
059: import org.openide.nodes.Children;
060: import org.openide.nodes.Node;
061: import org.openide.util.Lookup;
062: import org.openide.util.lookup.Lookups;
063: import org.openide.util.lookup.ProxyLookup;
064: import org.openidex.search.SearchInfo;
065:
066: /**
067: *
068: * @author Jaroslav Tulach <jtulach@netbeans.org>
069: */
070: public class ProjectsRootNodePreferredOpen2Test extends
071: ProjectsRootNodePreferredOpenTest {
072: private CharSequence log;
073:
074: public ProjectsRootNodePreferredOpen2Test(String testName) {
075: super (testName);
076: }
077:
078: @Override
079: Lookup createLookup(TestProject project, Object instance) {
080: return Lookups.fixed(instance, new MyTestProjectAdditions(
081: project));
082: }
083:
084: @Override
085: protected void setUp() throws Exception {
086: super .setUp();
087: log = Log.enable("", Level.WARNING);
088: }
089:
090: @Override
091: protected void tearDown() throws Exception {
092: super .tearDown();
093:
094: if (log.length() > 0) {
095: fail("No warnings printed to log:\n" + log);
096: }
097: }
098:
099: private static final class MyTestProjectAdditions implements
100: SearchInfo, LogicalViewProvider {
101: private TestProject project;
102:
103: public MyTestProjectAdditions(TestProject project) {
104: this .project = project;
105: }
106:
107: public boolean canSearch() {
108: return false;
109: }
110:
111: public Iterator<DataObject> objectsToSearch() {
112: return Collections.<DataObject> emptyList().iterator();
113: }
114:
115: public Node createLogicalView() {
116: return new AbstractNode(Children.LEAF, Lookups
117: .singleton(project));
118: }
119:
120: public Node findPath(Node root, Object target) {
121: return null;
122: }
123: }
124: }
|