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.WebServicesSupport; 25 import org.netbeans.modules.websvc.spi.webservices.WebServicesSupportProvider; 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 CustomWebServicesSupportProviderTest extends NbTestCase { 37 38 private FileObject datadir; 39 private FileObject ws; 40 private FileObject nows; 41 42 static { 43 CustomWebServicesSupportProviderTest.class.getClassLoader().setDefaultAssertionStatus(true); 44 } 45 46 47 public CustomWebServicesSupportProviderTest(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(WebServicesSupportProvider.class)); 74 assertEquals("there should be 2 instances - one from websvc/websvcapi and one from tests", 2, res.allInstances ().size ()); 75 } 76 77 public void testGetWebServicesSupport() throws Exception { 78 WebServicesSupport ws1 = WebServicesSupport.getWebServicesSupport(ws); 79 assertNotNull("found ws support", ws1); 80 WebServicesSupport ws2 = WebServicesSupport.getWebServicesSupport(nows); 81 assertNull("not found ws support", ws2); 82 } 83 } 84 | Popular Tags |