1 19 20 package org.netbeans.modules.openfile; 21 22 import java.awt.Component ; 23 import java.io.File ; 24 import org.netbeans.api.sendopts.CommandLine; 25 import org.netbeans.junit.MockServices; 26 import org.netbeans.junit.NbTestCase; 27 import org.openide.explorer.ExplorerManager; 28 import org.openide.filesystems.FileObject; 29 import org.openide.filesystems.FileUtil; 30 import org.openide.nodes.Node; 31 import org.openide.nodes.NodeAcceptor; 32 import org.openide.nodes.NodeOperation; 33 import org.openide.util.UserCancelException; 34 import org.openide.windows.TopComponent; 35 import org.openide.windows.WindowManager; 36 37 41 public class OpenCLITest extends NbTestCase { 42 File dir; 43 44 public OpenCLITest(String testName) { 45 super(testName); 46 } 47 48 protected boolean runInEQ() { 49 return true; 50 } 51 52 protected void setUp() throws Exception { 53 dir = new File (getWorkDir(), "tstdir"); 54 dir.mkdirs(); 55 56 MockServices.setServices(MockNodeOperation.class); 57 MockNodeOperation.explored = null; 58 } 59 60 protected void tearDown() throws Exception { 61 } 62 63 public void testOpenFolder() throws Exception { 64 CommandLine.getDefault().process(new String [] { "--open", dir.getPath() }); 65 66 assertNotNull("A node has been explored", MockNodeOperation.explored); 67 68 FileObject root = MockNodeOperation.explored.getLookup().lookup(FileObject.class); 69 assertNotNull("There is a file object in lookup", root); 70 71 assertEquals("It is our dir", dir, FileUtil.toFile(root)); 72 } 73 74 public static final class MockNodeOperation extends NodeOperation { 75 public static Node explored; 76 77 public boolean customize(Node n) { 78 fail("No customize"); 79 return false; 80 } 81 82 public void explore(Node n) { 83 assertNull("No explore before", explored); 84 explored = n; 85 } 86 87 public void showProperties(Node n) { 88 fail("no props"); 89 } 90 91 public void showProperties(Node[] n) { 92 fail("no props"); 93 } 94 95 public Node[] select(String title, String rootTitle, Node root, NodeAcceptor acceptor, Component top) throws UserCancelException { 96 fail("no select"); 97 return null; 98 } 99 100 } 101 } 102 | Popular Tags |