1 19 20 package org.netbeans.modules.websvc.api; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 import org.netbeans.modules.websvc.api.webservices.WebServicesView; 25 import org.netbeans.modules.websvc.spi.webservices.WebServicesViewProvider; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileUtil; 28 import org.openide.filesystems.LocalFileSystem; 29 import org.openide.filesystems.Repository; 30 import org.openide.util.Lookup; 31 32 36 public class CustomWebServicesViewProviderTest extends NbTestCase { 37 38 private FileObject datadir; 39 private FileObject ws; 40 private FileObject nows; 41 42 static { 43 CustomWebServicesViewProviderTest.class.getClassLoader().setDefaultAssertionStatus(true); 44 } 45 46 47 public CustomWebServicesViewProviderTest(String name) { 48 super(name); 49 } 50 51 protected void setUp() throws Exception { 52 super.setUp(); 53 File f = getWorkDir(); 54 assertTrue("work dir exists", f.exists()); 55 LocalFileSystem lfs = new LocalFileSystem (); 56 lfs.setRootDirectory (f); 57 Repository.getDefault ().addFileSystem (lfs); 58 datadir = FileUtil.toFileObject(f); 59 assertNotNull("no FileObject", datadir); 60 ws = datadir.createData("custom", "ws"); 61 assertNotNull("no ws FileObject", ws); 62 nows = datadir.createData("custom", "nows"); 63 assertNotNull("no ws FileObject", nows); 64 } 65 66 protected void tearDown() throws Exception { 67 super.tearDown(); 68 ws.delete(); 69 nows.delete(); 70 } 71 72 public void testProviders() throws Exception { 73 Lookup.Result res = Lookup.getDefault().lookup(new Lookup.Template(WebServicesViewProvider.class)); 74 assertEquals("there should be 1 instance - from websvc/websvcapi", 1, res.allInstances().size()); 75 } 76 77 public void testGetWebServicesView() { 78 WebServicesView view = WebServicesView.getWebServicesView(ws); 79 assertNotNull("found view support", view); 80 WebServicesView view2 = WebServicesView.getWebServicesView(nows); 81 assertNull("no found view support", view2); 82 } 83 84 } 85 | Popular Tags |