1 19 package org.openide.loaders; 20 import javax.swing.SwingUtilities ; 21 import org.netbeans.junit.NbTestCase; 22 import org.openide.filesystems.*; 23 import org.openide.nodes.Node; 24 import org.openide.util.*; 25 import org.openide.util.actions.CallableSystemAction; 26 27 31 public class InstanceNodeTest extends NbTestCase { 32 Node node; 33 34 public InstanceNodeTest (String testName) { 35 super (testName); 36 } 37 38 protected void setUp () throws Exception { 39 FileObject root = Repository.getDefault ().getDefaultFileSystem ().getRoot (); 40 DataObject dobj = InstanceDataObject.create (DataFolder.findFolder (root), null, A.class); 41 node = dobj.getNodeDelegate (); 42 assertTrue ("Is InstanceNode", node instanceof InstanceNode); 43 } 44 45 48 public void testGetDisplayName () throws Exception { 49 Node instance = node; 50 51 String expResult = "Ahoj"; 52 SwingUtilities.invokeAndWait (new Runnable () { 54 public void run () { 55 56 } 57 58 }); 59 String result = instance.getDisplayName(); 60 assertEquals(expResult, result); 61 } 62 63 public static class A extends CallableSystemAction { 64 public void performAction () { 65 } 66 67 public String getName () { 68 assertTrue ("Called from AWT", SwingUtilities.isEventDispatchThread ()); 69 return "Ahoj"; 70 } 71 72 public HelpCtx getHelpCtx () { 73 assertTrue ("Called from AWT", SwingUtilities.isEventDispatchThread ()); 74 return HelpCtx.DEFAULT_HELP; 75 } 76 77 } 78 79 } 80 | Popular Tags |