KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > util > WSDLUtilTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: WSDLUtilTest.java 15:45:48 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.util;
23
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.util.List JavaDoc;
27
28 import javax.xml.namespace.QName JavaDoc;
29 import javax.xml.parsers.DocumentBuilder JavaDoc;
30 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
31 import javax.xml.parsers.ParserConfigurationException JavaDoc;
32
33 import junit.framework.TestCase;
34
35 import org.w3c.dom.Document JavaDoc;
36 import org.xml.sax.SAXException JavaDoc;
37
38 /**
39  * Test of the WSDLUtil
40  *
41  * @author ddesjardins - eBMWebsourcing
42  */

43 public class WSDLUtilTest extends TestCase {
44
45     public void testAxisWSDL() throws SAXException JavaDoc, IOException JavaDoc,
46         ParserConfigurationException JavaDoc {
47         String JavaDoc baseDir = this.getClass().getResource(".").toString();
48         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
49         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
50         DocumentBuilderFactory JavaDoc factory = DocumentBuilderFactory.newInstance();
51         DocumentBuilder JavaDoc builder = factory.newDocumentBuilder();
52         File JavaDoc xml = new File JavaDoc(baseDir + "src" + File.separator + "test-data"
53             + File.separator + "Axis2BCService.wsdl");
54         Document JavaDoc document = builder.parse(xml);
55         QName JavaDoc serviceName = new QName JavaDoc(
56             "http://org.objectweb.petals.binding.axis2bc/", "Axis2BC");
57         List JavaDoc<QName JavaDoc> interfaces = WSDLUtil.getInterfacesForService(document,
58             serviceName);
59         assertEquals(interfaces.get(0), new QName JavaDoc(
60             "http://org.objectweb.petals.binding.axis2bc/", "Axis2BC"));
61         ;
62     }
63
64     public void testHWWSDL() throws SAXException JavaDoc, IOException JavaDoc,
65         ParserConfigurationException JavaDoc {
66         String JavaDoc baseDir = this.getClass().getResource(".").toString();
67         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
68         baseDir = baseDir.substring(baseDir.indexOf(":")+1);
69         DocumentBuilderFactory JavaDoc factory = DocumentBuilderFactory.newInstance();
70         DocumentBuilder JavaDoc builder = factory.newDocumentBuilder();
71         File JavaDoc xml = new File JavaDoc(baseDir + "src" + File.separator + "test-data"
72             + File.separator + "HelloworldService.wsdl");
73         Document JavaDoc document = builder.parse(xml);
74         QName JavaDoc serviceName = new QName JavaDoc(
75             "http://127.0.0.1:8080/axis/Helloworld.jws", "HelloworldService");
76         List JavaDoc<QName JavaDoc> interfaces = WSDLUtil.getInterfacesForService(document,
77             serviceName);
78         assertEquals(interfaces.get(0), new QName JavaDoc(
79             "http://127.0.0.1:8080/axis/Helloworld.jws", "Helloworld"));
80     }
81
82 }
83
Popular Tags