1 19 20 package org.netbeans.core.registry.instanceconv; 21 22 import junit.textui.TestRunner; 23 import org.netbeans.api.registry.Context; 24 import org.netbeans.api.registry.fs.FileSystemContextFactory; 25 import org.netbeans.core.registry.TestMFS; 26 import org.netbeans.junit.NbTestCase; 27 import org.netbeans.junit.NbTestSuite; 28 import org.netbeans.spi.registry.BasicContext; 29 import org.netbeans.spi.registry.SpiUtils; 30 import org.openide.filesystems.FileSystem; 31 import org.openide.filesystems.LocalFileSystem; 32 import org.openide.filesystems.XMLFileSystem; 33 import org.openide.modules.ModuleInfo; 34 import org.openide.util.Lookup; 35 36 import java.net.URL ; 37 38 42 public class InstanceConvertorTest extends NbTestCase { 43 44 public InstanceConvertorTest(String name) { 45 super (name); 46 } 47 48 public static void main(String [] args) { 49 TestRunner.run(new NbTestSuite(InstanceConvertorTest.class)); 50 } 51 52 protected void setUp () throws Exception { 53 Lookup.getDefault().lookup(ModuleInfo.class); 54 } 55 56 public void testConvertor() throws Exception { 57 LocalFileSystem lfs = new LocalFileSystem(); 58 lfs.setRootDirectory(getWorkDir()); 59 60 URL u1 = getClass().getResource("data/layer.xml"); 61 62 FileSystem xfs1 = new XMLFileSystem( u1 ); 63 FileSystem mfs = new TestMFS( new FileSystem[] { lfs, xfs1 } ); 64 65 BasicContext rootCtx = FileSystemContextFactory.createContext(mfs.getRoot()); 66 Context ctx = SpiUtils.createContext(rootCtx).getSubcontext("folder3"); 67 68 CD c = (CD)ctx.getObject("org-netbeans-core-registry-instanceconv-CD", null); 69 assertNotNull(c); 70 assertEquals(c, new CD()); 71 72 c = (CD)ctx.getObject("cd2", null); 73 assertNotNull(c); 74 assertEquals(c, new CD()); 75 76 c = (CD)ctx.getObject("cd3", null); 77 assertNotNull(c); 78 assertEquals(c, CD.createDefault()); 79 80 c = (CD)ctx.getObject("cd4", null); 81 assertNotNull(c); 82 assertEquals(c, new CD("The Hafler Trio", "Cleave: 9 Great Openings")); 83 84 } 85 86 } 87 | Popular Tags |