1 19 20 package org.netbeans.spi.settings; 21 22 import java.io.*; 23 import org.netbeans.junit.NbTestCase; 24 import org.openide.filesystems.FileObject; 25 import org.openide.filesystems.FileSystem; 26 import org.openide.filesystems.LocalFileSystem; 27 import org.openide.util.Lookup; 28 29 33 public class ConvertorTest extends NbTestCase { 34 35 FileSystem fs; 36 FileObject contextFO; 37 38 39 public ConvertorTest(String name) { 40 super(name); 41 } 42 43 protected void setUp() throws Exception { 44 super.setUp(); 45 clearWorkDir(); 46 File work = getWorkDir(); 47 LocalFileSystem lfs = new LocalFileSystem(); 48 lfs.setRootDirectory(work); 49 contextFO = lfs.getRoot().createData("context", "settings"); 50 fs = lfs; 51 } 52 53 public void testFindWriterContext() throws Exception { 54 Reader r = new java.io.InputStreamReader (contextFO.getInputStream()); 55 Reader cr = org.netbeans.modules.settings.ContextProvider.createReaderContextProvider(r, contextFO); 56 Lookup l = Convertor.findContext(cr); 57 assertNotNull(l); 58 FileObject src = (FileObject) l.lookup(FileObject.class); 59 assertNotNull(src); 60 assertEquals(contextFO.getPath(), src.getPath()); 61 } 62 63 public void testFindReaderContext() throws Exception { 64 org.openide.filesystems.FileLock lock = contextFO.lock(); 65 try { 66 Writer w = new java.io.OutputStreamWriter (contextFO.getOutputStream(lock)); 67 Writer cw = org.netbeans.modules.settings.ContextProvider.createWriterContextProvider(w, contextFO); 68 Lookup l = Convertor.findContext(cw); 69 assertNotNull(l); 70 FileObject src = (FileObject) l.lookup(FileObject.class); 71 assertNotNull(src); 72 assertEquals(contextFO.getPath(), src.getPath()); 73 } finally { 74 lock.releaseLock(); 75 } 76 } 77 78 } 79 | Popular Tags |