1 25 26 package org.objectweb.jonas.jonasadmin.test.monitoring; 27 28 import junit.framework.TestSuite; 29 30 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminAuth; 31 import org.objectweb.jonas.jonasadmin.test.util.JonasAdminTestCase; 32 33 import com.meterware.httpunit.HttpUnitOptions; 34 import com.meterware.httpunit.TableCell; 35 import com.meterware.httpunit.WebConversation; 36 import com.meterware.httpunit.WebForm; 37 import com.meterware.httpunit.WebLink; 38 import com.meterware.httpunit.WebResponse; 39 40 41 47 public class F_JonasAdminActivatedMonitoring extends JonasAdminTestCase { 48 49 52 private static final String URL_JONASADMIN_MONITORING = "/jonasAdmin/EditMonitoring.do"; 53 54 55 59 public F_JonasAdminActivatedMonitoring(String s) { 60 super(s, URL_JONASADMIN); 61 } 62 63 68 public F_JonasAdminActivatedMonitoring(WebConversation wc, String s) { 69 super(wc, s, URL_JONASADMIN); 70 } 71 72 76 public static void main(String [] args) { 77 78 String testtorun = null; 79 for (int argn = 0; argn < args.length; argn++) { 81 String sArg = args[argn]; 82 if (sArg.equals("-n")) { 83 testtorun = args[++argn]; 84 } 85 } 86 if (testtorun == null) { 87 junit.textui.TestRunner.run(suite()); 88 } else { 89 junit.textui.TestRunner.run(new F_JonasAdminActivatedMonitoring(testtorun)); 90 } 91 } 92 93 97 public static TestSuite suite() { 98 return new TestSuite(F_JonasAdminActivatedMonitoring.class); 99 } 100 101 106 public static TestSuite suite(WebConversation wc) { 107 TestSuite suite = new TestSuite(); 108 suite.addTest(new F_JonasAdminActivatedMonitoring(wc, "testMonitoringActivation")); 109 return suite; 110 } 111 112 117 protected void setUp() throws Exception { 118 super.setUp(); 119 120 if (wc.getCurrentPage().getURL() == null) { 121 useWar("jonasAdmin"); 122 try { 124 JonasAdminAuth.doValidAuth(wc, url); 125 } catch (Exception e) { 126 fail("authentification failed : " + e); 127 } 128 } else { 129 try { 131 wc.getFrameContents(FRAME_TREE); 132 } catch (Exception e) { 133 wc.getResponse(urlLogOut); 134 try { 136 JonasAdminAuth.doValidAuth(wc, url); 137 } catch (Exception auth) { 138 fail("authentification failed : " + auth); 139 } 140 } 141 } 142 } 143 144 148 public void testMonitoringActivation() throws Exception { 149 150 HttpUnitOptions.setExceptionsThrownOnScriptError(false); 152 HttpUnitOptions.setExceptionsThrownOnErrorStatus(false); 154 155 WebResponse wr = wc.getResponse(getAbsoluteUrl(URL_JONASADMIN_MONITORING)); 157 WebForm[] webForms = wr.getForms(); 158 WebForm webForm = webForms[0]; 159 160 webForm.setCheckbox("activated", "on", false); 162 163 wr = webForm.submit(); 164 assertEquals("there is more one tab. ", -1, wr.getText().indexOf("class=\"tab\"")); 165 166 wr = wc.getResponse(getAbsoluteUrl(URL_JONASADMIN)); 168 wr = wc.getResponse(getAbsoluteUrl(URL_JONASADMIN_MONITORING)); 169 assertEquals("there is more one tab. ", -1, wr.getText().indexOf("class=\"tab\"")); 170 171 172 webForms = wr.getForms(); 174 webForm = webForms[0]; 175 webForm.setCheckbox("activated", "on", true); 176 177 wr = webForm.submit(); 178 assertFalse("there is not at least two tabs. ", wr.getText().indexOf("class=\"tab\"") == -1); 179 180 TableCell cell = wr.getTables()[0].getTableCell(0, 0).getTables()[0].getTableCell(0, 2); 182 String attribut; 183 WebLink[] links; 184 185 attribut = cell.getAttribute("class"); 186 assertEquals("the tab is not in the wanted cell. ", "tab", attribut); 187 links = cell.getLinks(); 188 assertNotNull("there is no link", links); 189 assertEquals("link is not \"/jonasAdmin/EditMemory.do\"", "/jonasAdmin/EditMemory.do", links[0].getAttribute("href")); 190 191 wr = wc.getResponse(getAbsoluteUrl(URL_JONASADMIN)); 193 wr = wc.getResponse(getAbsoluteUrl(URL_JONASADMIN_MONITORING)); 194 assertFalse("there is not at least two tabs. ", wr.getText().indexOf("class=\"tab\"") == -1); 195 } 196 } 197 | Popular Tags |