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 HttpUnitAdminTest 24 extends HttpUnitBaseTestCase { 25 private static String admHomePageUrl = JasperServerConstants.BASE_URL + 27 "/jasperserver/admhompage.html"; 28 private static String adminPgText1 = "ADMIN HOME PAGE"; 29 private static String adminPgText2 = "NOTIFICATIONS"; 30 31 36 public HttpUnitAdminTest(String s) { 37 super(s); 38 } 39 40 45 public void setUp() 46 throws Exception { 47 wResponse = commonLoginFunction(admHomePageUrl); 48 } 49 50 51 55 56 57 64 public void testAdmHomePage() 65 throws Exception { 66 WebResponse adminPage = this.getWebConversation().getCurrentPage(); 67 assertNotNull("Admin Page Response is Null", adminPage); 68 69 String opt = adminPage.getText(); 70 71 if ((opt == null) || (opt.trim().length() == 0)) { 72 fail("Text not found in response"); 73 } 74 75 assertTrue((opt.indexOf(adminPgText1) != -1) && (opt.indexOf(adminPgText2) != -1)); 76 } 77 78 79 83 84 85 88 protected String [] getloginCredentials() { 89 return new String [] { USERNAME, PASSWORD }; 90 } 91 92 96 97 102 public static void main(String [] args) { 103 try { 104 junit.textui.TestRunner.run(suite()); 105 } catch (Exception _ex) { 106 _ex.printStackTrace(); 107 } 108 } 109 110 117 public static Test suite() 118 throws Exception { 119 TestSuite suite = new TestSuite(); 120 121 TestCase test1 = new HttpUnitAdminTest("testAdmHomePage"); 122 suite.addTest(test1); 123 124 return suite; 125 } 126 127 } 128 | Popular Tags |