1 25 26 package org.objectweb.jonas.examples.clients.cmp2; 27 28 import junit.framework.TestSuite; 29 30 import org.objectweb.jonas.examples.util.JExampleTestCase; 31 32 import com.meterware.httpunit.WebForm; 33 import com.meterware.httpunit.WebResponse; 34 35 40 public class F_Cmp2 extends JExampleTestCase { 41 42 45 private static final String URL_EARCMP2 = "/cmp2"; 46 47 51 public static void main(String [] args) { 52 53 String testtorun = null; 54 for (int argn = 0; argn < args.length; argn++) { 56 String sArg = args[argn]; 57 if (sArg.equals("-n")) { 58 testtorun = args[++argn]; 59 } 60 } 61 62 if (testtorun == null) { 63 junit.textui.TestRunner.run(suite()); 64 } else { 65 junit.textui.TestRunner.run(new F_Cmp2(testtorun)); 66 } 67 } 68 69 73 public static TestSuite suite() { 74 return new TestSuite(F_Cmp2.class); 75 } 76 77 82 protected void setUp() throws Exception { 83 super.setUp(); 84 useEar("cmp2"); 85 } 86 87 91 public F_Cmp2(String s) { 92 super(s, URL_EARCMP2); 93 } 94 95 99 public void testFirstServlet() throws Exception { 100 101 WebResponse wr = wc.getResponse(url); 102 103 WebForm[] webForms = wr.getForms(); 104 WebForm webForm = webForms[0]; 105 assertNotNull("There must be a form in the html page", webForm); 106 WebResponse wFormRes = webForm.submit(); 107 String txt = wFormRes.getText(); 108 if (txt.indexOf("<strong>Servlet is OK.</strong>") == -1) { 109 fail("The example was not ok : " + txt); 110 } 111 } 112 113 114 118 public void testSecondServlet() throws Exception { 119 120 WebResponse wr = wc.getResponse(url); 121 122 WebForm[] webForms = wr.getForms(); 123 WebForm webForm = webForms[1]; 124 assertNotNull("There must be a form in the html page", webForm); 125 WebResponse wFormRes = webForm.submit(); 126 String txt = wFormRes.getText(); 127 if (txt.indexOf("<strong>Servlet is OK.</strong>") == -1) { 128 fail("The example was not ok : " + txt); 129 } 130 } 131 132 136 public void testThirdServlet() throws Exception { 137 138 WebResponse wr = wc.getResponse(url); 139 140 WebForm[] webForms = wr.getForms(); 141 WebForm webForm = webForms[2]; 142 assertNotNull("There must be a form in the html page", webForm); 143 WebResponse wFormRes = webForm.submit(); 144 String txt = wFormRes.getText(); 145 if (txt.indexOf("<strong>Servlet is OK.</strong>") == -1) { 146 fail("The example was not ok : " + txt); 147 } 148 } 149 150 } 151 | Popular Tags |