1 19 20 package org.netbeans.modules.settings.convertors; 21 22 import org.netbeans.junit.NbTestCase; 23 import org.openide.cookies.InstanceCookie; 24 import org.openide.filesystems.FileObject; 25 import org.openide.filesystems.FileSystem; 26 import org.openide.loaders.DataObject; 27 import org.openide.modules.ModuleInfo; 28 import org.openide.nodes.Node; 29 import org.openide.util.Lookup; 30 31 35 public class SerialDataNodeTest extends NbTestCase { 36 37 private FileSystem sfs; 38 39 40 public SerialDataNodeTest(String name) { 41 super(name); 42 } 43 44 protected void setUp() throws Exception { 45 super.setUp(); 46 Lookup.getDefault().lookup(ModuleInfo.class); 47 sfs = org.openide.filesystems.Repository.getDefault().getDefaultFileSystem(); 48 } 49 50 public void testDisplayName() throws Exception { 51 String res = "Settings/org-netbeans-modules-settings-convertors-testDisplayName.settings"; 52 FileObject fo = sfs.findResource(res); 53 assertNotNull(res, fo); 54 assertNull("name", fo.getAttribute("name")); 55 56 DataObject dobj = DataObject.find (fo); 57 Node n = dobj.getNodeDelegate(); 58 assertNotNull(n); 59 assertEquals("I18N", n.getDisplayName()); 60 61 Object garbage = n.getPropertySets(); 64 65 InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class); 66 assertNotNull (dobj + " does not contain instance cookie", ic); 67 68 FooSetting foo = (FooSetting) ic.instanceCreate(); 69 String newName = "newName"; 70 foo.setName(newName); 71 assertEquals(n.toString(), newName, n.getDisplayName()); 72 73 newName = "newNameViaNode"; 74 n.setName(newName); 75 assertEquals(n.toString(), newName, n.getDisplayName()); 76 assertEquals(n.toString(), newName, foo.getName()); 77 } 78 } 79 | Popular Tags |