Source Code Cross Referenced for WebServiceManagerTest.java in  » IDE-Netbeans » web.core » org » netbeans » modules » websvc » manager » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » web.core » org.netbeans.modules.websvc.manager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         * 
024:         * Contributor(s):
025:         * 
026:         * Portions Copyrighted 2007 Sun Microsystems, Inc.
027:         */
028:
029:        package org.netbeans.modules.websvc.manager;
030:
031:        import java.io.File;
032:        import java.net.URL;
033:        import org.netbeans.junit.NbTestCase;
034:        import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModel;
035:        import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModeler;
036:        import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModelerFactory;
037:        import org.netbeans.modules.websvc.manager.model.WebServiceData;
038:        import org.netbeans.modules.websvc.manager.model.WebServiceGroup;
039:        import org.netbeans.modules.websvc.manager.model.WebServiceListModel;
040:        import org.netbeans.modules.websvc.manager.test.DialogDisplayerNotifier;
041:        import org.netbeans.modules.websvc.manager.test.SetupData;
042:        import org.netbeans.modules.websvc.manager.test.SetupUtil;
043:        import org.openide.DialogDisplayer;
044:
045:        /**
046:         *
047:         * @author quynguyen
048:         */
049:        public class WebServiceManagerTest extends NbTestCase {
050:            private static final String TEST_WSDL_REMOTE = "http://www.webservicemart.com/uszip.asmx.wsdl";
051:
052:            private SetupData testData;
053:
054:            public WebServiceManagerTest(String testName) {
055:                super (testName);
056:            }
057:
058:            @Override
059:            protected void setUp() throws Exception {
060:                super .setUp();
061:                clearWorkDir();
062:                File testRoot = getWorkDir();
063:
064:                testData = SetupUtil.commonSetUp(testRoot);
065:
066:                assertTrue("Could not set up user directory for test", testData
067:                        .getWebsvcHome().exists());
068:                assertTrue("WSDL copy failed", testData.getLocalWsdlFile()
069:                        .exists());
070:                assertTrue("Catalog copy failed", testData
071:                        .getLocalCatalogFile().exists());
072:
073:                File endorsedDir = null;
074:                String endorsedDirs = System.getProperty("java.endorsed.dirs");
075:                if (endorsedDirs != null) {
076:                    endorsedDir = new File(endorsedDirs);
077:                }
078:
079:                DialogDisplayer dd = DialogDisplayer.getDefault();
080:                assertTrue("DialogDisplayer not set correctly",
081:                        dd instanceof  DialogDisplayerNotifier);
082:                assertTrue(
083:                        "java.endorsed.dirs needs to be set to a valid location",
084:                        endorsedDir != null && endorsedDir.exists());
085:            }
086:
087:            @Override
088:            protected void tearDown() throws Exception {
089:                super .tearDown();
090:
091:                SetupUtil.commonTearDown();
092:            }
093:
094:            public void testLocalWebServiceData() throws Exception {
095:                System.out.println("localWebServiceAdd");
096:                WebServiceListModel listModel = WebServiceListModel
097:                        .getInstance();
098:
099:                URL wsdlUrl = testData.getLocalOriginalWsdl().toURI().toURL();
100:
101:                WebServiceData wsData = createWebServiceData(testData
102:                        .getLocalWsdlFile(), wsdlUrl.toExternalForm(),
103:                        "websvc", testData.getLocalCatalogFile(),
104:                        WebServiceListModel.DEFAULT_GROUP);
105:
106:                WebServiceGroup defaultGroup = listModel
107:                        .getWebServiceGroup(WebServiceListModel.DEFAULT_GROUP);
108:
109:                assertEquals(
110:                        "WebServiceData stored in WebServiceListModel not retrieved",
111:                        wsData, listModel.getWebService(wsData.getId()));
112:                assertTrue("WebServiceGroup does not link to WebServiceData",
113:                        defaultGroup.getWebServiceIds()
114:                                .contains(wsData.getId()));
115:
116:                WebServiceManager.getInstance().removeWebService(wsData);
117:                assertFalse("WSDL not deleted as expected", testData
118:                        .getLocalWsdlFile().exists());
119:                assertFalse("Catalog file not deleted as expected", testData
120:                        .getLocalCatalogFile().exists()
121:                        || testData.getLocalCatalogFile().getParentFile()
122:                                .exists());
123:                assertNull("WebServiceData not removed from list model",
124:                        listModel.getWebService(wsData.getId()));
125:                assertTrue("Original WSDL deleted improperly", testData
126:                        .getLocalOriginalWsdl().exists());
127:            }
128:
129:            public void testRemoteWebServiceData() throws Exception {
130:                System.out.println("remoteWebServiceAdd");
131:                WebServiceListModel listModel = WebServiceListModel
132:                        .getInstance();
133:
134:                WebServiceData wsData = createWebServiceData(testData
135:                        .getLocalWsdlFile(), TEST_WSDL_REMOTE, "websvc",
136:                        testData.getLocalCatalogFile(),
137:                        WebServiceListModel.DEFAULT_GROUP);
138:
139:                WebServiceGroup defaultGroup = listModel
140:                        .getWebServiceGroup(WebServiceListModel.DEFAULT_GROUP);
141:
142:                assertEquals(
143:                        "WebServiceData stored in WebServiceListModel not retrieved",
144:                        wsData, listModel.getWebService(wsData.getId()));
145:                assertTrue("WebServiceGroup does not link to WebServiceData",
146:                        defaultGroup.getWebServiceIds()
147:                                .contains(wsData.getId()));
148:
149:                WebServiceManager.getInstance().removeWebService(wsData);
150:                assertFalse("WSDL not deleted as expected", testData
151:                        .getLocalWsdlFile().exists());
152:                assertFalse("Catalog file not deleted as expected", testData
153:                        .getLocalCatalogFile().exists()
154:                        || testData.getLocalCatalogFile().getParentFile()
155:                                .exists());
156:                assertNull("WebServiceData not removed from list model",
157:                        listModel.getWebService(wsData.getId()));
158:            }
159:
160:            public WebServiceData createWebServiceData(File wsdlFile,
161:                    String original, String packageName, File catalog,
162:                    String groupId) throws Exception {
163:                WebServiceData wsData = new WebServiceData(wsdlFile
164:                        .getAbsolutePath(), original, groupId);
165:
166:                wsData.setPackageName(packageName);
167:                wsData.setCatalog(catalog.getAbsolutePath());
168:
169:                WebServiceManager.getInstance().addWebService(wsData, false);
170:
171:                assertTrue("WebServiceData state not correct", wsData
172:                        .getState().equals(WebServiceData.State.WSDL_RETRIEVED));
173:                return wsData;
174:            }
175:
176:            /**
177:             * Test of addWebService method, of class WebServiceManager.
178:             */
179:            /*
180:            public void testAddWebService() throws Exception {
181:                System.out.println("addWebService");
182:
183:                File localWsdlFile = testData.getLocalWsdlFile();
184:                File localOriginalWsdl = testData.getLocalOriginalWsdl();
185:                
186:                String packageName = "websvc";
187:                String groupId = WebServiceListModel.DEFAULT_GROUP;
188:                URL wsdlUrl = localWsdlFile.toURI().toURL();
189:                String originalWsdl = localOriginalWsdl.toURI().toURL().toExternalForm();
190:                
191:                DialogDisplayerNotifier dd = (DialogDisplayerNotifier)DialogDisplayer.getDefault();
192:                
193:                // Objects used for multi-thread success/failure notification
194:                final TestFlag failBeforeCompile = new TestFlag();
195:                final TestFlag failAfterAdd = new TestFlag();
196:                final TestFlag successAfterCompile = new TestFlag();
197:                
198:                dd.addListener(new WebServiceManagerListener() {
199:                    public void eventFired(WebServiceManagerEvent event) {
200:                        failBeforeCompile.setValue(true);
201:                        failBeforeCompile.msg = event.getData();
202:                    }
203:                });
204:                
205:                WebServiceListModel.getInstance().addDefaultGroupListener(new WebServiceGroupListener() {
206:
207:                    public void webServiceAdded(WebServiceGroupEvent groupEvent) {
208:                        WebServiceData wsData = WebServiceListModel.getInstance().getWebService(groupEvent.getWebServiceId());
209:                        wsData.addWebServiceDataListener(new WebServiceDataListener() {
210:                            public void webServiceCompiled(WebServiceDataEvent evt) {
211:                                successAfterCompile.setValue(true);
212:                            }
213:                        });
214:                    }
215:
216:                    public void webServiceRemoved(WebServiceGroupEvent groupEvent) {
217:                        failAfterAdd.setValue(true);
218:                    }
219:                });
220:                
221:                File localCatalogFile = testData.getLocalCatalogFile();
222:                final int TIMEOUT = 30000;
223:                
224:                WsdlModelListenerImpl listener = new WsdlModelListenerImpl(localWsdlFile, originalWsdl, packageName, groupId, localCatalogFile);
225:                WsdlModeler wsdlModeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlUrl);
226:                listener.setWsdlModeler(wsdlModeler);
227:                wsdlModeler.setPackageName(packageName);
228:                wsdlModeler.generateWsdlModel(listener);
229:                
230:                // hack to wait until the processes are done
231:                int counter = 0;
232:                do {
233:                    counter += 1000;
234:                    Thread.sleep(1000);
235:                }while ( ! (failBeforeCompile.getValue() || failAfterAdd.getValue() || successAfterCompile.getValue()) &&
236:                         counter < TIMEOUT);
237:                
238:                assertFalse("Failure notified with the following message: " + failBeforeCompile.msg, failBeforeCompile.getValue());
239:                assertFalse("Failed during client creation", failAfterAdd.getValue());
240:                assertTrue("Test timed out after " + counter + "ms", counter < TIMEOUT);
241:            }
242:             
243:            private static final class TestFlag {
244:                private boolean value = false;
245:                private String msg = "";
246:                
247:                public void setValue(boolean v) {
248:                    this.value = v;
249:                }
250:                
251:                public boolean getValue() {
252:                    return value;
253:                }
254:            }
255:             */
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.