This project has retired. For details please refer to its
Attic page.
API_051_BindingTemplateWSDLTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.api.impl;
16
17 import java.net.MalformedURLException;
18 import java.rmi.RemoteException;
19 import java.util.Properties;
20
21 import javax.wsdl.Definition;
22 import javax.wsdl.WSDLException;
23
24 import org.apache.commons.configuration.ConfigurationException;
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.juddi.Registry;
28 import org.apache.juddi.jaxb.PrintUDDI;
29 import org.apache.juddi.v3.client.config.UDDIClerk;
30 import org.apache.juddi.v3.client.config.UDDIClient;
31 import org.apache.juddi.v3.client.mapping.URLLocalizer;
32 import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl;
33 import org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL;
34 import org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI;
35 import org.apache.juddi.v3.client.transport.TransportException;
36 import org.apache.juddi.v3.tck.TckBusiness;
37 import org.apache.juddi.v3.tck.TckPublisher;
38 import org.apache.juddi.v3.tck.TckSecurity;
39 import org.apache.juddi.v3.tck.TckTModel;
40 import org.junit.AfterClass;
41 import org.junit.Assert;
42 import org.junit.BeforeClass;
43 import org.junit.Test;
44 import org.uddi.api_v3.FindTModel;
45 import org.uddi.v3_service.UDDISecurityPortType;
46
47
48
49
50
51 public class API_051_BindingTemplateWSDLTest
52 {
53 private static Log logger = LogFactory.getLog(API_051_BindingTemplateWSDLTest.class);
54
55 private static API_010_PublisherTest api010 = new API_010_PublisherTest();
56 private static TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl());
57 private static TckBusiness tckBusiness = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl());
58
59 private static String authInfoJoe = null;
60
61 @BeforeClass
62 public static void setup() throws ConfigurationException {
63 Registry.start();
64 logger.info("API_051_BindingTemplateWSDLTest");
65 logger.debug("Getting auth token..");
66 try {
67 api010.saveJoePublisher();
68 authInfoJoe = TckSecurity.getAuthToken(new UDDISecurityImpl(), TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
69 UDDISecurityPortType security = new UDDISecurityImpl();
70 String authInfoUDDI = TckSecurity.getAuthToken(security, TckPublisher.getUDDIPublisherId(), TckPublisher.getUDDIPassword());
71 tckTModel.saveUDDIPublisherTmodel(authInfoUDDI);
72 tckTModel.saveTModels(authInfoUDDI, TckTModel.TMODELS_XML);
73 } catch (RemoteException e) {
74 logger.error(e.getMessage(), e);
75 Assert.fail("Could not obtain authInfo token.");
76 }
77 }
78
79 @AfterClass
80 public static void stopRegistry() throws ConfigurationException {
81 tckTModel.deleteCreatedTModels(authInfoJoe);
82 Registry.stop();
83 }
84
85 @Test
86 public void testDirectCall() throws ConfigurationException, WSDLException, RemoteException, TransportException, MalformedURLException, Exception {
87 try {
88 tckTModel.saveJoePublisherTmodel(authInfoJoe);
89 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
90
91 UDDIClerk clerk = new UDDIClient("META-INF/uddi.xml").getClerk("joe");
92 Properties properties = clerk.getUDDINode().getProperties();
93 URLLocalizer urlLocalizer = new URLLocalizerDefaultImpl();
94
95
96 Definition wsdlDefinition = new ReadWSDL().readWSDL("wsdl/sample.wsdl");
97
98 properties.put("keyDomain", "uddi.joepublisher.com");
99 properties.put(org.apache.juddi.v3.client.config.Property.BUSINESS_KEY, "uddi:uddi.joepublisher.com:businessone");
100 properties.put("nodeName", "api.example.org_80");
101 WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(clerk, urlLocalizer, properties);
102
103 wsdl2UDDI.registerBusinessServices(wsdlDefinition);
104
105
106 String portTypeName = "StockQuotePortType";
107 String namespace = "http://example.com/stockquote/";
108 FindTModel findTModelForPortType = WSDL2UDDI.createFindPortTypeTModelForPortType(portTypeName, namespace);
109 System.out.println(new PrintUDDI<FindTModel>().print(findTModelForPortType));
110
111 wsdl2UDDI.unRegisterBusinessServices(wsdlDefinition);
112 } finally {
113 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
114 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
115 }
116 }
117
118 @Test
119 public void testClerkCall() throws ConfigurationException, WSDLException, RemoteException, TransportException, MalformedURLException {
120 try {
121 tckTModel.saveJoePublisherTmodel(authInfoJoe);
122 tckBusiness.saveJoePublisherBusiness(authInfoJoe);
123
124 UDDIClerk clerk = new UDDIClient("META-INF/uddi.xml").getClerk("joe");
125 clerk.registerWsdls();
126
127
128 String portTypeName = "StockQuotePortType";
129 String namespace = "http://example.com/stockquote/";
130 FindTModel findTModelForPortType = WSDL2UDDI.createFindPortTypeTModelForPortType(portTypeName, namespace);
131 System.out.println(new PrintUDDI<FindTModel>().print(findTModelForPortType));
132
133 clerk.unRegisterWsdls();
134 } catch (Exception e) {
135 e.printStackTrace();
136 Assert.fail();
137 } finally {
138 tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
139 tckTModel.deleteJoePublisherTmodel(authInfoJoe);
140 }
141 }
142
143
144 }