1 25 package org.objectweb.jonas.jtests.clients.endpoint; 26 27 import java.io.File ; 28 import java.util.Calendar ; 29 30 import javax.wsdl.Definition; 31 import javax.wsdl.Import; 32 import javax.wsdl.factory.WSDLFactory; 33 import javax.wsdl.xml.WSDLReader; 34 import javax.xml.namespace.QName ; 35 import javax.xml.rpc.Call ; 36 import javax.xml.rpc.Service ; 37 import javax.xml.rpc.ServiceFactory ; 38 39 import junit.framework.Test; 40 import junit.framework.TestSuite; 41 42 import org.objectweb.common.Cmd; 43 44 import org.objectweb.jonas.jtests.util.JWebServicesTestCase; 45 46 49 public class F_TimeEndpoint extends JWebServicesTestCase { 50 51 private static final String TIMEPORT_URL = "/time/TimePort/TimePort"; 52 53 56 public F_TimeEndpoint(String s) { 57 super(s); 58 } 59 60 public static Test suite() { 61 return new TestSuite(F_TimeEndpoint.class); 62 } 63 64 public void setUp() throws Exception { 65 super.setUp(); 66 67 useEar("time-test"); 68 } 69 70 public void tearDown() throws Exception { 71 super.tearDown(); 72 } 73 74 public void testTimeEndpoint() throws Exception { 75 String port = System.getProperty("http.port"); 76 77 Service service = ServiceFactory.newInstance().createService(new QName ("jonas:Time", "TimeBeanService")); 78 Call call = service.createCall(new QName ("TimePort"), new QName ("getDate")); 79 call.setTargetEndpointAddress("http://localhost:" + port + TIMEPORT_URL); 80 Calendar cal = (Calendar ) call.invoke(new Object [] {}); 81 82 assertNotNull("ServiceEndpoint performed succesfully", cal); 83 } 84 85 public void testTimeEndpointServerHandler() throws Exception { 86 String port = System.getProperty("http.port"); 87 88 Service service = ServiceFactory.newInstance().createService(new QName ("jonas:Time", "TimeBeanService")); 89 Call call = service.createCall(new QName ("TimePort"), new QName ("isHandlerInitRequestInvoked")); 90 call.setTargetEndpointAddress("http://localhost:" + port + TIMEPORT_URL); 91 Boolean b = (Boolean ) call.invoke(new Object [] {}); 92 93 assertTrue("Handler were not invoked successfully", b.booleanValue()); 94 } 95 96 public void testTimeEndpointFromAppClient() throws Exception { 97 98 String javaHomeBin = System.getProperty("java.home") + File.separator + "bin" + File.separator; 99 String jonasRoot = System.getProperty("jonas.root"); 100 String jonasBase = System.getProperty("jonasbase"); 101 102 Cmd cmd = new Cmd(javaHomeBin + "java"); 103 cmd.addArgument("-classpath"); 105 cmd.addArgument(jonasBase + File.separator + "conf" + File.pathSeparator + jonasRoot + File.separator + "lib" 106 + File.separator + "client.jar"); 107 cmd.addArgument("org.objectweb.jonas.client.ClientContainer"); 108 cmd.addArgument(jonasBase + File.separator + "apps" + File.separator + "time-test.ear"); 110 111 if (!cmd.run()) { 112 fail("Client fail see output for informations"); 113 } 114 } 115 116 117 public void testTimeEndpointURLPublication() throws Exception { 118 String port = System.getProperty("http.port"); 119 120 String url = "http://localhost:" + port + TIMEPORT_URL + "?JWSDL"; 121 WSDLFactory factory = WSDLFactory.newInstance(); 122 WSDLReader reader = factory.newWSDLReader(); 123 reader.setFeature("javax.wsdl.importDocuments", true); 124 Definition def = reader.readWSDL(url); 125 126 Import imp = (Import) def.getImports("jonas:Time").get(0); 127 assertEquals("wsdl:import[@location] not updated !", url + "&filename=Time.wsdl&context=.", imp.getLocationURI()); 128 } 129 130 } | Popular Tags |