Return-Path: X-Original-To: apmail-juddi-commits-archive@www.apache.org Delivered-To: apmail-juddi-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E62BD10258 for ; Mon, 28 Oct 2013 12:28:46 +0000 (UTC) Received: (qmail 2798 invoked by uid 500); 28 Oct 2013 12:28:46 -0000 Delivered-To: apmail-juddi-commits-archive@juddi.apache.org Received: (qmail 2755 invoked by uid 500); 28 Oct 2013 12:28:44 -0000 Mailing-List: contact commits-help@juddi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@juddi.apache.org Received: (qmail 2748 invoked by uid 99); 28 Oct 2013 12:28:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Oct 2013 12:28:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Oct 2013 12:28:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7CD83238896F; Mon, 28 Oct 2013 12:28:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1536327 - /juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java Date: Mon, 28 Oct 2013 12:28:22 -0000 To: commits@juddi.apache.org From: alexoree@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131028122822.7CD83238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: alexoree Date: Mon Oct 28 12:28:22 2013 New Revision: 1536327 URL: http://svn.apache.org/r1536327 Log: JUDDI-674 added more unit tests, pulling a wadl from the cxf project Modified: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java Modified: juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java?rev=1536327&r1=1536326&r2=1536327&view=diff ============================================================================== --- juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java (original) +++ juddi/trunk/juddi-client/src/test/java/org/apache/juddi/v3/client/mapping/WADL2UDDITest.java Mon Oct 28 12:28:22 2013 @@ -16,10 +16,12 @@ package org.apache.juddi.v3.client.mapping; import java.io.File; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URL; import java.util.List; import java.util.Properties; -import java.util.Set; +import java.util.logging.Logger; import javax.xml.namespace.QName; import org.apache.juddi.jaxb.PrintUDDI; import org.apache.juddi.v3.client.config.UDDIClerk; @@ -36,18 +38,19 @@ import org.uddi.api_v3.TModel; */ public class WADL2UDDITest { + static final Logger log = Logger.getLogger(WADL2UDDITest.class.getCanonicalName()); static PrintUDDI pTModel = new PrintUDDI(); static Properties properties = new Properties(); - - + /** * tests loading a wadl from a file - * @throws Exception + * + * @throws Exception */ @Test public void Test1() throws Exception { - - + log.info("Test1 read from file"); + Application app = WADL2UDDI.ParseWadl(new File("src/test/resources/wadl/cxf.wadl")); Assert.assertNotNull(app); Assert.assertNotNull(app); @@ -69,7 +72,7 @@ public class WADL2UDDITest { WADL2UDDI wadl2UDDI = new WADL2UDDI(null, new URLLocalizerDefaultImpl(), properties); Assert.assertNotNull(wadl2UDDI); - + BusinessService businessServices = wadl2UDDI.createBusinessService(new QName("CXF.Sample.WADL.namespace", "Servicename"), app); Assert.assertNotNull(businessServices); @@ -78,9 +81,9 @@ public class WADL2UDDITest { Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0)); Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0).getAccessPoint()); Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue()); - - - + + + PrintUDDI servicePrinter = new PrintUDDI(); @@ -89,4 +92,85 @@ public class WADL2UDDITest { } + + private static boolean IsReachable(String url) { + System.out.println("Testing connectivity to " + url); + try { + //make a URL to a known source + URL url2 = new URL(url); + + //open a connection to that source + HttpURLConnection urlConnect = (HttpURLConnection) url2.openConnection(); + + //trying to retrieve data from the source. If there + //is no connection, this line will fail + Object objData = urlConnect.getContent(); + urlConnect.disconnect(); + + } catch (Exception e) { + System.out.println("Connectivity failed " + e.getMessage()); + return false; + } + System.out.println("Connectivity passed"); + return true; + + } + + /** + * normally, this test will work correctly if and only if you're connected + * to the big bad internet. if you happen to be offline, this test will + * fail. + */ + @Test + public void Test2readFromURL() throws MalformedURLException, Exception { + log.info("Test2 read from URL"); + boolean b = IsReachable("http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/wadl/bookstoreImportResource.wadl"); + if (!b) { + System.out.println("Skipping test for a remote WADL due to connectivity problems"); + } + + + org.junit.Assume.assumeTrue(b); + + + Application app = WADL2UDDI.ParseWadl(new URL("http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/wadl/bookstoreImportResource.wadl")); + Assert.assertNotNull(app); + Assert.assertNotNull(app); + List urls = WADL2UDDI.GetBaseAddresses(app); + URL url = urls.get(0); + String domain = url.getHost(); + PrintUDDI tmodelPrinter = new PrintUDDI(); + TModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en"); + //save the keygen + SaveTModel stm = new SaveTModel(); + stm.getTModel().add(keygen); + System.out.println(tmodelPrinter.print(keygen)); + + properties.put("keyDomain", domain); + properties.put("businessName", domain); + properties.put("serverName", url.getHost()); + properties.put("serverPort", url.getPort()); + //wsdlURL = wsdlDefinition.getDocumentBaseURI(); + WADL2UDDI wadl2UDDI = new WADL2UDDI(null, new URLLocalizerDefaultImpl(), properties); + + Assert.assertNotNull(wadl2UDDI); + + BusinessService businessServices = wadl2UDDI.createBusinessService(new QName("CXF.Sample.WADL.namespace", "Servicename"), app); + + Assert.assertNotNull(businessServices); + Assert.assertNotNull(businessServices.getBindingTemplates()); + Assert.assertNotNull(businessServices.getName().get(0)); + Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0)); + Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0).getAccessPoint()); + Assert.assertNotNull(businessServices.getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue()); + + + + + PrintUDDI servicePrinter = new PrintUDDI(); + + System.out.println(servicePrinter.print(businessServices)); + + + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org For additional commands, e-mail: commits-help@juddi.apache.org