001: package org.objectweb.celtix.systest.basicDOCBare;
002:
003: import java.lang.annotation.Annotation;
004: import java.lang.reflect.Method;
005: import java.net.URL;
006:
007: import javax.jws.WebMethod;
008: import javax.jws.WebParam;
009: import javax.xml.namespace.QName; // import javax.xml.ws.AsyncHandler;
010:
011: import javax.xml.ws.Holder;
012:
013: import junit.framework.Test;
014: import junit.framework.TestSuite;
015:
016: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
017: import org.objectweb.celtix.systest.common.ClientServerTestBase;
018:
019: import org.objectweb.hello_world_doc_lit_bare.PutLastTradedPricePortType;
020: import org.objectweb.hello_world_doc_lit_bare.SOAPService;
021: import org.objectweb.hello_world_doc_lit_bare.types.TradePriceData;
022:
023: public class DOCBareClientServerTest extends ClientServerTestBase {
024:
025: private final QName serviceName = new QName(
026: "http://objectweb.org/hello_world_doc_lit_bare",
027: "SOAPService");
028: private final QName portName = new QName(
029: "http://objectweb.org/hello_world_doc_lit_bare", "SoapPort");
030:
031: public static Test suite() throws Exception {
032: TestSuite suite = new TestSuite(DOCBareClientServerTest.class);
033: return new ClientServerSetupBase(suite) {
034: public void startServers() throws Exception {
035: assertTrue("server did not launch correctly",
036: launchServer(Server.class));
037: }
038: };
039: }
040:
041: public void testBasicConnection() throws Exception {
042: URL wsdl = getClass().getResource("/wsdl/doc_lit_bare.wsdl");
043: assertNotNull("WSDL is null", wsdl);
044:
045: SOAPService service = new SOAPService(wsdl, serviceName);
046: assertNotNull("Service is ull ", service);
047:
048: PutLastTradedPricePortType putLastTradedPrice = service
049: .getPort(portName, PutLastTradedPricePortType.class);
050: TradePriceData priceData = new TradePriceData();
051: priceData.setTickerPrice(1.0f);
052: priceData.setTickerSymbol("CELTIX");
053:
054: Holder<TradePriceData> holder = new Holder<TradePriceData>(
055: priceData);
056:
057: for (int i = 0; i < 5; i++) {
058: putLastTradedPrice.sayHi(holder);
059: assertEquals(4.5f, holder.value.getTickerPrice());
060: assertEquals("OBJECTWEB", holder.value.getTickerSymbol());
061: putLastTradedPrice.putLastTradedPrice(priceData);
062: }
063:
064: }
065:
066: public void testAnnotation() throws Exception {
067: Class claz = PutLastTradedPricePortType.class;
068: TradePriceData priceData = new TradePriceData();
069: Holder<TradePriceData> holder = new Holder<TradePriceData>(
070: priceData);
071: Method method = claz.getMethod("sayHi", holder.getClass());
072: assertNotNull("Can not find SayHi method in generated class ",
073: method);
074: Annotation ann = method.getAnnotation(WebMethod.class);
075: WebMethod webMethod = (WebMethod) ann;
076: assertEquals(webMethod.operationName(), "SayHi");
077: Annotation[][] paraAnns = method.getParameterAnnotations();
078: for (Annotation[] paraType : paraAnns) {
079: for (Annotation an : paraType) {
080: if (an.annotationType() == WebParam.class) {
081: WebParam webParam = (WebParam) an;
082: assertNotSame("", webParam.targetNamespace());
083: }
084: }
085: }
086: }
087:
088: public static void main(String[] args) {
089: junit.textui.TestRunner.run(DOCBareClientServerTest.class);
090: }
091:
092: /*
093: * public static void main(String[] args) { ClientServerTest cst = new
094: * ClientServerTest(); if ("client".equals(args[0])) { try {
095: * cst.testAsyncPollingCall(); } catch (Exception ex) {
096: * ex.printStackTrace(); } System.err.println("Exiting...........");
097: * System.exit(0); } else if ("server".equals(args[0])) { try { //
098: * cst.setUp(); cst.onetimeSetUp(); } catch (Exception ex) {
099: * ex.printStackTrace(); } } else { System.out.println("Invaid arg"); } }
100: */
101:
102: }
|