Source Code Cross Referenced for AcceptanceTests.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » test » dataprovider » visualsqleditor » 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.visualsqleditor 
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.visualsqleditor;
043:
044:        import java.awt.event.*;
045:        import java.util.*;
046:        import java.awt.event.*;
047:        import java.awt.*;
048:        import javax.swing.*;
049:        import javax.swing.tree.*;
050:        import org.netbeans.jemmy.*;
051:        import org.netbeans.jemmy.operators.*;
052:        import org.netbeans.jellytools.actions.*;
053:        import org.netbeans.modules.visualweb.gravy.*;
054:        import org.netbeans.modules.visualweb.gravy.designer.*;
055:        import org.netbeans.modules.visualweb.gravy.dataconnectivity.*;
056:        import org.netbeans.test.dataprovider.common.*;
057:
058:        public class AcceptanceTests implements  Constants {
059:            private static final String DB_SCHEMA_NAME_TRAVEL = "TRAVEL",
060:                    SQL_QUERY_UNSUPPORTED = "SELECT MAX(TRAVEL.PERSON.PERSONID)+1 FROM TRAVEL.PERSON",
061:                    SQL_QUERY_PERSON_SELECT_2_FIELDS = "SELECT ALL PERSON.PERSONID, PERSON.FREQUENTFLYER FROM PERSON",
062:                    SQL_QUERY_PERSON_SELECT_ALL_FIELDS = "SELECT ALL PERSON.PERSONID, PERSON.NAME, PERSON.JOBTITLE, PERSON.FREQUENTFLYER, PERSON.LASTUPDATED FROM PERSON",
063:                    FIELD_PERSONID = "PERSONID",
064:                    QUERY_CRITERIA_GREATER_THAN = "> Greater Than";
065:
066:            private static int INPUT_TABLE_COLUMN_INDEX_OUTPUT = 3,
067:                    STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX = 0,
068:                    STRUCTURE_TABLE_COLUMN_INDEX_FIELD = 2;
069:
070:            private BaseTests testCaseInstance;
071:
072:            public AcceptanceTests(BaseTests testCaseInstance) {
073:                this .testCaseInstance = testCaseInstance;
074:            }
075:
076:            /**
077:             * Adds several DB tables to Query Editor.
078:             */
079:            public void checkQueryEditor_AddDBTables() {
080:                String dbURL = TestPropertiesHandler
081:                        .getDatabaseProperty("DB_URL");
082:                Utils.callPopupMenuForDBTable(dbURL, DB_TABLE_PERSON,
083:                        POPUP_MENU_ITEM_DESIGN_QUERY);
084:
085:                Utils.logMsg("+++ Popup menu item ["
086:                        + POPUP_MENU_ITEM_DESIGN_QUERY
087:                        + "] has been invoked for the DB table ["
088:                        + DB_TABLE_PERSON + "]");
089:                Util.wait(2000);
090:                new QueueTool().waitEmpty();
091:
092:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
093:                Util.wait(1000);
094:                new QueueTool().waitEmpty();
095:                Utils.logMsg("+++ Query Editor has been opened: "
096:                        + queryBuilder.getSource());
097:
098:                //TestUtils.printComponentList("D:\\zzz.zzz", visualSQLEditor.getSource().getParent().getParent());
099:
100:                String[] dbTableNames = { DB_TABLE_TRIP,
101:                        DB_TABLE_VALIDATION_TABLE };
102:                for (String dbTableName : dbTableNames) {
103:                    queryBuilder.addTable(dbTableName);
104:                    Util.wait(1000);
105:                    new QueueTool().waitEmpty();
106:                    Utils.logMsg("+++ DB table [" + dbTableName
107:                            + "] has been added on Query Editor Graph Panel");
108:
109:                    JTextComponentOperator textComponentOp = queryBuilder
110:                            .getQueryTextComponent();
111:                    Util.wait(1000);
112:                    new QueueTool().waitEmpty();
113:
114:                    String sqlStatementText = textComponentOp.getText();
115:                    Utils
116:                            .logMsg("+++ SQL statement in Query Editor SQL Text Panel: ["
117:                                    + sqlStatementText + "]");
118:
119:                    testCaseInstance.writeRefData(new Object[] {
120:                            GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText,
121:                            GOLDEN_FILE_LINE_SEPARATOR });
122:                }
123:                //Utils.doCloseWindow();
124:                //Util.wait(1000);
125:                //new QueueTool().waitEmpty();
126:
127:                testCaseInstance.compareReferenceFiles();
128:                Utils.logMsg("+++ SQL statements equal to goldenfile data");
129:            }
130:
131:            /**
132:             * Removes DB tables from Query Editor.
133:             */
134:            public void checkQueryEditor_RemoveDBTables() {
135:                // Query Editor is opened and 3 DB tables are placed on Graph Panel
136:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
137:                Util.wait(1000);
138:                new QueueTool().waitEmpty();
139:                Utils.logMsg("+++ Query Editor is opened: "
140:                        + queryBuilder.getSource());
141:
142:                String[] dbTableNames = { DB_TABLE_VALIDATION_TABLE,
143:                        DB_TABLE_TRIP };
144:                for (String dbTableName : dbTableNames) {
145:                    queryBuilder.removeTable(dbTableName);
146:                    Util.wait(1000);
147:                    new QueueTool().waitEmpty();
148:                    Utils
149:                            .logMsg("+++ DB table ["
150:                                    + dbTableName
151:                                    + "] has been removed from Query Editor Graph Panel");
152:
153:                    JTextComponentOperator textComponentOp = queryBuilder
154:                            .getQueryTextComponent();
155:                    Util.wait(1000);
156:                    new QueueTool().waitEmpty();
157:
158:                    String sqlStatementText = textComponentOp.getText();
159:                    Utils
160:                            .logMsg("+++ SQL statement in Query Editor SQL Text Panel: ["
161:                                    + sqlStatementText + "]");
162:
163:                    testCaseInstance.writeRefData(new Object[] {
164:                            GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText,
165:                            GOLDEN_FILE_LINE_SEPARATOR });
166:                }
167:                String gridTableData = gridTableData2String(queryBuilder);
168:                testCaseInstance.writeRefData(new Object[] {
169:                        GOLDEN_FILE_LINE_SEPARATOR, gridTableData,
170:                        GOLDEN_FILE_LINE_SEPARATOR });
171:
172:                if (gridTableData.contains(DB_TABLE_VALIDATION_TABLE)) {
173:                    throw new RuntimeException(
174:                            "Columns of DB table ["
175:                                    + DB_TABLE_VALIDATION_TABLE
176:                                    + "] aren't removed completely from Query Editor Table Panel");
177:                }
178:                if (gridTableData.contains(DB_TABLE_TRIP)) {
179:                    throw new RuntimeException(
180:                            "Columns of DB table ["
181:                                    + DB_TABLE_TRIP
182:                                    + "] aren't removed completely from Query Editor Table Panel");
183:                }
184:                testCaseInstance.compareReferenceFiles();
185:                Utils.logMsg("+++ Test data equal to goldenfile data");
186:            }
187:
188:            /**
189:             * Parses SQL queries in Query Editor.
190:             */
191:            public void checkQueryEditor_ParseSQLQuery() {
192:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
193:                Util.wait(1000);
194:                new QueueTool().waitEmpty();
195:                Utils.logMsg("+++ Query Editor is opened: "
196:                        + queryBuilder.getSource());
197:
198:                queryBuilder.retypeQuery(SQL_QUERY_PERSON_SELECT_2_FIELDS);
199:                Utils.logMsg("+++ SQL query ["
200:                        + SQL_QUERY_PERSON_SELECT_2_FIELDS
201:                        + "] has been entered");
202:                queryBuilder.parseQuery();
203:                Utils.logMsg("+++ SQL query ["
204:                        + SQL_QUERY_PERSON_SELECT_2_FIELDS
205:                        + "] has been parsed");
206:
207:                queryBuilder.retypeQuery(SQL_QUERY_UNSUPPORTED);
208:                Utils.logMsg("+++ SQL query [" + SQL_QUERY_UNSUPPORTED
209:                        + "] has been entered");
210:                String errMsg = null;
211:                /*
212:                queryBuilder.parseQuery();
213:
214:                Exception e = waitErrorDialogUnsupportedSQLStatement(BUTTON_LABEL_CANCEL);
215:                if (e != null) {
216:                    errMsg = (e instanceof TimeoutExpiredException ? 
217:                        "Dialog [" + DIALOG_TITLE_SQL_PARSING_ERROR + "] hasn't appeared after " +
218:                            "parsing of unsupported SQL query [" + SQL_QUERY_UNSUPPORTED + "]" :
219:                        e.getMessage());
220:                } else {
221:                    Utils.logMsg("+++ Dialog [" + DIALOG_TITLE_SQL_PARSING_ERROR + "] has appeared " +
222:                        "after parsing of unsupported SQL query [" + SQL_QUERY_UNSUPPORTED + "]");
223:                }
224:                 */
225:                queryBuilder.retypeQuery(SQL_QUERY_PERSON_SELECT_2_FIELDS);
226:                Utils.logMsg("+++ SQL query ["
227:                        + SQL_QUERY_PERSON_SELECT_2_FIELDS
228:                        + "] has been entered");
229:                queryBuilder.parseQuery();
230:                Utils.logMsg("+++ SQL query ["
231:                        + SQL_QUERY_PERSON_SELECT_2_FIELDS
232:                        + "] has been parsed");
233:
234:                queryBuilder.parseQuery(); // if first parsing gives error dialog, this parsing will fail to call popup menu
235:                Utils.logMsg("+++ SQL query ["
236:                        + SQL_QUERY_PERSON_SELECT_2_FIELDS
237:                        + "] has been parsed twice");
238:
239:                if (errMsg != null) {
240:                    throw new RuntimeException(errMsg);
241:                }
242:            }
243:
244:            /**
245:             * Runs SQL query in Query Editor.
246:             */
247:            public void checkQueryEditor_RunSQLQuery() {
248:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
249:                Util.wait(1000);
250:                new QueueTool().waitEmpty();
251:                Utils.logMsg("+++ Query Editor is opened: "
252:                        + queryBuilder.getSource());
253:
254:                queryBuilder.addTable(DB_TABLE_PERSON);
255:
256:                testCaseInstance
257:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
258:                printTable(queryBuilder.runQuery());
259:                testCaseInstance
260:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
261:                Utils.logMsg("+++ SQL statement ["
262:                        + queryBuilder.getQueryTextComponent().getText()
263:                        + "] has been run in Query Editor");
264:
265:                testCaseInstance.compareReferenceFiles();
266:                Utils.logMsg("+++ SQL statements equal to goldenfile data");
267:            }
268:
269:            /**
270:             * Runs SQL query with ORDER clause
271:             */
272:            public void checkQueryEditor_RunOrderedSQLQuery() {
273:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
274:                Util.wait(1000);
275:                new QueueTool().waitEmpty();
276:                Utils.logMsg("+++ Query Editor is opened: "
277:                        + queryBuilder.getSource());
278:
279:                queryBuilder.addTable(DB_TABLE_PERSON);
280:                JTableOperator jTable = queryBuilder.getInputTable();
281:
282:                // Specify the 1st sort type
283:                setInputTableComboboxValue(jTable, 0,
284:                        QueryBuilderOperator.SORT_TYPE,
285:                        QueryBuilderOperator.DESCENDING);
286:                String sqlStatementText = queryBuilder.getQueryTextComponent()
287:                        .getText();
288:                testCaseInstance.writeRefData(new Object[] {
289:                        GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText });
290:                printTable(queryBuilder.runQuery());
291:                testCaseInstance
292:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
293:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
294:                        + "] has been run in Query Editor");
295:
296:                // Specify the 2nd sort type
297:                setInputTableComboboxValue(jTable, 3,
298:                        QueryBuilderOperator.SORT_TYPE,
299:                        QueryBuilderOperator.ASCENDING);
300:                sqlStatementText = queryBuilder.getQueryTextComponent()
301:                        .getText();
302:                testCaseInstance.writeRefData(new Object[] {
303:                        GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText });
304:                printTable(queryBuilder.runQuery());
305:                testCaseInstance
306:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
307:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
308:                        + "] has been run in Query Editor");
309:
310:                // Specify sort order
311:                setInputTableComboboxValue(jTable, 3,
312:                        QueryBuilderOperator.SORT_ORDER, "1");
313:                sqlStatementText = queryBuilder.getQueryTextComponent()
314:                        .getText();
315:                testCaseInstance.writeRefData(new Object[] {
316:                        GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText });
317:                printTable(queryBuilder.runQuery());
318:                testCaseInstance
319:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
320:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
321:                        + "] has been run in Query Editor");
322:
323:                testCaseInstance.compareReferenceFiles();
324:                Utils.logMsg("+++ SQL statements equal to goldenfile data");
325:            }
326:
327:            /**
328:             * Runs SQL query with criteria
329:             */
330:            public void checkQueryEditor_RunSQLQueryWithCriteria() {
331:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
332:                Util.wait(1000);
333:                new QueueTool().waitEmpty();
334:                Utils.logMsg("+++ Query Editor is opened: "
335:                        + queryBuilder.getSource());
336:
337:                queryBuilder.addTable(DB_TABLE_PERSON);
338:                queryBuilder.addSimpleCriteria(FIELD_PERSONID, "3",
339:                        "> Greater Than");
340:                String sqlStatementText = queryBuilder.getQueryTextComponent()
341:                        .getText();
342:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
343:                        + "] with criteria in Query Editor");
344:
345:                queryBuilder.parseQuery();
346:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
347:                        + "] has been parsed in Query Editor");
348:
349:                testCaseInstance.writeRefData(new Object[] {
350:                        GOLDEN_FILE_LINE_SEPARATOR, sqlStatementText });
351:                printTable(queryBuilder.runQuery());
352:                testCaseInstance
353:                        .writeRefData(new Object[] { GOLDEN_FILE_LINE_SEPARATOR });
354:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
355:                        + "] has been run in Query Editor");
356:
357:                Utils.doCloseWindow();
358:                Util.wait(1000);
359:                new QueueTool().waitEmpty();
360:
361:                testCaseInstance.compareReferenceFiles();
362:                Utils.logMsg("+++ SQL statements equal to goldenfile data");
363:            }
364:
365:            /**
366:             * Puts DB table on VW project Designer and 
367:             * opens Query Editor for the created CachedRowSet 
368:             */
369:            public void checkQueryEditor_QueryEditorForCachedRowSet() {
370:                String dbURL = TestPropertiesHandler
371:                        .getDatabaseProperty("DB_URL"), dbTableName = DB_TABLE_PERSON, rowSetName = Utils
372:                        .getBaseRowSetName(dbTableName), dataProviderName = Utils
373:                        .getBaseDataProviderName(dbTableName);
374:
375:                Utils.putDBTableOnComponent(dbURL, dbTableName, new Point(25,
376:                        25));
377:                //--------------------------------------------------------------------//
378:                class FakeJSFComponent extends JSFComponent {
379:                    @Override
380:                    protected void checkRowSetAppearance(String rowSetNodeName) {
381:                        super .checkRowSetAppearance(rowSetNodeName);
382:                    }
383:
384:                    @Override
385:                    protected void checkDataProviderAppearance(
386:                            String dataProviderNodeName) {
387:                        super .checkDataProviderAppearance(dataProviderNodeName);
388:                    }
389:                }
390:                FakeJSFComponent fakeJSFComponent = new FakeJSFComponent();
391:                //--------------------------------------------------------------------//
392:                Utils.doResetWindows();
393:                fakeJSFComponent
394:                        .checkRowSetAppearance(NAVIGATOR_TREE_NODE_SESSION_PREFIX
395:                                + rowSetName);
396:                fakeJSFComponent
397:                        .checkDataProviderAppearance(NAVIGATOR_TREE_NODE_PAGE_PREFIX
398:                                + dataProviderName);
399:
400:                openQueryEditorForCachedRowSet(
401:                        NAVIGATOR_TREE_NODE_SESSION_PREFIX.replace("|", ""),
402:                        rowSetName);
403:                Utils.doSaveAll();
404:
405:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
406:                Util.wait(1000);
407:                new QueueTool().waitEmpty();
408:                Utils.logMsg("+++ Query Editor is opened: "
409:                        + queryBuilder.getSource());
410:
411:                boolean isDBTableOpened = queryBuilder
412:                        .isDBTableOpenedOnGraphPanel(dbTableName);
413:                if (!isDBTableOpened) {
414:                    throw new RuntimeException("DB table [" + dbTableName
415:                            + "] isn't found on Graph Panel");
416:                }
417:                Utils.logMsg("+++ DB table [" + dbTableName
418:                        + "] is found on Graph Panel");
419:
420:                String sqlStatementText = queryBuilder.getQueryTextComponent()
421:                        .getText();
422:                Utils.logMsg("+++ SQL statement [" + sqlStatementText
423:                        + "] with criteria in Query Editor");
424:            }
425:
426:            private void openQueryEditorForCachedRowSet(String beanNodeName,
427:                    String rowSetName) {
428:                JTreeOperator navigatorTreeOp = Utils
429:                        .getNavigatorTreeOperator();
430:                TreePath treePath = Utils.selectChildOfTreeNode(
431:                        (JTree) navigatorTreeOp.getSource(), beanNodeName,
432:                        rowSetName);
433:                navigatorTreeOp.clickOnPath(treePath, 2); // double click on rowset
434:                Util.wait(1000);
435:                new QueueTool().waitEmpty();
436:            }
437:
438:            /**
439:             * Modifies SQL query and reopens Query Editor for CachedRowSet
440:             */
441:            public void checkQueryEditor_ModifyQueryForCachedRowSet() {
442:                QueryBuilderOperator queryBuilder = new QueryBuilderOperator();
443:                Util.wait(1000);
444:                new QueueTool().waitEmpty();
445:                Utils.logMsg("+++ Query Editor is opened: "
446:                        + queryBuilder.getSource());
447:
448:                queryBuilder.retypeQuery(SQL_QUERY_PERSON_SELECT_ALL_FIELDS);
449:                Utils.logMsg("+++ SQL query ["
450:                        + SQL_QUERY_PERSON_SELECT_ALL_FIELDS
451:                        + "] has been entered");
452:                queryBuilder.parseQuery();
453:                Utils.logMsg("+++ SQL query ["
454:                        + SQL_QUERY_PERSON_SELECT_ALL_FIELDS
455:                        + "] has been parsed");
456:
457:                JTableOperator structureTable = queryBuilder
458:                        .getStructureTableOfDBTableOnGraphPanel(DB_TABLE_PERSON);
459:                if (structureTable == null) {
460:                    throw new RuntimeException("DB table [" + DB_TABLE_PERSON
461:                            + "] isn't found on Graph Panel "
462:                            + "or its structure table isn't found");
463:                }
464:                Utils.logMsg("+++ Structure table of DB table ["
465:                        + DB_TABLE_PERSON + "] is found");
466:
467:                // unmark the 1st checkbox (exclude the 1st field from SQL query)
468:                Utils
469:                        .logMsg("+++ Current value of the 1st checkbox in the structure table: ["
470:                                + structureTable.getValueAt(0,
471:                                        STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX)
472:                                + "]");
473:                structureTable.clickOnCell(0,
474:                        STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX);
475:                Util.wait(1000);
476:                new QueueTool().waitEmpty();
477:
478:                structureTable.setValueAt(Boolean.FALSE, 0,
479:                        STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX);
480:                Util.wait(1000);
481:                new QueueTool().waitEmpty();
482:                Utils
483:                        .logMsg("+++ Current value of the 1st DB table checkbox in the structure table: ["
484:                                + structureTable.getValueAt(0,
485:                                        STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX)
486:                                + "]");
487:
488:                Utils.doCloseWindow(); // modified SQL query should be stored in the appropriate CachedRowSet
489:                Util.wait(1000);
490:                new QueueTool().waitEmpty();
491:
492:                openQueryEditorForCachedRowSet(
493:                        NAVIGATOR_TREE_NODE_SESSION_PREFIX.replace("|", ""),
494:                        Utils.getBaseRowSetName(DB_TABLE_PERSON));
495:                queryBuilder = new QueryBuilderOperator();
496:                Util.wait(1000);
497:                new QueueTool().waitEmpty();
498:                Utils.logMsg("+++ Query Editor is opened: "
499:                        + queryBuilder.getSource());
500:
501:                structureTable = queryBuilder
502:                        .getStructureTableOfDBTableOnGraphPanel(DB_TABLE_PERSON);
503:                if (structureTable == null) {
504:                    throw new RuntimeException("DB table [" + DB_TABLE_PERSON
505:                            + "] isn't found on Graph Panel "
506:                            + "or its structure table isn't found");
507:                }
508:                Utils.logMsg("+++ Structure table of DB table ["
509:                        + DB_TABLE_PERSON + "] is found");
510:                Boolean value = (Boolean) structureTable.getValueAt(0,
511:                        STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX);
512:                Utils
513:                        .logMsg("+++ Current value of the 1st cell in the structure table: ["
514:                                + value + "]");
515:
516:                Utils.doSaveAll();
517:
518:                if (!value.equals(Boolean.FALSE)) {
519:                    throw new RuntimeException(
520:                            "SQL query wasn't stored in CachedRowSet properly: "
521:                                    + "the 1st checkbox of structure table should be ["
522:                                    + Boolean.FALSE + "], "
523:                                    + "but its current value is [" + value
524:                                    + "]");
525:                }
526:                checkStructureTableInpuTableSynchronization(structureTable,
527:                        queryBuilder.getInputTable());
528:                checkStructureTableSQLQuerySynchronization(structureTable,
529:                        queryBuilder.getQueryTextComponent().getText(),
530:                        DB_TABLE_PERSON);
531:            }
532:
533:            private void checkStructureTableSQLQuerySynchronization(
534:                    JTableOperator structTable, String controlSQLQuery,
535:                    String dbTableName) {
536:                String sqlQuery = "SELECT ALL ";
537:                int structRowCount = structTable.getRowCount();
538:                for (int i = 0; i < structRowCount; ++i) {
539:                    Boolean structValue = (Boolean) structTable.getValueAt(i,
540:                            STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX);
541:                    if (structValue) {
542:                        sqlQuery += dbTableName
543:                                + "."
544:                                + structTable.getValueAt(i,
545:                                        STRUCTURE_TABLE_COLUMN_INDEX_FIELD)
546:                                + (i < (structRowCount - 1) ? ", " : "");
547:                    }
548:                }
549:                sqlQuery += " FROM " + dbTableName;
550:                Utils.logMsg("+++ SQL query from structure table = ["
551:                        + sqlQuery + "]");
552:                Utils.logMsg("+++ Control SQL query = [" + controlSQLQuery
553:                        + "]");
554:
555:                sqlQuery = testCaseInstance.changeExtraWhiteSpaces(sqlQuery);
556:                String proxyControlSQLQuery = testCaseInstance
557:                        .changeExtraWhiteSpaces(controlSQLQuery).replace("\"",
558:                                "").replace(DB_SCHEMA_NAME_TRAVEL + ".", "");
559:                if (!sqlQuery.equalsIgnoreCase(proxyControlSQLQuery)) {
560:                    throw new RuntimeException(
561:                            "Control SQL query ["
562:                                    + controlSQLQuery
563:                                    + "] isn't equal to SQL query from structure table ["
564:                                    + sqlQuery + "]");
565:                }
566:                Utils
567:                        .logMsg("+++ Control SQL query is equal to SQL query from structure table.");
568:            }
569:
570:            private void checkStructureTableInpuTableSynchronization(
571:                    JTableOperator structTable, JTableOperator inputTable) {
572:                int structRowCount = structTable.getRowCount(), inputRowCount = inputTable
573:                        .getRowCount();
574:                if (structRowCount != inputRowCount) {
575:                    throw new RuntimeException(
576:                            "Amount of rows for structure table in Graph Pane ["
577:                                    + structRowCount
578:                                    + "] "
579:                                    + "isn't equal to amount of rows for table in Grid Pane ["
580:                                    + inputRowCount + "]");
581:                }
582:                Utils
583:                        .logMsg("+++ Amount of rows for structure table in Graph Pane ["
584:                                + structRowCount
585:                                + "] "
586:                                + "is equal to amount of rows for table in Grid Pane ["
587:                                + inputRowCount + "]");
588:                for (int i = 0; i < structRowCount; ++i) {
589:                    Boolean structValue = (Boolean) structTable.getValueAt(i,
590:                            STRUCTURE_TABLE_COLUMN_INDEX_CHECKBOX), inputValue = (Boolean) inputTable
591:                            .getValueAt(i, INPUT_TABLE_COLUMN_INDEX_OUTPUT);
592:                    if (!structValue.equals(inputValue)) {
593:                        throw new RuntimeException(
594:                                "Checkbox value ["
595:                                        + structValue
596:                                        + "] of the 1st column for structure table in Graph Pane "
597:                                        + "isn't equal to checkbox value ["
598:                                        + inputValue + "] of column [Output] "
599:                                        + "for table in Grid Pane: row = ["
600:                                        + (i + 1) + "]");
601:                    }
602:                }
603:                Utils
604:                        .logMsg("+++ Data of structure table in Graph Pane are synchronized with data of table in Grid Pane");
605:            }
606:
607:            protected void setInputTableComboboxValue(JTableOperator jTable,
608:                    int rowNumber, String columnName, String comboboxValue) {
609:                jTable.clickOnCell(rowNumber, jTable.findColumn(columnName));
610:                Util.wait(1000);
611:                new QueueTool().waitEmpty();
612:
613:                JComboBoxOperator combobox = new JComboBoxOperator(jTable);
614:                Util.wait(1000);
615:                new QueueTool().waitEmpty();
616:
617:                combobox.setVerification(false);
618:                combobox.selectItem(comboboxValue);
619:                Util.wait(1000);
620:                new QueueTool().waitEmpty();
621:            }
622:
623:            protected Exception waitErrorDialogUnsupportedSQLStatement(
624:                    String buttonLabel) {
625:                return waitDialog(DIALOG_TITLE_SQL_PARSING_ERROR, buttonLabel);
626:            }
627:
628:            protected Exception waitDialog(String dialogTitle,
629:                    String buttonLabel) {
630:                String timeoutName = "DialogWaiter.WaitDialogTimeout";
631:                long previousTimeoutValue = JemmyProperties
632:                        .getCurrentTimeout(timeoutName), newTimeoutValue = 5000;
633:                JemmyProperties.getCurrentTimeouts().setTimeout(timeoutName,
634:                        newTimeoutValue);
635:                try {
636:                    JDialogOperator errDlg = new JDialogOperator(dialogTitle);
637:                    Util.wait(1000);
638:                    new QueueTool().waitEmpty();
639:                    new JButtonOperator(errDlg, buttonLabel).pushNoBlock();
640:                } catch (Exception e) {
641:                    return e;
642:                } finally {
643:                    JemmyProperties.getCurrentTimeouts().setTimeout(
644:                            timeoutName, previousTimeoutValue);
645:                    Util.wait(1000);
646:                    new QueueTool().waitEmpty();
647:                }
648:                return null;
649:            }
650:
651:            protected String printTable(JTableOperator table) {
652:                String res = "";
653:                for (int col = 0; col < table.getColumnCount(); col++) {
654:                    res += table.getColumnName(col) + " ";
655:                }
656:                testCaseInstance.writeRefData(new Object[] { res });
657:
658:                for (int row = 0; row < table.getRowCount(); row++) {
659:                    res = "";
660:                    for (int col = 0; col < table.getColumnCount(); col++) {
661:                        res += table.getValueAt(row, col).toString() + " ";
662:                    }
663:                    testCaseInstance.writeRefData(new Object[] { res });
664:                }
665:                return res;
666:            }
667:
668:            public static String gridTableData2String(
669:                    QueryBuilderOperator queryBuilder) {
670:                String result = "";
671:                JTableOperator gridTableOp = queryBuilder.getInputTable();
672:                for (int row = 0; row < queryBuilder.getInputTable()
673:                        .getRowCount(); row++) {
674:                    for (int col = 0; col < queryBuilder.getInputTable()
675:                            .getColumnCount(); col++) {
676:                        result += gridTableOp.getValueAt(row, col).toString()
677:                                + " ";
678:                    }
679:                    result += "\r\n";
680:                }
681:                return result;
682:            }
683:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.