KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > api > CustomWebServicesClientSupportProviderTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.api;
21
22 import java.io.File JavaDoc;
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 /**
34  *
35  * @author Lukas Jungmann
36  */

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     /** Creates a new instance of CustomWebServicesSupportProviderTest */
50     public CustomWebServicesClientSupportProviderTest(String JavaDoc name) {
51         super(name);
52     }
53     
54     protected void setUp() throws Exception JavaDoc {
55         super.setUp();
56         File JavaDoc 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 JavaDoc {
74         super.tearDown();
75         ws.delete();
76         jaxws.delete();
77         nows.delete();
78         both.delete();
79     }
80     
81     public void testProviders() throws Exception JavaDoc {
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 JavaDoc {
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