1 25 26 package org.objectweb.jonas.jtests.clients.service; 27 28 import org.objectweb.jonas.jtests.util.JWebServicesTestCase; 29 30 import junit.framework.Test; 31 import junit.framework.TestSuite; 32 33 import com.meterware.httpunit.*; 34 35 39 public class F_PortComponentLink extends JWebServicesTestCase { 40 41 protected static final String CONTEXT = "/portlink/"; 42 43 public F_PortComponentLink(String name) { 44 super(name, CONTEXT); 45 } 46 47 public static Test suite() { 48 return new TestSuite(F_PortComponentLink.class); 49 } 50 51 public void setUp() throws Exception { 52 super.setUp(); 53 useEar("port-component-link"); 54 } 55 56 public void tearDown() throws Exception { 57 super.tearDown(); 58 } 59 60 public void testConfiguration() throws Exception { 61 WebResponse wr = wc.getResponse(url + "index.jsp"); 62 63 WebLink loc = wr.getLinkWithID("location"); 65 assertNotNull(loc); 66 String link = loc.asText(); 67 String url = "http://localhost:" 68 + System.getProperty("http.port") 69 + "/endpoint/AddressBookPort/AddressBookPort"; 70 int index = link.indexOf(url); 71 System.out.println("expected URL :" + url); 72 System.out.println("current URL :" + link); 73 assertTrue("endpoint not updated", -1 != index); 74 75 WebLink stub = wr.getLinkWithID("stub"); 77 assertNotNull("no stub", stub); 78 link = stub.asText(); 79 index = link.indexOf("'true'"); 80 assertTrue("stub not returned", -1 != index); 81 82 } 83 84 public void testResults() throws Exception { 85 WebResponse wr = wc.getResponse(url + "index.jsp"); 86 87 WebLink type = wr.getLinkWithID("classname"); 89 assertNotNull(type); 90 String link = type.asText(); 91 int index = link.indexOf("org.objectweb.jonas.jtests.servlets.portlink.Address"); 92 assertTrue("bad return type", -1 != index); 93 94 WebLink get = wr.getLinkWithID("get"); 96 assertNotNull(get); 97 link = get.asText(); 98 index = link.indexOf("name : 'JOnAS'"); 99 assertTrue("bad name returned", -1 != index); 100 index = link.indexOf("company : 'ObjectWeb Consortium'"); 101 assertTrue("bad company returned", -1 != index); 102 index = link.indexOf("version : '4.0'"); 103 assertTrue("bad version returned", -1 != index); 104 105 WebLink getAll = wr.getLinkWithID("getAll"); 107 assertNotNull(getAll); 108 link = getAll.asText(); 109 index = link.indexOf("getAddresses() length : 2"); 110 assertTrue("bad length", -1 != index); 111 112 WebLink pres = wr.getLinkWithID("present"); 114 assertNotNull(pres); 115 link = pres.asText(); 116 index = link.indexOf("isPresent(\"JOnAS-Team\") : 'true'"); 117 assertTrue("JOnAS Team not found", -1 != index); 118 119 } 120 121 public static void main (String args[]) { 122 String testtorun = null; 123 for (int argn = 0; argn < args.length; argn++) { 125 String s_arg = args[argn]; 126 if (s_arg.equals("-n")) { 127 testtorun = args[++argn]; 128 } 129 } 130 if (testtorun == null) { 131 junit.textui.TestRunner.run(suite()); 132 } else { 133 junit.textui.TestRunner.run(new F_PortComponentLink(testtorun)); 134 } 135 } 136 137 } 138 | Popular Tags |