1 19 20 package org.netbeans.core.registry.serialdataconv; 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 SerialDataConvertorTest extends NbTestCase { 43 44 public SerialDataConvertorTest(String name) { 45 super (name); 46 } 47 48 public static void main(String [] args) { 49 TestRunner.run(new NbTestSuite(SerialDataConvertorTest.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("folder2"); 67 68 SerializableCD c = (SerializableCD)ctx.getObject("cd1", null); 69 assertNotNull(c); 70 assertEquals(c, new SerializableCD("Giya Kancheli", "Mourned by the Wind")); 71 72 c = (SerializableCD)ctx.getObject("cd2", null); 73 assertNotNull(c); 74 assertEquals(c, new SerializableCD()); 75 76 c = (SerializableCD)ctx.getObject("cd3", null); 77 assertNotNull(c); 78 assertEquals(c, new SerializableCD("V.A.", "Radio Kiss100 Mixes")); 79 80 SerializableCD cd = new SerializableCD("Arvo Part", "Kanon Pokajanen"); 81 SerializableCD cd2 = new SerializableCD("Arvo Part", "Kanon Pokajanen"); 82 83 ctx.putObject("newcd", cd); 84 assertEquals(ctx.getObject("newcd", null), cd2); 85 cd = null; 86 System.gc();System.gc();System.gc();System.gc();System.gc(); 87 assertEquals(ctx.getObject("newcd", null), cd2); 88 89 } 90 91 } 92 | Popular Tags |