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: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.gravy;
043:
044: import java.io.IOException;
045:
046: import com.meterware.httpunit.*;
047:
048: import junit.framework.TestCase;
049:
050: /**
051: * RemoteDeploymentUtils class
052: */
053:
054: public class DeploymentUtils {
055: /**
056: * Check if project was deployed.
057: * @param deploy_string String to execute.
058: * @return True if project works well, in other way retuirn false.
059: */
060: public static boolean testProject(String deploy_string) {
061: try {
062: Process oasp = Runtime.getRuntime().exec(deploy_string);
063: System.out.println(deploy_string + " execute.");
064: try {
065: if (oasp.waitFor() == 0)
066: System.out
067: .println("Project has been deployed successfully!");
068: else {
069: System.out
070: .println("Project has not been deployed!");
071: TestCase.fail("Cannot run application.");
072: }
073: } catch (InterruptedException ie) {
074: TestCase.fail("Exception in waitFor() : " + ie);
075: return false;
076: }
077: oasp.destroy();
078: } catch (IOException e) {
079: TestCase.fail("Cannot run application.");
080: return false;
081: }
082: TestUtils.wait(20000);
083: return true;
084: }
085:
086: /**
087: * Check project with page navigation.
088: * @param checkURL Project's URL.
089: * @return True if project works well, in other way retuirn false.
090: */
091: public static boolean httpVerifySimpleNavigation(String checkURL) {
092: try {
093: WebConversation conversation = new WebConversation();
094: WebResponse response = null;
095: response = conversation.getResponse(checkURL);
096: WebForm addContainer = response.getForms()[0];
097:
098: SubmitButton btn = addContainer.getSubmitButtons()[0];
099: response = addContainer.submit(btn);
100: System.out.println("Response text after page commit: "
101: + response.getText());
102: if (!response.getTitle().equals("Page2 Title")) {
103: TestCase.fail("Cannot find Page2 in response");
104: return false;
105: }
106: } catch (Exception e) {
107: System.out.println("Exception occured: ");
108: e.printStackTrace();
109: TestCase.fail("Exception in HTTP check : " + e);
110: return false;
111: }
112: return true;
113: }
114:
115: /**
116: * Check project with web service.
117: * @param checkURL Project's URL.
118: * @return True if project works well, in other way retuirn false.
119: */
120: public static boolean httpVerifyWebService(String checkURL) {
121: try {
122: String webOutput;
123: WebConversation conversation = new WebConversation();
124: WebResponse response = null;
125: response = conversation.getResponse(checkURL);
126: WebForm addContainer = response.getForms()[0];
127: SubmitButton btn = addContainer.getSubmitButtons()[0];
128: response = addContainer.submit(btn);
129: webOutput = response.getText();
130: System.out.println("Response text : " + webOutput);
131: if (((response.getText()).indexOf("Kent") == -1)
132: || ((response.getText()).indexOf("Richard") == -1)
133: || ((response.getText())
134: .indexOf("Cancel by 6pm local time 24 hours prior to avoid no-show billing.") == -1)) {
135: TestCase
136: .fail("Cannot find strings according to chosen WebService in response");
137: return false;
138: }
139: } catch (Exception e) {
140: System.out.println("Exception occured: ");
141: e.printStackTrace();
142: TestCase.fail("Exception in HTTP check : " + e);
143: return false;
144: }
145: return true;
146: }
147:
148: /**
149: * Check "Intro" project.
150: * @param checkURL Project's URL.
151: * @return True if project works well, in other way retuirn false.
152: */
153: public static boolean httpVerifyIntro(String checkURL) {
154: try {
155: WebConversation conversation = new WebConversation();
156: WebResponse response = null;
157: response = conversation.getResponse(checkURL);
158: com.meterware.httpunit.WebForm addContainer = response
159: .getForms()[0];
160: WebRequest request = addContainer.getRequest();
161: System.out.println("Response text : " + response.getText());
162: addContainer.setParameter("form1:dropdown1", "Chen, Larry");
163: response = conversation.getResponse(request);
164: SubmitButton btn = addContainer.getSubmitButtons()[0];
165: response = addContainer.submit(btn);
166: addContainer = response.getForms()[0];
167: System.out.println("Response text after page commit: "
168: + response.getText());
169: if ((response.getText()).indexOf("Hello, Larry!") == -1) {
170: TestCase
171: .fail("Cannot find \" Hello, Larry! \" string in response after submit");
172: return false;
173: }
174: } catch (Exception e) {
175: System.out.println("Exception occured: ");
176: e.printStackTrace();
177: TestCase.fail("Exception in HTTP check : " + e);
178: return false;
179: }
180: return true;
181: }
182:
183: /**
184: * Check project with validaton.
185: * @param checkURL Project's URL.
186: * @return True if project works well, in other way retuirn false.
187: */
188: public static boolean httpVerifyValidation(String checkURL) {
189: try {
190: WebConversation conversation = new WebConversation();
191: WebResponse response = null;
192: response = conversation.getResponse(checkURL);
193: WebForm addContainer = response.getForms()[0];
194: WebRequest request = addContainer.getRequest();
195: System.out
196: .println("Set textField value = 500, expected result = 932");
197: addContainer.setParameter("form1:textField1", "500");
198: response = conversation.getResponse(request);
199: System.out.println("Response text after 1st page commit: "
200: + response.getText());
201: if ((response.getText()).indexOf("932") == -1) {
202: TestCase
203: .fail("Cannot find value \"932:\" string in response");
204: return false;
205: }
206: TestUtils.wait(5000);
207: addContainer = response.getForms()[0];
208: request = addContainer.getRequest();
209: System.out
210: .println("Set textField value = -1000, expected result = Validation Error");
211: addContainer.setParameter("form1:textField1", "-1000");
212: response = conversation.getResponse(request);
213: System.out.println("Response text after 2st page commit: "
214: + response.getText());
215: if ((response.getText()).indexOf("Validation Error") == -1) {
216: TestCase
217: .fail("Cannot find \"Validation Error:\" string in response");
218: return false;
219: }
220: } catch (Exception e) {
221: System.out.println("Exception occured: ");
222: e.printStackTrace();
223: TestCase.fail("Exception in HTTP check : " + e);
224: return false;
225: }
226: return true;
227: }
228:
229: /**
230: * Check project with dynamic navigation.
231: * @param checkURL Project's URL.
232: * @return True if project works well, in other way retuirn false.
233: */
234: public static boolean httpVerifyDynamicNavigation(String checkURL) {
235: try {
236: WebConversation conversation = new WebConversation();
237: WebResponse response = null;
238: response = conversation.getResponse(checkURL);
239: WebForm addContainer = response.getForms()[0];
240: addContainer
241: .setParameter("form1:dropdown1", "Emerald City");
242: SubmitButton btn = addContainer.getSubmitButtons()[0];
243: response = addContainer.submit(btn);
244: System.out.println("Response text after form1 submit: "
245: + response.getText());
246: if (!response.getTitle().equals("Page2 Title")) {
247: TestCase
248: .fail("Wrong webform responce after WebForm1 submit action");
249: return false;
250: }
251: addContainer = response.getForms()[0];
252: btn = addContainer.getSubmitButtons()[0];
253: response = addContainer.submit(btn);
254: System.out.println("Response text after 1 form2 submit: "
255: + response.getText());
256: if (response.getTitle().equals("Page1 Title")) {
257: TestCase
258: .fail("Wrong webform responce after WebForm2 first submit action");
259: return false;
260: }
261: response = addContainer.submit(btn);
262: System.out.println("Response text after 2 Page2 submit: "
263: + response.getText());
264: response = addContainer.submit(btn);
265: System.out.println("Response text after 3 Page2 submit: "
266: + response.getText());
267:
268: if (!response.getTitle().equals("Page1 Title")) {
269: TestCase
270: .fail("Wrong page responce after Page2 third submit action");
271: return false;
272: }
273: } catch (Exception e) {
274: System.out.println("Exception occured: ");
275: e.printStackTrace();
276: TestCase.fail("Excetion in HTTP check : " + e);
277: return false;
278: }
279: return true;
280: }
281:
282: /**
283: * Check project which send email.
284: * @param checkURL Project's URL.
285: * @return True if project works well, in other way retuirn false.
286: */
287: public static boolean httpVerifyEmail(String checkURL) {
288: try {
289: WebConversation conversation = new WebConversation();
290: WebResponse response = null;
291: response = conversation.getResponse(checkURL);
292: WebForm addContainer = response.getForms()[0];
293: addContainer.setParameter("form1:txtComments",
294: "Hello world!");
295: TestUtils.wait(2000);
296: SubmitButton btn = addContainer.getSubmitButtons()[0];
297: response = addContainer.submit(btn);
298: TestUtils.wait(2000);
299: System.out.println("Response text after page commit: "
300: + response.getText());
301: if ((response.getText())
302: .indexOf("Your comments have been successfully sent") == -1) {
303: TestCase
304: .fail("Cannot find \"Your comments have been successfully sent\" string in response");
305: return false;
306: }
307: } catch (Exception e) {
308: System.out.println("Exception occured: ");
309: e.printStackTrace();
310: System.out
311: .println("Check your mail settings, it can be cause of failing.");
312: TestCase.fail("Excetion in HTTP check : " + e);
313: return false;
314: }
315: return true;
316: }
317:
318: /**
319: * Check project which DB access.
320: * @param checkURL Project's URL.
321: * @return True if project works well, in other way retuirn false.
322: */
323: public static boolean httpVerifyDBAccess(String checkURL) {
324: try {
325: String webOutput;
326: WebConversation conversation = new WebConversation();
327: WebResponse response = null;
328: response = conversation.getResponse(checkURL); //
329: WebForm addContainer = response.getForms()[0];
330: addContainer.setParameter("form1:dropdown1", "2");
331: TestUtils.wait(5000);
332: WebRequest request = addContainer.getRequest();
333: TestUtils.wait(5000);
334: response = conversation.getResponse(request);
335: webOutput = response.getText();
336: System.out.println("Response text : " + webOutput);
337: } catch (Exception e) {
338: System.out.println("Exception occured: ");
339: e.printStackTrace();
340: TestCase.fail("Exception in HTTP check : " + e);
341: return false;
342: }
343: return true;
344: }
345:
346: /**
347: * Check project with number converter.
348: * @param checkURL Project's URL.
349: * @return True if project works well, in other way retuirn false.
350: */
351: public static boolean httpVerifyNumberConverter(String checkURL) {
352: try {
353: WebConversation conversation = new WebConversation();
354: WebResponse response = null;
355: response = conversation.getResponse(checkURL);
356: WebForm addContainer = response.getForms()[0];
357: SubmitButton btn = addContainer.getSubmitButtons()[0];
358: System.out
359: .println("Set textField value = 125, expected result = class.java.Long");
360: addContainer.setParameter("form1:textField1", "125");
361: response = addContainer.submit(btn);
362: System.out.println("Response text after 1st page commit: "
363: + response.getText());
364: if ((response.getText()).indexOf("java.lang.Long") == -1) {
365: TestCase
366: .fail("Cannot find value \"java.lang.Long\" string in response");
367: return false;
368: }
369: TestUtils.wait(5000);
370: addContainer = response.getForms()[0];
371: btn = addContainer.getSubmitButtons()[0];
372: System.out
373: .println("Set textField value = 125.3, expected result = class.java.Double");
374: addContainer.setParameter("form1:textField1", "125.3");
375: response = addContainer.submit(btn);
376: System.out.println("Response text after 2st page commit: "
377: + response.getText());
378: if ((response.getText()).indexOf("java.lang.Double") == -1) {
379: TestCase
380: .fail("Cannot find \"java.lang.Double\" string in response");
381: return false;
382: }
383: } catch (Exception e) {
384: System.out.println("Exception occured: ");
385: e.printStackTrace();
386: TestCase.fail("Exception in HTTP check : " + e);
387: return false;
388: }
389: return true;
390: }
391:
392: /**
393: * Check project with currency converter.
394: * @param checkURL Project's URL.
395: * @return True if project works well, in other way retuirn false.
396: */
397: public static boolean httpVerifyCurrencyConverter(String checkURL) {
398: try {
399: WebConversation conversation = new WebConversation();
400: WebResponse response = null;
401: response = conversation.getResponse(checkURL);
402: WebForm addContainer = response.getForms()[0];
403: SubmitButton btn = addContainer.getSubmitButtons()[0];
404: System.out.println("Set textField value = $1,234.00");
405: addContainer.setParameter("form1:textField1", "$1,234.00");
406: response = addContainer.submit(btn);
407: System.out.println("Response text after 1st page commit: "
408: + response.getText());
409: if (((response.getText()).indexOf("£822.67") == -1)
410: || ((response.getText()).indexOf("E 1.028,33") == -1)) {
411: TestCase
412: .fail("Cannot find value \"£822.67\" or \"E 1.028,33\" string in response");
413: return false;
414: }
415: } catch (Exception e) {
416: System.out.println("Exception occured: ");
417: e.printStackTrace();
418: TestCase.fail("Exception in HTTP check : " + e);
419: return false;
420: }
421: return true;
422: }
423:
424: /**
425: * Check project with date converter.
426: * @param checkURL Project's URL.
427: * @return True if project works well, in other way retuirn false.
428: */
429: public static boolean httpVerifyDateConverter(String checkURL) {
430: try {
431: WebConversation conversation = new WebConversation();
432: WebResponse response = null;
433: response = conversation.getResponse(checkURL);
434: WebForm addContainer = response.getForms()[0];
435: SubmitButton btn = addContainer.getSubmitButtons()[0];
436: response = addContainer.submit(btn);
437: System.out.println("Response text after 1st page commit: "
438: + response.getText());
439: if (((response.getText()).indexOf("Greenwich Mean Time") == -1)
440: || ((response.getText()).indexOf("GMT") == -1)
441: || (((response.getText())
442: .indexOf("Pacific Daylight Time") == -1) && ((response
443: .getText())
444: .indexOf("Pacific Standard Time") == -1))) {
445: TestCase
446: .fail("Cannot find date time strings in response");
447: return false;
448: }
449: } catch (Exception e) {
450: System.out.println("Exception occured: ");
451: e.printStackTrace();
452: TestCase.fail("Exception in HTTP check : " + e);
453: return false;
454: }
455: return true;
456: }
457:
458: /**
459: * Check project with "List" component.
460: * @param checkURL Project's URL.
461: * @return True if project works well, in other way retuirn false.
462: */
463: public static boolean httpVerifyList(String checkURL) {
464: try {
465: WebConversation conversation = new WebConversation();
466: WebResponse response = null;
467: response = conversation.getResponse(checkURL);
468: com.meterware.httpunit.WebForm addContainer = response
469: .getForms()[0];
470: System.out.println("Response : " + response.getText());
471: String[] valArray = { "choice1", "choice2" };
472: addContainer.setParameter("form1:multiSelectListbox1",
473: valArray);
474: SubmitButton btm = addContainer
475: .getSubmitButton("form1:button1");
476: response = addContainer.submit(btm);
477: addContainer = response.getForms()[0];
478: System.out.println("Response text after page commit: "
479: + response.getText());
480: if ((response.getText())
481: .indexOf("Values chosen:\nchoice1\nchoice2") == -1) {
482: TestCase
483: .fail("Cannot find result string in response after submit");
484: return false;
485: }
486: TestUtils.wait(5000);
487: btm = addContainer.getSubmitButton("form1:button2");
488: TestUtils.wait(3000);
489: response = addContainer.submit(btm);
490: TestUtils.wait(3000);
491: addContainer = response.getForms()[0];
492: btm = addContainer.getSubmitButton("form1:button2");
493: response = addContainer.submit(btm);
494: TestUtils.wait(3000);
495: addContainer = response.getForms()[0];
496: TestUtils.wait(3000);
497: System.out.println("Response text after 1 page commit: "
498: + response.getText());
499: String[] valArray1 = { "testChoice5", "testChoice6" };
500: addContainer.setParameter("form1:multiSelectListbox1",
501: valArray1);
502: btm = addContainer.getSubmitButton("form1:button1");
503: response = addContainer.submit(btm);
504: addContainer = response.getForms()[0];
505: System.out.println("Response text after 2 page commit: "
506: + response.getText());
507: if ((response.getText())
508: .indexOf("Values chosen:\ntestChoice5\ntestChoice6") == -1) {
509: TestCase
510: .fail("Cannot find result string in response after submit");
511: return false;
512: }
513: TestUtils.wait(5000);
514: btm = addContainer.getSubmitButton("form1:button3");
515: TestUtils.wait(3000);
516: response = addContainer.submit(btm);
517: TestUtils.wait(3000);
518: addContainer = response.getForms()[0];
519: System.out.println("Response text after 3 page commit: "
520: + response.getText());
521: if (((response.getText()).indexOf("testChoice5") != -1)
522: || ((response.getText()).indexOf("testChoice6") != -1)) {
523: TestCase
524: .fail("Wrong list items left after removing in response after submit");
525: return false;
526: }
527: } catch (Exception e) {
528: System.out.println("Exception occured: ");
529: e.printStackTrace();
530: TestCase.fail("Excetion in HTTP check : " + e);
531: return false;
532: }
533: return true;
534: }
535:
536: /**
537: * Check project with property binding.
538: * @param checkURL Project's URL.
539: * @return True if project works well, in other way retuirn false.
540: */
541: public static boolean httpVerifyLinking(String checkURL) {
542: try {
543: WebConversation conversation = new WebConversation();
544: WebResponse response = null;
545: response = conversation.getResponse(checkURL);
546: WebForm addContainer = response.getForms()[0];
547: WebRequest request = addContainer.getRequest();
548: System.out.println("Response text : " + response.getText());
549: addContainer.setParameter("form1:dropdown1", "Chen, Larry");
550: response = conversation.getResponse(request);
551: SubmitButton btn = addContainer.getSubmitButtons()[0];
552: response = addContainer.submit(btn);
553: addContainer = response.getForms()[0];
554: System.out.println("Response text after page commit: "
555: + response.getText());
556: if ((response.getText()).indexOf("Hello, Larry!") == -1) {
557: TestCase
558: .fail("Cannot find \" Hello, Larry! \" string in response after submit");
559: return false;
560: }
561: } catch (Exception e) {
562: System.out.println("Exception occured: ");
563: e.printStackTrace();
564: TestCase.fail("Exception in HTTP check : " + e);
565: return false;
566: }
567: return true;
568: }
569:
570: /**
571: * Check project with ancillary library.
572: * @param checkURL Project's URL.
573: * @return True if project works well, in other way retuirn false.
574: */
575: public static boolean httpVerifyLibrary(String checkURL) {
576: try {
577: WebConversation conversation = new WebConversation();
578: WebResponse response = null;
579: response = conversation.getResponse(checkURL);
580: com.meterware.httpunit.WebForm addContainer = response
581: .getForms()[0];
582: System.out.println("Response : " + response.getText());
583: if ((response.getText()).indexOf("Hello, world.") == -1) {
584: TestCase
585: .fail("Cannot find \"Hello, world.\" string in response.");
586: return false;
587: }
588: } catch (Exception e) {
589: System.out.println("Exception occured: " + e);
590: e.printStackTrace();
591: TestCase.fail("Exception in HTTP check : " + e);
592: return false;
593: }
594: return true;
595: }
596:
597: /**
598: * Check project with "Message" component.
599: * @param checkURL Project's URL.
600: * @return True if project works well, in other way retuirn false.
601: */
602: public static boolean httpVerifyMessage(String checkURL) {
603: try {
604: WebConversation conversation = new WebConversation();
605: WebResponse response = null;
606: response = conversation.getResponse(checkURL);
607: WebForm addContainer = response.getForms()[0];
608: WebRequest request = addContainer.getRequest();
609: System.out.println("Response text : " + response.getText());
610: SubmitButton btn = addContainer.getSubmitButtons()[0];
611: response = addContainer.submit(btn);
612: addContainer = response.getForms()[0];
613: System.out.println("Response text after page commit: "
614: + response.getText());
615: if ((response.getText())
616: .indexOf("Validation Error: Value is required.") == -1
617: || (response.getText())
618: .indexOf("Validation Error: Value is required.") == -1) {
619: TestCase
620: .fail("Cannot find \"Validation Error: Value is required.\" string in response after submit");
621: return false;
622: }
623: TestUtils.wait(1000);
624: addContainer.setParameter("form1:textField1", "abc");
625: addContainer.setParameter("form1:textField2", "abc");
626: btn = addContainer.getSubmitButtons()[0];
627: response = addContainer.submit(btn);
628: addContainer = response.getForms()[0];
629: System.out.println("Response text after page commit: "
630: + response.getText());
631: if ((response.getText())
632: .indexOf("Conversion error occurred.") == -1) {
633: TestCase
634: .fail("Cannot find \"Conversion error occurred.\" string in response after submit");
635: return false;
636: }
637: TestUtils.wait(1000);
638: addContainer.setParameter("form1:textField1", "10");
639: addContainer.setParameter("form1:textField2", "abc");
640: btn = addContainer.getSubmitButtons()[0];
641: response = addContainer.submit(btn);
642: addContainer = response.getForms()[0];
643: System.out.println("Response text after page commit: "
644: + response.getText());
645: if ((response.getText())
646: .indexOf("Validation Error: Specified attribute is not between the expected values of 1 and 5.") == -1) {
647: TestCase
648: .fail("Cannot find \"Validation Error: Specified attribute is not between the expected values of 1 and 5.\" string in response after submit");
649: return false;
650: }
651: TestUtils.wait(1000);
652: addContainer.setParameter("form1:textField1", "4");
653: addContainer.setParameter("form1:textField2", "abc");
654: btn = addContainer.getSubmitButtons()[0];
655: response = addContainer.submit(btn);
656: addContainer = response.getForms()[0];
657: System.out.println("Response text after page commit: "
658: + response.getText());
659: if ((response.getText())
660: .indexOf("Form Message: Processing Complete.") == -1) {
661: TestCase
662: .fail("Cannot find \"Form Message: Processing Complete.\" string in response after submit");
663: return false;
664: }
665: } catch (Exception e) {
666: System.out.println("Exception occured: ");
667: e.printStackTrace();
668: TestCase.fail("Exception in HTTP check : " + e);
669: return false;
670: }
671: return true;
672: }
673:
674: /**
675: * Check CRUD project.
676: * @param checkURL Project's URL.
677: * @return True if project works well, in other way retuirn false.
678: */
679: public static boolean httpVerifyCRUD(String checkURL) {
680: try {
681: WebConversation conversation = new WebConversation();
682: WebResponse response = conversation.getResponse(checkURL);
683: System.out.println("Start page: " + response.getText());
684: WebForm form = response.getForms()[0];
685: SubmitButton addBtn = (SubmitButton) form
686: .getButtonWithID("form1:addTrip");
687: response = form.submit(addBtn);
688: System.out.println("Details screen for add = "
689: + response.getText());
690: form = response.getForms()[0];
691: form.setParameter("form1:depDate", "16.06.2004 0:23:09");
692: form.setParameter("form1:fromCity", "Hobbiton");
693: form.setParameter("form1:toCity", "Rivendell");
694: form.setParameter("form1:tripTypeId", "3");
695: SubmitButton saveBtn = (SubmitButton) form
696: .getButtonWithID("form1:save");
697: response = form.submit(saveBtn);
698: System.out.println("After adding travel: "
699: + response.getText());
700: form = response.getForms()[0];
701: SubmitButton updateBtn = (SubmitButton) form
702: .getButtonWithID("form1:dataTable1:0:update");
703: response = form.submit(updateBtn);
704: System.out.println("Details screen for update = "
705: + response.getText());
706: form = response.getForms()[0];
707: form.setParameter("form1:depDate", "16.07.2004 0:23:09");
708: form.setParameter("form1:fromCity", "Rivendell");
709: form.setParameter("form1:toCity", "Orodruin");
710: form.setParameter("form1:tripTypeId", "4");
711: saveBtn = (SubmitButton) form.getButtonWithID("form1:save");
712: response = form.submit(saveBtn);
713: System.out.println("After updating travel: "
714: + response.getText());
715: form = response.getForms()[0];
716: SubmitButton deleteBtn = (SubmitButton) form
717: .getButtonWithID("form1:dataTable1:0:delete");
718: response = form.submit(deleteBtn);
719: } catch (Exception e) {
720: System.out.println("Exception occured: ");
721: e.printStackTrace();
722: TestCase.fail("Exception in HTTP check : " + e);
723: return false;
724: }
725: return true;
726: }
727: }
|