You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2011/05/13 16:52:38 UTC
svn commit: r1102770 - in /juddi/trunk/juddi-client/src:
main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
test/java/org/apache/juddi/v3/client/mapping/
test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
Author: kstam
Date: Fri May 13 14:52:37 2011
New Revision: 1102770
URL: http://svn.apache.org/viewvc?rev=1102770&view=rev
Log:
JUDDI-377 adding unittest
Added:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/
juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
Added: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java?rev=1102770&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java (added)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/ReadWSDL.java Fri May 13 14:52:37 2011
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import org.apache.juddi.v3.client.ClassUtil;
+
+import com.ibm.wsdl.factory.WSDLFactoryImpl;
+
+/**
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ */
+public class ReadWSDL {
+
+ public Definition readWSDL(String fileName) throws WSDLException {
+ WSDLFactory factory = WSDLFactoryImpl.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ URL wsdlURL = ClassUtil.getResource(fileName, this.getClass());
+ Definition wsdlDefinition = reader.readWSDL(wsdlURL.toExternalForm());
+ return wsdlDefinition;
+ }
+
+
+}
Added: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java?rev=1102770&view=auto
==============================================================================
--- juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java (added)
+++ juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WSDL2UDDITest.java Fri May 13 14:52:37 2011
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.mapping;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+import javax.wsdl.WSDLException;
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
+import org.apache.juddi.jaxb.PrintUDDI;
+import org.junit.Assert;
+import org.junit.Test;
+import org.uddi.api_v3.TModel;
+
+/**
+ * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
+ */
+public class WSDL2UDDITest {
+
+ PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
+ ReadWSDL rw = new ReadWSDL();
+
+ @Test
+ public void testUDDIBindingModel() throws WSDLException, JAXBException {
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("uddi_api_v3_portType.wsdl");
+ String wsdlURL = wsdlDefinition.getDocumentBaseURI();
+
+ Properties properties = new Properties();
+ properties.put("keyDomain", "juddi.apache.org");
+ WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(properties);
+ Set<TModel> tModels = new HashSet<TModel>();
+ @SuppressWarnings("unchecked")
+ Map<QName,PortType> portTypes = (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
+ Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes);
+ tModels.addAll(portTypeTModels);
+
+ for (TModel tModel : tModels) {
+ System.out.println("UDDI PortType TModel " + tModel.getName().getValue());
+ System.out.println(pTModel.print(tModel));
+ }
+ Assert.assertEquals(3,tModels.size());
+ }
+
+ @Test
+ public void testWSDLBindingModel() throws WSDLException, JAXBException {
+
+ // Reading the WSDL
+ Definition wsdlDefinition = rw.readWSDL("uddi_api_v3_binding.wsd");
+ String wsdlURL = wsdlDefinition.getDocumentBaseURI();
+
+ Properties properties = new Properties();
+ properties.put("keyDomain", "juddi.apache.org");
+ WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(properties);
+ Set<TModel> tModels = new HashSet<TModel>();
+ @SuppressWarnings("unchecked")
+ Map<QName,Binding> bindings= (Map<QName,Binding>) wsdlDefinition.getAllBindings();
+ Set<TModel> bindingTModels = wsdl2UDDI.createWSDLBindingTModels(wsdlURL, bindings);
+ tModels.addAll(bindingTModels);
+
+ for (TModel tModel : tModels) {
+ System.out.println("UDDI Binding TModel " + tModel.getName().getValue());
+ System.out.println(pTModel.print(tModel));
+ }
+ Assert.assertEquals(3,tModels.size());
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org