1 2 11 12 package com.jaspersoft.jasperserver.war; 13 14 import com.meterware.httpunit.*; 15 16 import junit.framework.*; 17 18 23 public class HttpUnitReportMgmtTest 24 extends HttpUnitBaseTestCase { 25 private static String reptMgmtPageUrl = JasperServerConstants.BASE_URL + 26 "/jasperserver/reportmgmt.html"; 27 private static String repMgmtLink = "AllAccounts"; 28 private static String repNameText = "txRepName"; 29 private static String repPageText = "SEARCH"; 30 private static String repDetFormName = "fmRptDtls"; 31 private static String repDetText1 = "AllAccounts"; 32 private static String repDetText2 = "sub-JRXML-01 in Repository"; 33 private static String crRepImgText = "/jasperserver/images/create_button.gif"; 34 35 protected static WebResponse retResponse; 36 37 42 public HttpUnitReportMgmtTest(String s) { 43 super(s); 44 } 45 46 51 public void setUp() 52 throws Exception { 53 wResponse = commonLoginFunction(reptMgmtPageUrl); 54 } 55 56 57 61 62 69 public void testReptMgmtPage() 70 throws Exception { 71 WebResponse reportMgmt = this.getWebConversation().getCurrentPage(); 72 73 assertNotNull("Report Management response is Null", reportMgmt); 74 75 assertNotNull("Report Management element is Null", 77 reportMgmt.getElementsWithName(repNameText)); 78 79 83 String page = reportMgmt.getText(); 84 85 if ((page == null) || (page.trim().length() == 0)) { 86 fail("No text fond in response"); 87 } 88 89 assertTrue(page.indexOf("Name:") != -1); 90 91 WebImage image = reportMgmt.getImageWithSource(crRepImgText); 92 assertNotNull("Image is present", image); 93 94 } 95 96 105 public void testReptDetlPage() 106 throws Exception { 107 WebResponse reportMgmt = this.getWebConversation().getCurrentPage(); 109 assertNotNull("Report Detail response is Null", reportMgmt); 110 111 WebLink link = reportMgmt.getLinkWith(repMgmtLink); 112 link.click(); 113 114 WebResponse reportDetail = this.getWebConversation().getCurrentPage(); 116 117 String string = reportDetail.getText(); 118 119 if ((string == null) || (string.trim().length() == 0)) { 120 fail("No text found in response"); 121 } 122 123 assertTrue((string.indexOf(repDetText1) != -1) && 124 (string.indexOf(repDetText2) != -1)); 125 126 WebForm repDetForm = reportDetail.getFormWithName(repDetFormName); 127 repDetForm.getScriptableObject().setParameterValue("repdtlsaction", "torepmgmt"); 128 repDetForm.submit(); 129 130 131 WebResponse bkRepMgmt = this.getWebConversation().getCurrentPage(); 132 133 String str = bkRepMgmt.getText(); 134 135 if ((str == null) || (str.trim().length() == 0)) { 136 fail("No text found in response"); 137 } 138 139 assertTrue(str.indexOf(repPageText) != -1); 140 } 141 142 143 147 148 149 152 protected String [] getloginCredentials() { 153 return new String [] { USERNAME, PASSWORD }; 154 } 155 156 157 161 162 167 public static void main(String [] args) { 168 try { 169 junit.textui.TestRunner.run(suite()); 170 } catch (Exception _ex) { 171 _ex.printStackTrace(); 172 } 173 } 174 175 182 public static Test suite() 183 throws Exception { 184 TestSuite suite = new TestSuite(); 185 186 TestCase test1 = new HttpUnitReportMgmtTest("testReptMgmtPage"); 187 TestCase test2 = new HttpUnitReportMgmtTest("testReptDetlPage"); 188 189 suite.addTest(test1); 190 return suite; 192 } 193 } 194 | Popular Tags |