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.client.WebServicesClientSupport; 25 import org.netbeans.modules.websvc.api.jaxws.client.JAXWSClientSupport; 26 import org.netbeans.modules.websvc.spi.client.WebServicesClientSupportProvider; 27 import org.openide.filesystems.FileObject; 28 import org.openide.filesystems.FileUtil; 29 import org.openide.filesystems.LocalFileSystem; 30 import org.openide.filesystems.Repository; 31 import org.openide.util.Lookup; 32 33 37 public class CustomWebServicesClientSupportProviderTest extends NbTestCase { 38 39 private FileObject datadir; 40 private FileObject nows; 41 private FileObject ws; 42 private FileObject jaxws; 43 private FileObject both; 44 45 static { 46 CustomWebServicesClientSupportProviderTest.class.getClassLoader().setDefaultAssertionStatus(true); 47 } 48 49 50 public CustomWebServicesClientSupportProviderTest(String name) { 51 super(name); 52 } 53 54 protected void setUp() throws Exception { 55 super.setUp(); 56 File f = getWorkDir(); 57 assertTrue("work dir exists", f.exists()); 58 LocalFileSystem lfs = new LocalFileSystem (); 59 lfs.setRootDirectory (f); 60 Repository.getDefault ().addFileSystem (lfs); 61 datadir = FileUtil.toFileObject(f); 62 assertNotNull("no FileObject", datadir); 63 nows = datadir.createData("custom", "nows"); 64 assertNotNull("no ws FileObject", nows); 65 ws = datadir.createData("custom", "ws"); 66 assertNotNull("no ws FileObject", ws); 67 jaxws = datadir.createData("custom", "jaxws"); 68 assertNotNull("no ws FileObject", jaxws); 69 both = datadir.createData("custom", "both"); 70 assertNotNull("no ws FileObject", both); 71 } 72 73 protected void tearDown() throws Exception { 74 super.tearDown(); 75 ws.delete(); 76 jaxws.delete(); 77 nows.delete(); 78 both.delete(); 79 } 80 81 public void testProviders() throws Exception { 82 Lookup.Result res = Lookup.getDefault().lookup(new Lookup.Template(WebServicesClientSupportProvider.class)); 83 assertEquals("there should be 2 instances - one from websvc/clientapi and one from tests", 2, res.allInstances ().size ()); 84 } 85 86 public void testGetWebServicesClientSupport() throws Exception { 87 WebServicesClientSupport ws1 = WebServicesClientSupport.getWebServicesClientSupport(nows); 88 assertNull("not found ws support", ws1); 89 WebServicesClientSupport ws2 = WebServicesClientSupport.getWebServicesClientSupport(ws); 90 assertNotNull("found ws support", ws2); 91 WebServicesClientSupport ws3 = WebServicesClientSupport.getWebServicesClientSupport(jaxws); 92 assertNull("not found ws support", ws3); 93 WebServicesClientSupport ws4= WebServicesClientSupport.getWebServicesClientSupport(both); 94 assertNotNull("found ws support", ws4); 95 96 JAXWSClientSupport jaxws1 = JAXWSClientSupport.getJaxWsClientSupport(nows); 97 assertNull("not found jaxws support", jaxws1); 98 JAXWSClientSupport jaxws2 = JAXWSClientSupport.getJaxWsClientSupport(ws); 99 assertNull("not found jaxws support", jaxws2); 100 JAXWSClientSupport jaxws3 = JAXWSClientSupport.getJaxWsClientSupport(jaxws); 101 assertNotNull("found jaxws support", jaxws3); 102 JAXWSClientSupport jaxws4 = JAXWSClientSupport.getJaxWsClientSupport(both); 103 assertNotNull("found jaxws support", jaxws4); 104 } 105 } 106 | Popular Tags |