Source Code Cross Referenced for FTPComponentValidatorTest.java in  » IDE-Netbeans » wsdlextensions.file » org » netbeans » modules » wsdlextensions » ftp » validation » test » 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 » wsdlextensions.file » org.netbeans.modules.wsdlextensions.ftp.validation.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        package org.netbeans.modules.wsdlextensions.ftp.validation.test;
021:
022:        import junit.framework.*;
023:        import java.io.File;
024:        import java.io.FileFilter;
025:        import java.net.URI;
026:        import java.util.HashSet;
027:        import java.util.Iterator;
028:        import java.util.ResourceBundle;
029:
030:        import org.netbeans.modules.xml.wsdl.model.WSDLModel;
031:        import org.netbeans.modules.xml.xam.spi.Validation;
032:        import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
033:        import org.netbeans.modules.xml.xam.spi.ValidationResult;
034:        import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
035:        import org.netbeans.modules.wsdlextensions.ftp.validator.FTPComponentValidator;
036:
037:        /**
038:         * @author jfu
039:         */
040:        public class FTPComponentValidatorTest extends TestCase {
041:            private static final ResourceBundle mMessages = ResourceBundle
042:                    .getBundle("org.netbeans.modules.wsdlextensions.ftp.validator.Bundle");
043:
044:            public FTPComponentValidatorTest(String testName) {
045:                super (testName);
046:            }
047:
048:            protected void setUp() throws Exception {
049:            }
050:
051:            protected void tearDown() throws Exception {
052:                //TestCatalogModel.getDefault().clearDocumentPool();
053:            }
054:
055:            private ValidationResult validate(String relativePath)
056:                    throws Exception {
057:                WSDLModel model = Util.loadWSDLModel(relativePath);
058:                Validation validation = new Validation();
059:                ValidationType validationType = Validation.ValidationType.COMPLETE;
060:                FTPComponentValidator instance = new FTPComponentValidator();
061:                ValidationResult result = instance.validate(model, validation,
062:                        validationType);
063:                return result;
064:            }
065:
066:            private void validate(String relativePath,
067:                    HashSet<String> expectedErrors) throws Exception {
068:                System.out.println(relativePath);
069:                ValidationResult result = validate(relativePath);
070:                Iterator<ResultItem> it = result.getValidationResult()
071:                        .iterator();
072:                while (it.hasNext()) {
073:                    ResultItem item = it.next();
074:                    System.out.println("    " + item.getDescription());
075:                    assertTrue(item.getDescription(), match(item
076:                            .getDescription(), expectedErrors));
077:                }
078:                if (result.getValidationResult().size() == 0
079:                        && expectedErrors.size() > 0) {
080:                    fail("Expected at least " + expectedErrors.size()
081:                            + " error(s).  Got 0 errors instead");
082:                }
083:            }
084:
085:            private boolean match(String msg, HashSet<String> expectedErrors) {
086:                boolean result = false;
087:                if (msg != null && expectedErrors != null) {
088:                    Iterator it = expectedErrors.iterator();
089:                    while (it.hasNext()) {
090:                        if (msg.startsWith(it.next().toString())) {
091:                            result = true;
092:                            break;
093:                        }
094:                    }
095:                }
096:                return result;
097:            }
098:
099:            /**
100:             * Test of getName method, of class org.netbeans.modules.wsdlextensions.ftp.validation.FTPComponentValidator.
101:             */
102:            public void testGetName() throws Exception {
103:                FTPComponentValidator instance = new FTPComponentValidator();
104:
105:                String expResult = instance.getClass().getName();
106:                String result = instance.getName();
107:                assertEquals(expResult, result);
108:            }
109:
110:            /**
111:             * Test of validate method, of class org.netbeans.modules.wsdlextensions.ftp.validation.FTPComponentValidator.
112:             */
113:            public void testValidWSDLs() throws Exception {
114:                // Grab all our WSDL files to test using a known WSDL
115:                URI resource = Util
116:                        .getResourceURI("data/valid/valid_ftpbc_wsdl_001.wsdl");
117:                File resourceFile = new File(resource);
118:                File[] wsdls = resourceFile.getParentFile().listFiles(
119:                        new FileFilter() {
120:                            public boolean accept(File pathname) {
121:                                return pathname.getName().endsWith(".wsdl");
122:                            }
123:                        });
124:                for (int ii = 0; ii < wsdls.length; ii++) {
125:                    String relativePath = "data/valid/" + wsdls[ii].getName();
126:                    ValidationResult result = validate(relativePath);
127:                    assertTrue(result.getValidationResult().size() == 0);
128:                }
129:            }
130:
131:            /**
132:             FTPExtValidation.MISSING_FTP_ADDRESS=Missing ftp:address in service binding
133:             FTPExtValidation.ONLY_ONE_FTPADDRESS_ALLOWED=Only one ftp:address allowed
134:             FTPBindingValidation.ONLY_ONE_FTP_BINDING_ALLOWED=Only one ftp:binding allowed
135:             FTPAddress.MISSING_FTP_URL=Missing FTP URL in ftp binding address
136:             FTPAddress.MISSING_PROXY_URL=Missing proxy URL in ftp binding address
137:             FTPAddress.INVALID_FTP_URL_PREFIX=Invalid FTP url, not starting with ftp://, url=
138:             FTPAddress.MALFORMED_FTP_URL=Malformed FTP url, url=
139:             FTPAddress.INVALID_FTP_URL_PATH_NOT_ALLOWED=Invalid FTP url, path not allowed for a url as FTP endpoint, url=
140:             FTPAddress.MALFORMED_FTP_URL_HOST_REQUIRED=Invalid FTP url, host required, url=
141:
142:             FTPAddress.INVALID_PROXY_URL_PREFIX=Invalid proxy url, not starting with socks4:// or socks5://, url value=
143:             FTPAddress.MALFORMED_PROXY_URL=Malformed proxy url, url=
144:             FTPAddress.INVALID_PROXY_URL_PATH_NOT_ALLOWED=Invalid proxy url, path not allowed for a proxy url
145:             FTPAddress.MALFORMED_PROXY_URL_HOST_REQUIRED=Invalid proxy url, host required, url=
146:             FTPAddress.REPLACE_FTP_URL_PLACEHOLDER_WITH_REAL_URL=FTP url is still a ftp url placeholder, please specify a concrete FTP address.
147:             FTPAddress.REPLACE_PROXY_URL_PLACEHOLDER_WITH_REAL_URL=Proxy url is still a placeholder, please specify a concrete proxy address.
148:             FTPAddress.INVALID_PORT_IN_URL=Invalid port in URL, must be a positive number following host name as in localhost:21, url=
149:
150:             FTPTransfer.MISSING_TARGET_FILE=Missing Target File Name for ftp:transfer.
151:             FTPTransfer.MISSING_UD_HEURISTICS_CFG_LOC=Location for user defined heuristics not specified.
152:             FTPTransfer.MISSING_UD_DIRLSTSTYLE_NAME=User defined directory listing style name not specified.
153:
154:             FTPBindingValidation.MISSING_FTP_OPERATION=Missing ftp:operation in ftp:binding
155:             FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT=At most one ftp:transfer allowed in one <input> binding, found:
156:             FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT=At most one ftp:transfer allowed in one <output> binding, found:
157:             FTPBindingValidation.FTP_OPERATION_WO_FTP_BINDING=ftp:operation found without corresponding ftp:binding
158:             */
159:            public void testInvalidFTPWSDL001() throws Exception {
160:                HashSet<String> expectedErrors = new HashSet<String>();
161:                expectedErrors.add(mMessages
162:                        .getString("FTPTransfer.MISSING_TARGET_FILE"));
163:                expectedErrors.add(mMessages
164:                        .getString("FTPAddress.MALFORMED_FTP_URL"));
165:                validate("data/invalid/invalid_ftpbc_wsdl_001.wsdl",
166:                        expectedErrors);
167:            }
168:
169:            public void testInvalidFTPWSDL002() throws Exception {
170:                HashSet<String> expectedErrors = new HashSet<String>();
171:                expectedErrors
172:                        .add(mMessages
173:                                .getString("FTPBindingValidation.MISSING_FTP_OPERATION"));
174:                validate("data/invalid/invalid_ftpbc_wsdl_002.wsdl",
175:                        expectedErrors);
176:            }
177:
178:            public void testInvalidFTPWSDL003() throws Exception {
179:                HashSet<String> expectedErrors = new HashSet<String>();
180:                expectedErrors
181:                        .add(mMessages
182:                                .getString("FTPAddress.REPLACE_PROXY_URL_PLACEHOLDER_WITH_REAL_URL"));
183:                validate("data/invalid/invalid_ftpbc_wsdl_003.wsdl",
184:                        expectedErrors);
185:            }
186:
187:            public void testInvalidFTPWSDL004() throws Exception {
188:                HashSet<String> expectedErrors = new HashSet<String>();
189:                expectedErrors
190:                        .add(mMessages
191:                                .getString("FTPTransfer.MISSING_UD_HEURISTICS_CFG_LOC"));
192:                validate("data/invalid/invalid_ftpbc_wsdl_004.wsdl",
193:                        expectedErrors);
194:            }
195:
196:            public void testInvalidFTPWSDL005() throws Exception {
197:                HashSet<String> expectedErrors = new HashSet<String>();
198:                expectedErrors
199:                        .add(mMessages
200:                                .getString("FTPBindingValidation.FTP_OPERATION_WO_FTP_BINDING"));
201:                validate("data/invalid/invalid_ftpbc_wsdl_005.wsdl",
202:                        expectedErrors);
203:            }
204:
205:            public void testInvalidFTPWSDL006() throws Exception {
206:                HashSet<String> expectedErrors = new HashSet<String>();
207:                expectedErrors
208:                        .add(mMessages
209:                                .getString("FTPAddress.REPLACE_FTP_URL_PLACEHOLDER_WITH_REAL_URL"));
210:                expectedErrors.add(mMessages
211:                        .getString("FTPTransfer.MISSING_TARGET_FILE"));
212:                validate("data/invalid/invalid_ftpbc_wsdl_006.wsdl",
213:                        expectedErrors);
214:            }
215:
216:            public void testInvalidFTPWSDL007() throws Exception {
217:                HashSet<String> expectedErrors = new HashSet<String>();
218:                expectedErrors.add(mMessages
219:                        .getString("FTPAddress.MISSING_FTP_URL"));
220:                expectedErrors.add(mMessages
221:                        .getString("FTPAddress.MISSING_PROXY_URL"));
222:                validate("data/invalid/invalid_ftpbc_wsdl_007.wsdl",
223:                        expectedErrors);
224:            }
225:
226:            public void testInvalidFTPWSDL008() throws Exception {
227:                HashSet<String> expectedErrors = new HashSet<String>();
228:                expectedErrors.add(mMessages
229:                        .getString("FTPExtValidation.MISSING_FTP_ADDRESS"));
230:                validate("data/invalid/invalid_ftpbc_wsdl_008.wsdl",
231:                        expectedErrors);
232:            }
233:
234:            public void testInvalidFTPWSDL009() throws Exception {
235:                HashSet<String> expectedErrors = new HashSet<String>();
236:                expectedErrors.add(mMessages
237:                        .getString("FTPAddress.INVALID_FTP_URL_PREFIX"));
238:                validate("data/invalid/invalid_ftpbc_wsdl_009.wsdl",
239:                        expectedErrors);
240:            }
241:
242:            public void testInvalidFTPWSDL010() throws Exception {
243:                HashSet<String> expectedErrors = new HashSet<String>();
244:                expectedErrors.add(mMessages
245:                        .getString("FTPAddress.INVALID_PORT_IN_URL"));
246:                validate("data/invalid/invalid_ftpbc_wsdl_010.wsdl",
247:                        expectedErrors);
248:            }
249:
250:            public void testInvalidFTPWSDL011() throws Exception {
251:                HashSet<String> expectedErrors = new HashSet<String>();
252:                expectedErrors
253:                        .add(mMessages
254:                                .getString("FTPAddress.MALFORMED_PROXY_URL_HOST_REQUIRED"));
255:                validate("data/invalid/invalid_ftpbc_wsdl_011.wsdl",
256:                        expectedErrors);
257:            }
258:
259:            public void testInvalidFTPWSDL012() throws Exception {
260:                HashSet<String> expectedErrors = new HashSet<String>();
261:                expectedErrors
262:                        .add(mMessages
263:                                .getString("FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_INPUT"));
264:                expectedErrors
265:                        .add(mMessages
266:                                .getString("FTPBindingValidation.ATMOST_ONE_TRANSFER_IN_OUTPUT"));
267:                validate("data/invalid/invalid_ftpbc_wsdl_012.wsdl",
268:                        expectedErrors);
269:            }
270:
271:            public void testInvalidFTPWSDL013() throws Exception {
272:                HashSet<String> expectedErrors = new HashSet<String>();
273:                expectedErrors
274:                        .add(mMessages
275:                                .getString("FTPBindingValidation.ONLY_ONE_FTP_BINDING_ALLOWED"));
276:                validate("data/invalid/invalid_ftpbc_wsdl_013.wsdl",
277:                        expectedErrors);
278:            }
279:
280:            public void testInvalidFTPWSDL014() throws Exception {
281:                HashSet<String> expectedErrors = new HashSet<String>();
282:                expectedErrors
283:                        .add(mMessages
284:                                .getString("FTPExtValidation.ONLY_ONE_FTPADDRESS_ALLOWED"));
285:                validate("data/invalid/invalid_ftpbc_wsdl_014.wsdl",
286:                        expectedErrors);
287:            }
288:        }
ww_w___.ja__v___a___2__s_.__c___o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.