1 21 package com.jaspersoft.jasperserver.war.wizard; 22 23 import java.io.File ; 24 25 import com.jaspersoft.jasperserver.war.HttpUnitBaseTestCase; 26 import com.meterware.httpunit.SubmitButton; 27 import com.meterware.httpunit.UploadFileSpec; 28 import com.meterware.httpunit.WebForm; 29 import com.meterware.httpunit.WebLink; 30 import com.meterware.httpunit.WebResponse; 31 32 33 37 public abstract class AbstractHttpWizardBaseFlow 38 extends HttpUnitBaseTestCase 39 implements WizardScreenConstants { 40 private static WebForm repNamingForm; 41 private static WebForm loadPageForm; 42 private static SubmitButton nextButton; 43 private static SubmitButton backButton; 44 private static WebForm loadJRXMLForm; 45 private static String resourcePath; 46 private static WebForm repositoryForm; 47 private static SubmitButton addNewButton; 48 private static WebForm pageForm; 49 50 55 public AbstractHttpWizardBaseFlow(String s) { 56 super(s); 57 resourceMap.put("Jrxml1", "AllAccounts.jrxml"); 58 resourceMap.put("Jrxml2", "SalesByMonth.jrxml"); 59 resourceMap.put("Jrxml3", "SalesByMonthDetail.jrxml"); 60 resourceMap.put("Img1", "logo.jpg"); 61 resourceMap.put("Img2", "report.jpg"); 62 resourceMap.put("text", "test.txt"); 63 resourcePath = getClass().getClassLoader().getResource("SalesByMonth.jrxml").getPath(); 64 } 65 66 71 public void setUp() 72 throws Exception { 73 wResponse = commonLoginFunction(homePageUrl); 74 75 } 76 77 78 79 83 84 85 86 protected void runWizardFlow(TestAttribute attrb) 87 throws Exception { 88 89 checkRepositoryPage(); 91 checkRepNamingPage(attrb); 93 checkLoadFilePage(attrb); 95 checkSelectSourcePage(); 97 checkDataSourcepage(attrb); 99 checkDataDescriptionPage(attrb); 101 checkPublishPage(); 103 } 104 105 106 private void checkRepositoryPage() throws Exception { 108 assertNotNull(" Home Page Response is Null ", wResponse); 110 111 WebLink link = wResponse.getLinkWith(repositoryLink); 113 assertNotNull(repositoryLink +"Link is Null ", link); 114 115 wResponse = link.click(); 116 117 assertNotNull("Link element is not on the page",wResponse.getElementsWithName(rootLink)); 119 120 String opt = wResponse.getText(); 122 assertNotNull("page text is Null ", opt); 123 124 if ((opt == null) || (opt.trim().length() == 0)) { 125 fail("Text not found in response"); 126 } 127 128 assertTrue((opt.indexOf(repositoryPageText1) != -1) && (opt.indexOf(repositoryPageText2) != -1)); 129 130 repositoryForm = wResponse.getFormWithName(repFormText); 132 assertNotNull("Form text is Null ", repositoryForm); 133 134 addNewButton = repositoryForm.getSubmitButton(addNewBtnText); 135 assertNotNull("Button text is Null ", addNewButton); 136 137 repositoryForm.setParameter("cmbResourceType",repositoryUnitValueText); 138 139 wResponse = repositoryForm.submit(addNewButton); 140 141 String str = wResponse.getText(); 142 assertNotNull("page text is Null ", str); 143 144 if ((str == null) || (str.trim().length() == 0)) { 145 fail("Text not found in response"); 146 } 147 148 assertTrue((str.indexOf(createReportPageText) != -1)); 149 } 150 151 152 protected void checkRepNamingPage(TestAttribute attrb) 154 throws Exception { 155 assertNotNull(" Home Page Response is Null ", wResponse); 156 157 assertNotNull("No text field on the page", wResponse.getElementsWithName(nameText)); 159 160 String string = wResponse.getText(); 162 assertNotNull("page text is Null ", string); 163 164 if ((string == null) || (string.trim().length() == 0)) { 165 fail("There is no text in response"); 166 } 167 168 assertTrue((string.indexOf(pageText) != -1)); 169 170 repNamingForm = wResponse.getFormWithName(repNameFormText); 172 assertNotNull("Form text is Null ", repNamingForm); 173 174 SubmitButton cancelButton = repNamingForm.getSubmitButton(cancelBtnText); 175 assertNotNull("Button text is Null ", cancelButton); 176 177 wResponse = repNamingForm.submit(cancelButton); 178 179 String report = wResponse.getText(); 180 assertNotNull("page text is Null ", report); 181 182 if ((report == null) || (report.trim().length() == 0)) { 183 fail("There is no text in response"); 184 } 185 186 assertTrue(report.indexOf(ViewReportPageText) != -1); 187 188 repositoryForm = wResponse.getFormWithName(repFormText); 189 assertNotNull("Form text is Null ", repositoryForm); 190 191 addNewButton = repositoryForm.getSubmitButton(addNewBtnText); 192 assertNotNull("Button text is Null ", addNewButton); 193 194 repositoryForm.setParameter("cmbResourceType",repositoryUnitValueText); 195 196 wResponse = repositoryForm.submit(addNewButton); 197 198 String wizard = wResponse.getText(); 199 assertNotNull("page text is Null ", wizard); 200 201 if ((wizard == null) || (wizard.trim().length() == 0)) { 202 fail("there is no text on response"); 203 } 204 205 assertTrue(wizard.indexOf(pageText) != -1); 206 207 checkNxtBtnForRepNamingPage(attrb); 208 } 209 210 211 private void checkNxtBtnForRepNamingPage(TestAttribute attrb) 213 throws Exception { 214 assertNotNull(" Report Naming Page Response is Null ", wResponse); 215 216 repNamingForm = wResponse.getFormWithName(repNameFormText); 217 assertNotNull("Form text is Null ", repNamingForm); 218 219 nextButton = repNamingForm.getSubmitButton(nextBtnText); 220 assertNotNull("Button text is Null ", nextButton); 221 222 assertNotNull(" Report Naming Page Response is Null ", wResponse); 224 225 assertNotNull(" FORM object is null ", repNamingForm); 226 227 nextButton = repNamingForm.getSubmitButton(nextBtnText); 228 assertNotNull(" Next button is null ", nextButton); 229 230 wResponse = repNamingForm.submit(nextButton); 231 232 String str = wResponse.getText(); 233 assertNotNull("page text is Null ", str); 234 235 if ((str == null) || (str.trim().length() == 0)) { 236 fail(" there is no text on response "); 237 } 238 239 assertTrue((str.indexOf(errorMsgRepPageText1) != -1) && 240 (str.indexOf(errorMsgRepPageText2) != -1)); 241 242 244 repNamingForm.setParameter("reportUnit.name", attrb.getReportName()); 245 repNamingForm.setParameter("reportUnit.label", attrb.getLabel()); 246 247 wResponse = repNamingForm.submit(nextButton); 248 249 String nextPage = wResponse.getText(); 250 assertNotNull("page text is Null ", nextPage); 251 252 if ((nextPage == null) || (nextPage.trim().length() == 0)) { 253 fail(" there is no text on response "); 254 } 255 assertTrue(nextPage.indexOf(loadPageText1) != -1); 256 } 257 258 259 protected void checkLoadFilePage(TestAttribute attrb) 261 throws Exception { 262 assertNotNull(" Report Naming Page Response is Null ", wResponse); 263 264 assertNotNull("No text field on the page", wResponse.getElementsWithName(fileFieldText)); 266 267 String string = wResponse.getText(); 269 assertNotNull("page text is Null ", string); 270 271 if ((string == null) || (string.trim().length() == 0)) { 272 fail(" There is no text on response "); 273 } 274 275 assertTrue((string.indexOf(loadPageText1) != -1)); 276 277 loadJRXMLForm = wResponse.getFormWithName(formText); 279 backButton = loadJRXMLForm.getSubmitButton(backBtnText); 280 281 wResponse = loadJRXMLForm.submit(backButton); 282 283 String str = wResponse.getText(); 284 assertNotNull("page text is Null ", str); 285 286 if ((str == null) || (str.trim().length() == 0)) { 287 fail("There is no text in response"); 288 } 289 290 assertTrue(str.indexOf("Description") != -1); 291 292 repNamingForm = wResponse.getFormWithName(repNameFormText); 293 assertNotNull("Form text is Null ", repNamingForm); 294 295 nextButton = repNamingForm.getSubmitButton(nextBtnText); 296 assertNotNull("Button text is Null ", nextButton); 297 298 wResponse = repNamingForm.submit(nextButton); 299 300 String str1 = wResponse.getText(); 301 assertNotNull("page text is Null ", str1); 302 303 if ((str1 == null) || (str1.trim().length() == 0)) { 304 fail("There is no text in response"); 305 } 306 307 assertTrue(str1.indexOf(loadPageText1) != -1); 308 309 checkNxtBtnForLoadFilePage(attrb); 310 } 311 312 313 private void checkNxtBtnForLoadFilePage(TestAttribute attrb) 315 throws Exception { 316 317 assertNotNull(" Load File Page Response is Null ", wResponse); 318 319 loadPageForm = wResponse.getFormWithName(formText); 320 assertNotNull("Form text is Null ", loadPageForm); 321 322 loadPageForm = wResponse.getFormWithName(formText); 324 assertNotNull("Form text is Null ", loadPageForm); 325 326 nextButton = loadPageForm.getSubmitButton(nextBtnText); 327 assertNotNull("Button text is Null ", nextButton); 328 329 wResponse = loadPageForm.submit(nextButton); 330 331 String error = wResponse.getText(); 332 assertNotNull("page text is Null ", error); 333 334 if ((error == null) || (error.trim().length() == 0)) { 335 fail("There is no text in response"); 336 } 337 338 assertTrue(error.indexOf(errorMsgLoadPageText) != -1); 339 340 SubmitButton nextButton2 = loadPageForm.getSubmitButton(nextBtnText); 342 File jrxml = new File (getJrxmlFileResourceURL(attrb.getJrxml())); 343 UploadFileSpec[] uploadFile = new UploadFileSpec[] { new UploadFileSpec(jrxml) }; 344 loadPageForm.setParameter("jrxmlData", uploadFile); 345 346 wResponse = loadPageForm.submit(nextButton2); 347 348 String page = wResponse.getText(); 349 assertNotNull("page text is Null ", page); 350 351 if ((page == null) || (page.trim().length() == 0)) { 352 fail("There is no text in response"); 353 } 354 355 assertTrue(page.indexOf(reportListPageText) != -1); 356 357 358 360 Description description = new Description(); 362 description.setFileName("newFile"+String.valueOf((int)(Math.random()*1000))); 363 description.setFileLabel("newLink"); 364 description.setFileDescription("This is new file"); 365 366 wResponse = addControl(wResponse, description); 367 368 String text1 = wResponse.getText(); 369 assertNotNull("page text is Null ", text1); 370 371 if ((text1 == null) || (text1.trim().length() == 0)) { 372 fail("There is no text in response"); 373 } 374 375 assertTrue(text1.indexOf(addControlPageText) != -1); 376 377 378 380 Description description2 = new Description(); 382 description2.setFileName("ResourceFile"+String.valueOf((int)(Math.random()*1000))); 383 description2.setFileLabel("ResourceLink"); 384 description2.setFileDescription("This is new Resource File"); 385 386 wResponse = addResource(wResponse,description2, getFileResourceURLByType("Img2")); 387 388 String text2 = wResponse.getText(); 389 assertNotNull("page text is Null ", text2); 390 391 if ((text2 == null) || (text2.trim().length() == 0)) { 392 fail("There is no text in response"); 393 } 394 395 assertTrue(text2.indexOf(resourceFileText) != -1); 396 397 String str = wResponse.getText(); 398 assertNotNull("page text is Null ", str); 399 400 if(str.indexOf("LogoLink") != -1){ 402 403 wResponse = addNowDetails(wResponse, getFileResourceURLByType("Img2")); 404 405 String text3 = wResponse.getText(); 406 assertNotNull("page text is Null ", text3); 407 408 if ((text3 == null) || (text3.trim().length() == 0)) { 409 fail("There is no text in response"); 410 } 411 412 assertTrue(text3.indexOf(fileAddedText) != -1); 413 414 415 wResponse = addNowDetails(wResponse, getFileResourceURLByType("Img1")); 416 417 String text4 = wResponse.getText(); 418 assertNotNull("page text is Null ", text4); 419 420 if ((text4 == null) || (text4.trim().length() == 0)) { 421 fail("There is no text in response"); 422 } 423 424 assertTrue(text4.indexOf(fileAddedText) != -1); 425 }else{ 426 wResponse = addNowDetails(wResponse, getFileResourceURLByType("Jrxml3")); 427 428 String text5 = wResponse.getText(); 429 430 if ((text5 == null) || (text5.trim().length() == 0)) { 431 fail("There is no text in response"); 432 } 433 434 assertTrue(text5.indexOf(fileAddedText) != -1); 435 436 437 wResponse = addNowDetails(wResponse, getFileResourceURLByType("Img1")); 438 439 String text6 = wResponse.getText(); 440 441 if ((text6 == null) || (text6.trim().length() == 0)) { 442 fail("There is no text in response"); 443 } 444 445 assertTrue(text6.indexOf(fileAddedText) != -1); 446 } 447 448 pageForm = wResponse.getFormWithName(listPageFormText); 450 assertNotNull("Form is Null ", pageForm); 451 452 nextButton = pageForm.getSubmitButton(nextBtnText); 453 assertNotNull("button is Null ", nextButton); 454 455 wResponse = pageForm.submit(nextButton); 456 457 String string = wResponse.getText(); 458 assertNotNull("page text is Null ", string); 459 460 if ((string == null) || (string.trim().length() == 0)) { 461 fail("There is no text on response"); 462 } 463 464 assertTrue(string.indexOf(sourceSelectionPageText) != -1); 465 } 466 467 468 public void checkSelectSourcePage() 470 throws Exception { 471 assertNotNull("Upload Success Page Response is Null ", wResponse); 472 473 WebForm sourceSellectionForm = wResponse.getFormWithName(sourceSellFormText); 474 assertNotNull("Form is Null ", sourceSellectionForm); 475 476 SubmitButton backButton = sourceSellectionForm.getSubmitButton(backBtnText); 478 assertNotNull("Form is Null ", backButton); 479 480 wResponse = sourceSellectionForm.submit(backButton); 481 482 loadPageForm = wResponse.getFormWithName(listPageFormText); 483 nextButton = loadPageForm.getSubmitButton(nextBtnText); 484 485 wResponse = loadPageForm.submit(nextButton); 486 487 String next = wResponse.getText(); 488 assertNotNull("page text is Null ", next); 489 490 if ((next == null) || (next.trim().length() == 0)) { 491 fail("There is no text in response"); 492 } 493 494 assertTrue(next.indexOf(sourceSelectionPageText) != -1); 495 496 WebForm sourceSelectionForm2 = wResponse.getFormWithName(sourceSellFormText); 498 nextButton = sourceSelectionForm2.getSubmitButton(nextBtnText); 499 500 sourceSelectionForm2.setParameter("source", "LOCAL"); 501 sourceSelectionForm2.setParameter("selectedUri", "/datasources/JServerJNDIDS"); 502 503 wResponse = sourceSelectionForm2.submit(nextButton); 504 505 String str = wResponse.getText(); 506 assertNotNull("page text is Null ", str); 507 508 if ((str == null) || (str.trim().length() == 0)) { 509 fail("There is no text in response"); 510 } 511 512 assertTrue(str.indexOf(dataSrcPageText1) != -1); 513 } 514 515 516 public void checkDataSourcepage(TestAttribute attrb) 518 throws Exception { 519 assertNotNull(" Load File Page Response is Null ", wResponse); 520 521 String str = wResponse.getText(); 523 assertNotNull("page text is Null ", str); 524 525 if ((str == null) || (str.trim().length() == 0)) { 526 fail("There is no text on response"); 527 } 528 529 assertTrue((str.indexOf(dataSrcPageText1) != -1)); 530 531 WebForm dataSrcForm = wResponse.getFormWithName(dataSrcPageFormText); 532 assertNotNull("Form is Null ", dataSrcForm); 533 534 nextButton = dataSrcForm.getSubmitButton(nextBtnText); 535 assertNotNull("Form is Null ", nextButton); 536 537 dataSrcForm.setParameter("type", attrb.getDataSourceAttrb().getDataSourceType()); 538 wResponse = dataSrcForm.submit(nextButton); 539 } 540 541 542 public void checkDataDescriptionPage(TestAttribute attrb) 544 throws Exception { 545 assertNotNull(" Data Source Page Response is Null ", wResponse); 546 547 String string = wResponse.getText(); 548 assertNotNull("page text is Null ", string); 549 550 if (string.indexOf("JDBC") != -1) { 551 assertNotNull(" Data Source Page Response is Null ", wResponse); 552 553 WebForm propertyForm1 = wResponse.getFormWithName("fmCRValidConf"); 555 nextButton = propertyForm1.getSubmitButton(nextBtnText); 556 557 wResponse = propertyForm1.submit(nextButton); 558 559 String opt = wResponse.getText(); 560 561 if ((opt == null) || (opt.trim().length() == 0)) { 562 fail("There is no text on the page"); 563 } 564 565 assertTrue((opt.indexOf(errMsgText2) != -1) && 566 (opt.indexOf(errorMsgText3) != -1)); 567 568 propertyForm1.setParameter("reportDataSource.name", attrb.getDataSourceAttrb().getName()); 570 propertyForm1.setParameter("reportDataSource.label", attrb.getDataSourceAttrb().getLabel()); 571 572 propertyForm1.setParameter("reportDataSource.driverClass", attrb.getDataSourceAttrb().getDriver()); 573 propertyForm1.setParameter("reportDataSource.connectionUrl", attrb.getDataSourceAttrb().getUrl()); 574 propertyForm1.setParameter("reportDataSource.username", attrb.getDataSourceAttrb().getUsername()); 575 propertyForm1.setParameter("reportDataSource.password", attrb.getDataSourceAttrb().getPassword()); 576 577 wResponse = propertyForm1.submit(nextButton); 578 } else { 579 assertNotNull(" Data Source Page Response is Null ", wResponse); 580 581 WebForm propertyForm2 = wResponse.getFormWithName(propertyPageFormText); 583 nextButton = propertyForm2.getSubmitButton(nextBtnText); 584 585 wResponse = propertyForm2.submit(nextButton); 586 587 String str = wResponse.getText(); 588 589 if ((str == null) || (str.trim().length() == 0)) { 590 fail("There is no text on the page"); 591 } 592 593 assertTrue((str.indexOf(errMsgServiceNameText1) != -1) && 594 (str.indexOf(errMsgText2) != -1)); 595 596 propertyForm2.setParameter("reportDataSource.name", attrb.getDataSourceAttrb().getName()); 598 propertyForm2.setParameter("reportDataSource.label", attrb.getDataSourceAttrb().getLabel()); 599 propertyForm2.setParameter("reportDataSource.jndiName", attrb.getDataSourceAttrb().getServiceName()); 600 601 wResponse = propertyForm2.submit(nextButton); 602 } 603 604 String page = wResponse.getText(); 605 assertNotNull("page text is Null ", page); 606 if ((page == null) || (page.trim().length() == 0)) { 607 fail("There is no text on the page"); 608 } 609 610 assertTrue(page.indexOf(validationPageText) != -1); 611 } 612 613 614 public void checkPublishPage() 616 throws Exception { 617 assertNotNull(" Data Source Description Page Response is Null ", wResponse); 618 619 WebForm extResourceForm = wResponse.getFormWithName(testFormText); 620 assertNotNull("Form is Null ", extResourceForm); 621 622 SubmitButton saveButton = extResourceForm.getSubmitButton(saveSelectedBtnText); 623 assertNotNull("Form is Null ", saveButton); 624 625 wResponse = extResourceForm.submit(saveButton); 626 627 String string = wResponse.getText(); 628 assertNotNull("page text is Null ", string); 629 630 if ((string == null) || (string.trim().length() == 0)) { 631 fail("There is no text on the page"); 632 } 633 634 assertTrue(string.indexOf(ViewReportPageText) != -1); 635 } 636 637 638 639 643 644 645 650 protected String getFileResourceByType(String type) { 651 return (String )resourceMap.get(type); 652 653 } 654 655 660 private String getJrxmlFileResourceURL(String jrxml) { 661 return getClass().getClassLoader().getResource(jrxml).getPath(); 663 } 664 665 672 private String getFileResourceURLByType(String type) { 673 return getClass().getClassLoader().getResource((String )resourceMap.get(type)).getPath(); 675 } 676 677 678 679 683 684 685 695 public WebResponse addControl(WebResponse webResponse, 696 Description description) 697 throws Exception { 698 699 assertNotNull("List Report Detail page response is Null",webResponse); 700 701 String str = webResponse.getText(); 702 703 if ((str == null) || (str.trim().length() == 0)) { 704 fail("There is no text on response"); 705 } 706 707 assertTrue(str.indexOf(reportListPageText) != -1); 708 709 pageForm = webResponse.getFormWithName(listPageFormText); 710 assertNotNull("Form is Null ", pageForm); 711 712 SubmitButton addControlBtn = pageForm.getSubmitButton(addCtrlBtnText); 713 assertNotNull("Button is Null ", addControlBtn); 714 715 webResponse = pageForm.submit(addControlBtn); 716 717 String text = webResponse.getText(); 718 assertNotNull("page text is Null ", text); 719 720 if(text == null || text.trim().length()==0) 721 fail("There is no text on page"); 722 723 assertTrue(text.indexOf(locateInputControlText)!= -1); 724 725 WebForm locateInputForm = webResponse.getFormWithName(datadescFormText); 726 assertNotNull("Form is Null ", locateInputForm); 727 728 nextButton = locateInputForm.getSubmitButton(nextBtnText); 729 assertNotNull("button is Null ", nextButton); 730 731 locateInputForm.setParameter("inputControlSource","LOCAL"); 732 733 webResponse = locateInputForm.submit(nextButton); 734 735 String string = webResponse.getText(); 736 assertNotNull("page text is Null ", string); 737 738 if(string == null || string.trim().length()==0) 739 fail("There is no text on page"); 740 741 assertTrue(string.indexOf(reportInputControlText)!= -1); 742 743 744 WebForm descriptionForm = webResponse.getFormWithName(descriptionFormText); 745 assertNotNull("Form is Null ", descriptionForm); 746 747 nextButton = descriptionForm.getSubmitButton(nextBtnText); 748 assertNotNull("button is Null ", nextButton); 749 750 descriptionForm.setParameter("inputControl.name",description.getFileName()); 751 descriptionForm.setParameter("inputControl.label",description.getFileLabel()); 752 753 webResponse = descriptionForm.submit(nextButton); 754 755 WebForm dataTypeForm = webResponse.getFormWithName(datadescFormText); 756 assertNotNull("Form is Null ", dataTypeForm); 757 758 nextButton = dataTypeForm.getSubmitButton(nextBtnText); 759 assertNotNull("button is Null ", nextButton); 760 761 dataTypeForm.setParameter("source","LOCAL"); 762 763 webResponse = dataTypeForm.submit(nextButton); 764 765 String page = webResponse.getText(); 766 assertNotNull("page text is Null ", page); 767 768 if(page == null || page.trim().length()==0) 769 fail("There is no text on page"); 770 771 assertTrue(page.indexOf(dataTypePageText)!= -1); 772 773 WebForm dataDescForm = webResponse.getFormWithName(dataTypeFormText); 774 assertNotNull("Form is Null ", dataDescForm); 775 776 SubmitButton saveButton = dataDescForm.getSubmitButton(savetBtnText); 777 assertNotNull("button is Null ", saveButton); 778 779 dataDescForm.setParameter("dataType.name",description.getFileName()); 780 dataDescForm.setParameter("dataType.label",description.getFileLabel()); 781 782 webResponse = dataDescForm.submit(saveButton); 783 784 return webResponse; 785 } 786 787 788 789 800 public WebResponse addResource(WebResponse webResponse, 801 Description description, 802 String fileLocation) 803 throws Exception { 804 805 assertNotNull("List Report Detail page response is Null",webResponse); 806 807 pageForm = webResponse.getFormWithName(listPageFormText); 808 809 SubmitButton addResourceBtn = pageForm.getSubmitButton(addResourceBtnText); 810 811 webResponse = pageForm.submit(addResourceBtn); 812 813 String string = webResponse.getText(); 814 815 if(string == null || string.trim().length()==0) 816 fail("There is no text on page"); 817 818 assertTrue(string.indexOf(reportFileResPageText)!= -1); 819 820 WebForm loadPageForm = webResponse.getFormWithName(formText); 821 822 SubmitButton nextButton = loadPageForm.getSubmitButton(nextBtnText); 823 824 File file1 = new File (fileLocation); 825 UploadFileSpec[] uploadFile = new UploadFileSpec[] { new UploadFileSpec(file1) }; 826 827 loadPageForm.setParameter("source", "FILE_SYSTEM"); 828 loadPageForm.setParameter("newData", uploadFile); 829 830 webResponse = loadPageForm.submit(nextButton); 831 832 String str = webResponse.getText(); 833 if(str==null || str.trim().length()==0) 834 fail("There is no text on the page"); 835 836 assertTrue(str.indexOf(fileResourcePageText)!= -1); 837 838 WebForm rescDescForm = webResponse.getFormWithName(resDescriptiomFormText); 839 840 nextButton = rescDescForm.getSubmitButton(nextBtnText); 841 842 rescDescForm.setParameter("fileResource.name",description.getFileName()); 843 rescDescForm.setParameter("fileResource.label",description.getFileLabel()); 844 rescDescForm.setParameter("fileResource.description",description.getFileDescription()); 845 846 webResponse = rescDescForm.submit(nextButton); 847 848 return webResponse; 849 850 } 851 852 853 864 public WebResponse addNowDetails(WebResponse wResponse, 865 String fileLocation) 866 throws Exception { 867 assertNotNull(" Load File Page Response is Null ", wResponse); 868 869 String str = wResponse.getText(); 870 871 if ((str == null) || (str.trim().length() == 0)) { 872 fail("There is no text on response"); 873 } 874 875 assertTrue(str.indexOf(reportListPageText) != -1); 876 877 pageForm = wResponse.getFormWithName(listPageFormText); 878 879 WebLink addNowLink = wResponse.getLinkWith("Add Now"); 880 881 wResponse = addNowLink.click(); 882 883 String string = wResponse.getText(); 884 if ((string == null) || (string.trim().length() == 0)) { 885 fail("There is no text on response"); 886 } 887 888 assertTrue(string.indexOf(reportFileResPageText) != -1); 889 890 891 WebForm form1 = wResponse.getFormWithName(formText); 892 893 nextButton = form1.getSubmitButton(nextBtnText); 894 895 File file = new File (fileLocation); 896 UploadFileSpec[] uploadFile1 = new UploadFileSpec[] { new UploadFileSpec(file) }; 897 898 form1.setParameter("source", "FILE_SYSTEM"); 899 form1.setParameter("newData", uploadFile1); 900 901 wResponse = form1.submit(nextButton); 902 903 String string2 = wResponse.getText(); 904 905 if ((string2 == null) || (string2.trim().length() == 0)) { 906 fail("There is no text on response"); 907 } 908 909 assertTrue(string2.indexOf(fileResourcePageText) != -1); 910 911 WebForm descriptionForm = wResponse.getFormWithName(resDescriptiomFormText); 912 nextButton = descriptionForm.getSubmitButton(nextBtnText); 913 wResponse = descriptionForm.submit(nextButton); 914 915 return wResponse; 916 } 917 918 922 public class Description { 923 private String fileName; 924 private String fileLabel; 925 private String fileDescription; 926 private String fileType; 927 928 public Description() { 929 super(); 930 } 931 932 public Description(String name, 933 String label, 934 String description, 935 String type) { 936 super(); 937 this.fileName = name; 938 this.fileLabel = label; 939 this.fileDescription = description; 940 this.fileType = type; 941 } 942 943 public String getFileDescription() { 944 return fileDescription; 945 } 946 947 public void setFileDescription(String fileDescription) { 948 this.fileDescription = fileDescription; 949 } 950 951 public String getFileLabel() { 952 return fileLabel; 953 } 954 955 public void setFileLabel(String fileLabel) { 956 this.fileLabel = fileLabel; 957 } 958 959 public String getFileName() { 960 return fileName; 961 } 962 963 public void setFileName(String fileName) { 964 this.fileName = fileName; 965 } 966 967 public String getFileType() { 968 return fileType; 969 } 970 971 public void setFileType(String fileType) { 972 this.fileType = fileType; 973 } 974 } 975 976 } 977 | Popular Tags |