| 1 package org.objectweb.celtix.systest.basicDOCBare; 2 3 import java.lang.annotation.Annotation ; 4 import java.lang.reflect.Method ; 5 import java.net.URL ; 6 7 import javax.jws.WebMethod; 8 import javax.jws.WebParam; 9 import javax.xml.namespace.QName ; 10 12 import javax.xml.ws.Holder; 13 14 import junit.framework.Test; 15 import junit.framework.TestSuite; 16 17 import org.objectweb.celtix.systest.common.ClientServerSetupBase; 18 import org.objectweb.celtix.systest.common.ClientServerTestBase; 19 20 import org.objectweb.hello_world_doc_lit_bare.PutLastTradedPricePortType; 21 import org.objectweb.hello_world_doc_lit_bare.SOAPService; 22 import org.objectweb.hello_world_doc_lit_bare.types.TradePriceData; 23 24 public class DOCBareClientServerTest extends ClientServerTestBase { 25 26 private final QName serviceName = new QName ("http://objectweb.org/hello_world_doc_lit_bare", 27 "SOAPService"); 28 private final QName portName = new QName ("http://objectweb.org/hello_world_doc_lit_bare", "SoapPort"); 29 30 public static Test suite() throws Exception { 31 TestSuite suite = new TestSuite(DOCBareClientServerTest.class); 32 return new ClientServerSetupBase(suite) { 33 public void startServers() throws Exception { 34 assertTrue("server did not launch correctly", launchServer(Server.class)); 35 } 36 }; 37 } 38 39 public void testBasicConnection() throws Exception { 40 URL wsdl = getClass().getResource("/wsdl/doc_lit_bare.wsdl"); 41 assertNotNull("WSDL is null", wsdl); 42 43 SOAPService service = new SOAPService(wsdl, serviceName); 44 assertNotNull("Service is ull ", service); 45 46 PutLastTradedPricePortType putLastTradedPrice = service.getPort(portName, 47 PutLastTradedPricePortType.class); 48 TradePriceData priceData = new TradePriceData(); 49 priceData.setTickerPrice(1.0f); 50 priceData.setTickerSymbol("CELTIX"); 51 52 Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData); 53 54 for (int i = 0; i < 5; i++) { 55 putLastTradedPrice.sayHi(holder); 56 assertEquals(4.5f, holder.value.getTickerPrice()); 57 assertEquals("OBJECTWEB", holder.value.getTickerSymbol()); 58 putLastTradedPrice.putLastTradedPrice(priceData); 59 } 60 61 } 62 63 public void testAnnotation() throws Exception { 64 Class claz = PutLastTradedPricePortType.class; 65 TradePriceData priceData = new TradePriceData(); 66 Holder<TradePriceData> holder = new Holder<TradePriceData>(priceData); 67 Method method = claz.getMethod("sayHi", holder.getClass()); 68 assertNotNull("Can not find SayHi method in generated class ", method); 69 Annotation ann = method.getAnnotation(WebMethod.class); 70 WebMethod webMethod = (WebMethod)ann; 71 assertEquals(webMethod.operationName(), "SayHi"); 72 Annotation [][] paraAnns = method.getParameterAnnotations(); 73 for (Annotation [] paraType : paraAnns) { 74 for (Annotation an : paraType) { 75 if (an.annotationType() == WebParam.class) { 76 WebParam webParam = (WebParam)an; 77 assertNotSame("", webParam.targetNamespace()); 78 } 79 } 80 } 81 } 82 83 public static void main(String [] args) { 84 junit.textui.TestRunner.run(DOCBareClientServerTest.class); 85 } 86 87 96 97 } 98 | Popular Tags |