Source Code Cross Referenced for RunProject.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » test » dataprovider » cachedrowsetdataprovider » 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 » visualweb.api.designer » org.netbeans.test.dataprovider.cachedrowsetdataprovider 
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:
007:        The contents of this file are subject to the terms of either the GNU
008:        General Public License Version 2 only ("GPL") or the Common
009:        Development and Distribution License("CDDL") (collectively, the
010:        "License"). You may not use this file except in compliance with the
011:        License. You can obtain a copy of the License at
012:        http://www.netbeans.org/cddl-gplv2.html
013:        or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
014:        specific language governing permissions and limitations under the
015:        License.  When distributing the software, include this License Header
016:        Notice in each file and include the License file at
017:        nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
018:        particular file as subject to the "Classpath" exception as provided
019:        by Sun in the GPL Version 2 section of the License file that
020:        accompanied this code. If applicable, add the following below the
021:        License Header, with the fields enclosed by brackets [] replaced by
022:        your own identifying information:
023:        "Portions Copyrighted [year] [name of copyright owner]"
024:
025:        Contributor(s):
026:
027:        The Original Software is NetBeans. The Initial Developer of the Original
028:        Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
029:        Microsystems, Inc. All Rights Reserved.
030:
031:        If you wish your version of this file to be governed by only the CDDL
032:        or only the GPL Version 2, indicate your decision by adding
033:        "[Contributor] elects to include this software in this distribution
034:        under the [CDDL or GPL Version 2] license." If you do not indicate a
035:        single choice of license, a recipient has the option to distribute
036:        your version of this file under either the CDDL, the GPL Version 2 or
037:        to extend the choice of license to its licensees as provided above.
038:        However, if you add GPL Version 2 code and therefore, elected the GPL
039:        Version 2 license, then the option applies only if the new code is
040:        made subject to such option by the copyright holder.
041:         */
042:        package org.netbeans.test.dataprovider.cachedrowsetdataprovider;
043:
044:        import org.netbeans.modules.visualweb.gravy.*;
045:        import com.meterware.httpunit.*;
046:        import java.util.*;
047:        import java.util.regex.*;
048:        import org.netbeans.test.dataprovider.common.*;
049:
050:        public class RunProject implements  Constants {
051:            private String webAppURL = TestPropertiesHandler
052:                    .getServerProperty("Application_Server_URL")
053:                    + ProjectTests.getCurrentPrjName();
054:            private int webResponseCode;
055:
056:            public String runProject() {
057:                String errMsg = null;
058:                webResponseCode = -1;
059:                try {
060:                    // if web-application with the same name was deployed already, undeploy it first
061:                    WebUtils.undeployProject(ProjectTests.getCurrentPrjName());
062:
063:                    WebUtils.runProject(ProjectTests.getCurrentPrjName());
064:                    WebResponse response = checkStatusWebAppDeployedFirst();
065:                    //response = changePersonDropDownListValue(response, "New Value, for example: Donaldson, Sue"); 
066:                } catch (Throwable e) {
067:                    e.printStackTrace(Utils.logStream);
068:                    errMsg = (e.getMessage() == null ? e.toString() : e
069:                            .getMessage());
070:                }
071:                return errMsg;
072:            }
073:
074:            private WebResponse checkStatusWebAppDeployedFirst() {
075:                try {
076:                    Utils.logMsg("+++ webAppURL = " + webAppURL);
077:
078:                    WebResponse response = WebUtils
079:                            .getWebResponseAfterDeployment(webAppURL);
080:                    String contentData = response.getText();
081:                    Utils.logMsg("+++ Web response after project deployment: "
082:                            + "content type = [" + response.getContentType()
083:                            + "], " + "response code = ["
084:                            + response.getResponseCode() + "], "
085:                            + "content data = [" + contentData + "]");
086:
087:                    if (!WebUtils.isWebResponseOK(response)) {
088:                        throw new RuntimeException(
089:                                "Result of deployment: web application isn't running correctly (web response code "
090:                                        + "is "
091:                                        + response.getResponseCode()
092:                                        + " instead of "
093:                                        + WEB_RESPONSE_CODE_OK
094:                                        + ")");
095:                    }
096:                    Utils.logMsg("+++ Web-application [" + webAppURL
097:                            + "] response is correct");
098:                    webResponseCode = WEB_RESPONSE_CODE_OK;
099:                    checkContentDataAfterDeployment(contentData);
100:                    return response;
101:                } catch (Throwable t) {
102:                    t.printStackTrace(Utils.logStream);
103:                    throw new RuntimeException(t);
104:                }
105:            }
106:
107:            public int getWebResponseCode() {
108:                return webResponseCode;
109:            }
110:
111:            private void checkContentDataAfterDeployment(String contentData) {
112:                checkPersonDropDownListDataAfterDeployment(contentData);
113:                checkTripTableDataAfterDeployment(contentData);
114:                checkTextFieldDataAfterDeployment(contentData,
115:                        TestPropertiesHandler
116:                                .getTestProperty("ID_TextField_DataBinding"),
117:                        "1");
118:                checkTextFieldDataAfterDeployment(
119:                        contentData,
120:                        TestPropertiesHandler
121:                                .getTestProperty("ID_TextField_Binding_DataProvider"),
122:                        "1");
123:            }
124:
125:            private void checkPersonDropDownListDataAfterDeployment(
126:                    String contentData) {
127:                String dropDownID = TestPropertiesHandler
128:                        .getTestProperty("ID_DropDownList_For_DBTablePerson");
129:                String pattern = getPatternPersonDropDownListDataAfterDeployment(dropDownID);
130:                boolean result = Pattern.matches(pattern, contentData);
131:                if (!result) {
132:                    throw new RuntimeException(
133:                            "Content data, related to Drop Down List ["
134:                                    + dropDownID + "], "
135:                                    + "don't match the pattern: [" + pattern
136:                                    + "]");
137:                }
138:                Utils.logMsg("Content data, related to Drop Down List ["
139:                        + dropDownID + "], " + "match the pattern: [" + pattern
140:                        + "]");
141:            }
142:
143:            private String getPatternPersonDropDownListDataAfterDeployment(
144:                    String dropDownID) {
145:                String patternPrefix = null, patternPostfix = null;
146:                if (Utils.isUsedJ2EELevel_5()) {
147:                    patternPrefix = PATTERN_PREFIX_DEPLOYMENT_DATA_J2EE_5_PERSON_DROPDOWNLIST;
148:                    patternPostfix = PATTERN_POSTFIX_DEPLOYMENT_DATA_J2EE_5_PERSON_DROPDOWNLIST;
149:                } else if (Utils.isUsedJ2EELevel_14()) {
150:                    patternPrefix = PATTERN_PREFIX_DEPLOYMENT_DATA_J2EE_14_PERSON_DROPDOWNLIST;
151:                    patternPostfix = PATTERN_POSTFIX_DEPLOYMENT_DATA_J2EE_14_PERSON_DROPDOWNLIST;
152:                }
153:                if ((Utils.isStringEmpty(patternPrefix))
154:                        || (Utils.isStringEmpty(patternPostfix))) {
155:                    return null;
156:                }
157:                return (patternPrefix + dropDownID + patternPostfix);
158:            }
159:
160:            private void checkTripTableDataAfterDeployment(String contentData) {
161:                Set<TableRowData> tripDataSet = getTripTableData(contentData);
162:                Utils.logMsg("+++ Trip Table Data = " + tripDataSet);
163:
164:                Set<TableRowData> controlTripDataSet = getControlTripTableData();
165:                Utils.logMsg("+++ Control Trip Table Data = "
166:                        + controlTripDataSet);
167:
168:                boolean result = controlTripDataSet.equals(tripDataSet);
169:                if (!result) {
170:                    throw new RuntimeException(
171:                            "Trip Table Data are not equal to Control Trip Table Data");
172:                }
173:                Utils
174:                        .logMsg("Trip Table Data are equal to Control Trip Table Data");
175:            }
176:
177:            private Set<TableRowData> getTripTableData(String contentData) {
178:                if (Utils.isUsedJ2EELevel_5()) {
179:                    return getTripTableData_J2EELevel_5(contentData);
180:                } else if (Utils.isUsedJ2EELevel_14()) {
181:                    return getTripTableData_J2EELevel_14(contentData);
182:                } else {
183:                    return null;
184:                }
185:            }
186:
187:            private Set<TableRowData> getTripTableData_J2EELevel_14(
188:                    String contentData) {
189:                Set<TableRowData> tripDataSet = new TreeSet<TableRowData>();
190:
191:                for (int i = 0; i < AMOUNT_TRIPS_PERSON_ID_1; ++i) {
192:                    TableRowData tableRowData = new TableRowData();
193:                    int posRowGroup = contentData
194:                            .indexOf(WEB_PAGE_TABLE_ROW_GROUP_PREFIX + i);
195:                    int posClosingTagSpan = posRowGroup;
196:                    for (int column = 0; column < 3; ++column) {
197:                        posClosingTagSpan = contentData.indexOf(
198:                                WEB_PAGE_CLOSING_TAG_SPAN, ++posClosingTagSpan);
199:                        int posLastTagChar = contentData.lastIndexOf(
200:                                WEB_PAGE_LAST_TAG_CHAR, posClosingTagSpan);
201:
202:                        String data = contentData.substring(posLastTagChar + 1,
203:                                posClosingTagSpan).trim();
204:
205:                        if (column == 0)
206:                            tableRowData.setDepDate(data);
207:                        if (column == 1)
208:                            tableRowData.setDepCity(data);
209:                        if (column == 2)
210:                            tableRowData.setDestCity(data);
211:
212:                        tripDataSet.add(tableRowData);
213:                    }
214:                }
215:                return tripDataSet;
216:            }
217:
218:            private Set<TableRowData> getTripTableData_J2EELevel_5(
219:                    String contentData) {
220:                Set<TableRowData> tripDataSet = new TreeSet<TableRowData>();
221:
222:                int posComma = 0;
223:                for (int i = 0; i < AMOUNT_TRIPS_PERSON_ID_1; ++i) {
224:                    TableRowData tableRowData = new TableRowData();
225:                    for (int column = 0; column < 3; ++column) {
226:                        int posRowGroup = contentData.indexOf(
227:                                WEB_PAGE_TABLE_ROW_GROUP_ID_PREFIX + i,
228:                                posComma);
229:                        int posValue = contentData.indexOf(
230:                                WEB_PAGE_COMPONENT_VALUE_PREFIX, posRowGroup);
231:                        posComma = contentData.indexOf(",", posValue);
232:
233:                        String data = contentData.substring(posValue, posComma)
234:                                .replace(WEB_PAGE_COMPONENT_VALUE_PREFIX, "")
235:                                .replace("\"", "").replace(":", "").trim();
236:
237:                        if (column == 0)
238:                            tableRowData.setDepDate(data);
239:                        if (column == 1)
240:                            tableRowData.setDepCity(data);
241:                        if (column == 2)
242:                            tableRowData.setDestCity(data);
243:
244:                        tripDataSet.add(tableRowData);
245:                    }
246:                }
247:                return tripDataSet;
248:            }
249:
250:            private Set<TableRowData> getControlTripTableData() {
251:                Set<TableRowData> controlTripDataSet = new TreeSet<TableRowData>();
252:                String year = TestPropertiesHandler
253:                        .getDatabaseProperty("DB_Data_Year");
254:                controlTripDataSet.add(new TableRowData("16.06." + year,
255:                        "Oakland", "New York"));
256:                controlTripDataSet.add(new TableRowData("14.09." + year,
257:                        "San Francisco", "New York"));
258:                controlTripDataSet.add(new TableRowData("22.10." + year,
259:                        "Oakland", "Toronto"));
260:                controlTripDataSet.add(new TableRowData("23.11." + year,
261:                        "San Francisco", "Tokyo"));
262:                controlTripDataSet.add(new TableRowData("12.12." + year,
263:                        "San Francisco", "Chicago"));
264:                return controlTripDataSet;
265:            }
266:
267:            private void checkTextFieldDataAfterDeployment(String contentData,
268:                    String textFieldID, String textFieldValue) {
269:                String textFieldData = getTextFieldData(contentData,
270:                        textFieldID);
271:                boolean result = textFieldData.equals(textFieldValue);
272:                if (!result) {
273:                    throw new RuntimeException("Value [" + textFieldData
274:                            + "] of text field [" + textFieldID
275:                            + "] doesn't equal to control value ["
276:                            + textFieldValue + "]");
277:                }
278:                Utils.logMsg("+++ Value of text field [" + textFieldID
279:                        + "] equals to control value [" + textFieldValue + "]");
280:            }
281:
282:            private String getTextFieldData(String contentData,
283:                    String textFieldID) {
284:                if (Utils.isUsedJ2EELevel_5()) {
285:                    return getTextFieldData_J2EELevel_5(contentData,
286:                            textFieldID);
287:                } else if (Utils.isUsedJ2EELevel_14()) {
288:                    return getTextFieldData_J2EELevel_14(contentData,
289:                            textFieldID);
290:                } else {
291:                    return null;
292:                }
293:            }
294:
295:            private String getTextFieldData_J2EELevel_14(String contentData,
296:                    String textFieldID) {
297:                int posTextFieldID = contentData
298:                        .indexOf(WEB_PAGE_COMPONENT_ID_J2EE14_PREFIX + "\""
299:                                + WEB_PAGE_FORM_PREFIX + textFieldID), posValue = contentData
300:                        .indexOf(WEB_PAGE_COMPONENT_VALUE_PREFIX,
301:                                posTextFieldID), posCommaFirst = contentData
302:                        .indexOf("\"", posValue), posCommaLast = contentData
303:                        .indexOf("\"", posCommaFirst + 1);
304:
305:                String data = contentData
306:                        .substring(posCommaFirst, posCommaLast).replace("\"",
307:                                "").trim();
308:                return data;
309:            }
310:
311:            private String getTextFieldData_J2EELevel_5(String contentData,
312:                    String textFieldID) {
313:                int posTextFieldID = contentData
314:                        .indexOf(WEB_PAGE_COMPONENT_ID_J2EE5_PREFIX + "\""
315:                                + WEB_PAGE_FORM_PREFIX + textFieldID), posValue = contentData
316:                        .indexOf(WEB_PAGE_COMPONENT_VALUE_PREFIX,
317:                                posTextFieldID), posComma = contentData
318:                        .indexOf(",", posValue);
319:
320:                String data = contentData.substring(posValue, posComma)
321:                        .replace(WEB_PAGE_COMPONENT_VALUE_PREFIX, "").replace(
322:                                "\"", "").replace(":", "").trim();
323:                return data;
324:            }
325:
326:            private WebResponse changePersonDropDownListValue(
327:                    WebResponse response, String newValue) throws Throwable {
328:                String dropDownID = TestPropertiesHandler
329:                        .getTestProperty("ID_DropDownList_For_DBTablePerson");
330:                WebForm webForm = response.getForms()[0];
331:
332:                // change value of Drop Down List "personDD"
333:
334:                WebResponse newResponse = webForm.submitNoButton(); //webForm.submit();
335:                String contentData = response.getText();
336:                Utils
337:                        .logMsg("+++ Web response after changing DropDownList value: "
338:                                + "content type = ["
339:                                + response.getContentType()
340:                                + "], "
341:                                + "response code = ["
342:                                + response.getResponseCode()
343:                                + "], "
344:                                + "content data = [" + contentData + "]");
345:                return newResponse;
346:            }
347:
348:            //========================================================================//
349:            private class TableRowData implements  Comparable {
350:                private String depDate = "", depCity = "", destCity = "";
351:
352:                public TableRowData() {
353:                }
354:
355:                public TableRowData(String depDate, String depCity,
356:                        String destCity) {
357:                    setDepDate(depDate);
358:                    setDepCity(depCity);
359:                    setDestCity(destCity);
360:                }
361:
362:                @Override
363:                public boolean equals(Object obj) {
364:                    boolean retValue;
365:                    TableRowData newTableRowData = (TableRowData) obj;
366:                    retValue = (this .toString().equals(newTableRowData
367:                            .toString()));
368:                    return retValue;
369:                }
370:
371:                @Override
372:                public int hashCode() { // was generated by NetBeans Wizard (Insert Code)
373:                    int hash = 3;
374:                    hash = 97
375:                            * hash
376:                            + (this .depDate != null ? this .depDate.hashCode()
377:                                    : 0);
378:                    hash = 97
379:                            * hash
380:                            + (this .depCity != null ? this .depCity.hashCode()
381:                                    : 0);
382:                    hash = 97
383:                            * hash
384:                            + (this .destCity != null ? this .destCity.hashCode()
385:                                    : 0);
386:                    return hash;
387:                }
388:
389:                public int compareTo(Object obj) {
390:                    int retValue;
391:                    TableRowData newTableRowData = (TableRowData) obj;
392:                    retValue = (this .toString().compareTo(newTableRowData
393:                            .toString()));
394:                    return retValue;
395:                }
396:
397:                public String getDepCity() {
398:                    return depCity;
399:                }
400:
401:                public void setDepCity(String depCity) {
402:                    this .depCity = depCity.replace("\"", "").trim();
403:                }
404:
405:                public String getDepDate() {
406:                    return depDate;
407:                }
408:
409:                public void setDepDate(String depDate) {
410:                    this .depDate = depDate.replace("\"", "").trim();
411:                }
412:
413:                public String getDestCity() {
414:                    return destCity;
415:                }
416:
417:                public void setDestCity(String destCity) {
418:                    this .destCity = destCity.replace("\"", "").trim();
419:                }
420:
421:                @Override
422:                public String toString() {
423:                    String retValue;
424:                    retValue = "DepDate: [" + getDepDate() + "], "
425:                            + "DepCity: [" + getDepCity() + "], "
426:                            + "DestCity: [" + getDestCity() + "] ";
427:                    return retValue;
428:                }
429:            }
430:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.