This project has retired. For details please refer to its
Attic page.
BPEL_020_IntegrationTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.v3.bpel;
16
17 import java.net.MalformedURLException;
18 import java.net.URL;
19 import java.rmi.RemoteException;
20 import java.util.Iterator;
21 import java.util.Map;
22 import java.util.Properties;
23
24 import javax.wsdl.Definition;
25 import javax.wsdl.PortType;
26 import javax.wsdl.WSDLException;
27 import javax.xml.namespace.QName;
28 import javax.xml.ws.BindingProvider;
29
30 import junit.framework.Assert;
31
32 import org.apache.commons.configuration.ConfigurationException;
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35 import org.apache.juddi.v3.client.config.UDDIClerk;
36 import org.apache.juddi.v3.client.config.UDDIClient;
37 import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl;
38 import org.apache.juddi.v3.client.mapping.wsdl.BPEL2UDDI;
39 import org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL;
40 import org.apache.juddi.v3.client.transport.Transport;
41 import org.apache.juddi.v3.client.transport.TransportException;
42 import org.apache.juddi.v3.tck.TckBusiness;
43 import org.apache.juddi.v3.tck.TckBusinessService;
44 import org.apache.juddi.v3.tck.TckPublisher;
45 import org.apache.juddi.v3.tck.TckSecurity;
46 import org.apache.juddi.v3.tck.TckTModel;
47 import org.junit.After;
48 import org.junit.AfterClass;
49 import org.junit.Before;
50 import org.junit.BeforeClass;
51 import org.junit.Test;
52 import org.uddi.v3_service.UDDIInquiryPortType;
53 import org.uddi.v3_service.UDDIPublicationPortType;
54 import org.uddi.v3_service.UDDISecurityPortType;
55
56
57
58
59 public class BPEL_020_IntegrationTest {
60
61 private static Log logger = LogFactory.getLog(BPEL_010_IntegrationTest.class);
62 private static TckTModel tckTModel = null;
63 private static TckBusinessService tckService = null;
64 private static TckBusiness tckBusiness = null;
65 private static String authInfoRiftSaw = null;
66 private static UDDIClient manager;
67 static ReadWSDL rw;
68
69 @BeforeClass
70 public static void startManager() throws ConfigurationException {
71
72 logger.info("BPEL_020_IntegrationTest");
73 manager = new UDDIClient();
74 manager.start();
75
76 logger.debug("Getting auth token for user riftsaw/riftsaw..");
77 try {
78 Transport transport = manager.getTransport("uddiv3");
79
80 UDDISecurityPortType security = transport.getUDDISecurityService();
81 authInfoRiftSaw = TckSecurity.getAuthToken(security, TckPublisher.getRiftSawPublisherId(), TckPublisher.getRiftSawPassword());
82
83
84 UDDIPublicationPortType publication = transport.getUDDIPublishService();
85 UDDIInquiryPortType inquiry = transport.getUDDIInquiryService();
86 if (!TckPublisher.isUDDIAuthMode()) {
87 TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getRiftSawPublisherId(), TckPublisher.getRiftSawPassword());
88 TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getRiftSawPublisherId(), TckPublisher.getRiftSawPassword());
89 }
90
91 tckTModel = new TckTModel(publication, inquiry);
92 tckService = new TckBusinessService(publication, inquiry);
93 tckBusiness = new TckBusiness(publication, inquiry);
94
95 } catch (Exception e) {
96 logger.error(e.getMessage(), e);
97 Assert.fail("Could not obtain authInfo token.");
98 }
99 rw = new ReadWSDL();
100 }
101 @AfterClass
102 public static void cleanup() throws ConfigurationException{
103 tckTModel.deleteCreatedTModels(authInfoRiftSaw);
104 manager.stop();
105 }
106
107 @Before
108 public void saveRiftSawKeyGenerator() {
109 tckTModel.saveTModel(authInfoRiftSaw, TckTModel.RIFTSAW_PUBLISHER_TMODEL_XML, TckTModel.RIFTSAW_PUBLISHER_TMODEL_KEY);
110 tckBusiness.saveBusiness(authInfoRiftSaw, TckBusiness.RIFTSAW_BUSINESS_XML, TckBusiness.RIFTSAW_BUSINESS_KEY);
111 }
112
113 @After
114 public void saveRiftSawKeyGeneratorAfter() {
115 tckBusiness.deleteBusiness(authInfoRiftSaw, TckBusiness.RIFTSAW_BUSINESS_XML, TckBusiness.RIFTSAW_BUSINESS_KEY);
116 tckTModel.deleteTModel(authInfoRiftSaw, TckTModel.RIFTSAW_PUBLISHER_TMODEL_XML, TckTModel.RIFTSAW_PUBLISHER_TMODEL_KEY);
117 }
118
119 @Test
120 public void parseWSDL_PortTypeTModels() throws WSDLException, Exception {
121
122 Definition wsdlDefinition = rw.readWSDL("uddi_data/bpel/riftsaw/bpel-technote.wsdl");
123 @SuppressWarnings("unchecked")
124 Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
125 String ns = wsdlDefinition.getTargetNamespace();
126 logger.info("Namespace: " + ns);
127
128 boolean foundInterfaceOfTravelAgent=false;
129 boolean foundInterfaceOfCustomer=false;
130
131 Iterator<QName> iterator = portTypes.keySet().iterator();
132 while (iterator.hasNext()) {
133 QName qName = iterator.next();
134 String nsp = qName.getNamespaceURI();
135 String localpart = qName.getLocalPart();
136 logger.info("Namespace: " + nsp);
137 logger.info("LocalPart: " + localpart);
138 if (localpart.equals("InterfaceOfTravelAgent"))
139 foundInterfaceOfTravelAgent=true;
140 if (localpart.equals("InterfaceOfCustomer"))
141 foundInterfaceOfCustomer=true;
142 }
143 org.junit.Assert.assertTrue("InterfaceOfCustomer wasn't found, wsdl parsing error", foundInterfaceOfCustomer);
144 org.junit.Assert.assertTrue("InterfaceOfTravelAgent wasn't found, wsdl parsing error", foundInterfaceOfTravelAgent);
145 }
146
147 @Test
148 public void registerBPELProcess() throws WSDLException, ConfigurationException,
149 MalformedURLException, RemoteException, TransportException, Exception {
150
151 UDDIClerk clerk = new UDDIClerk();
152 clerk.setManagerName(manager.getName());
153 clerk.setName("testClerk");
154 clerk.setPublisher(TckPublisher.getRiftSawPublisherId());
155 clerk.setPassword(TckPublisher.getRiftSawPassword());
156
157 clerk.setUDDINode(manager.getClientConfig().getHomeNode());
158
159 Properties properties = manager.getClientConfig().getHomeNode().getProperties();
160 properties.put("keyDomain", "riftsaw.jboss.org");
161 properties.put("nodeName", "localhost");
162 properties.put("businessName", "redhat-jboss");
163 BPEL2UDDI bpel2UDDI = new BPEL2UDDI(clerk, new URLLocalizerDefaultImpl(), properties);
164
165 Definition wsdlDefinition = rw.readWSDL("uddi_data/bpel/riftsaw/HelloWorld.wsdl");
166 QName serviceName = new QName("http://www.jboss.org/bpel/examples/wsdl", "HelloService");
167 String portName = "HelloPort";
168 URL serviceUrl = new URL("http://localhost:8080/helloworld");
169 bpel2UDDI.register(serviceName, portName, serviceUrl, wsdlDefinition);
170
171 logger.info("DONE");
172
173 bpel2UDDI.unRegister(serviceName, portName, serviceUrl);
174 }
175 }