1 22 package org.objectweb.petals.util; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.util.List ; 27 28 import javax.xml.namespace.QName ; 29 import javax.xml.parsers.DocumentBuilder ; 30 import javax.xml.parsers.DocumentBuilderFactory ; 31 import javax.xml.parsers.ParserConfigurationException ; 32 33 import junit.framework.TestCase; 34 35 import org.w3c.dom.Document ; 36 import org.xml.sax.SAXException ; 37 38 43 public class WSDLUtilTest extends TestCase { 44 45 public void testAxisWSDL() throws SAXException , IOException , 46 ParserConfigurationException { 47 String baseDir = this.getClass().getResource(".").toString(); 48 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 49 baseDir = baseDir.substring(baseDir.indexOf(":") + 1); 50 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 51 DocumentBuilder builder = factory.newDocumentBuilder(); 52 File xml = new File (baseDir + "src" + File.separator + "test-data" 53 + File.separator + "Axis2BCService.wsdl"); 54 Document document = builder.parse(xml); 55 QName serviceName = new QName ( 56 "http://org.objectweb.petals.binding.axis2bc/", "Axis2BC"); 57 List <QName > interfaces = WSDLUtil.getInterfacesForService(document, 58 serviceName); 59 assertEquals(interfaces.get(0), new QName ( 60 "http://org.objectweb.petals.binding.axis2bc/", "Axis2BC")); 61 ; 62 } 63 64 public void testHWWSDL() throws SAXException , IOException , 65 ParserConfigurationException { 66 String baseDir = this.getClass().getResource(".").toString(); 67 baseDir = baseDir.substring(0, baseDir.indexOf("target")); 68 baseDir = baseDir.substring(baseDir.indexOf(":")+1); 69 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 70 DocumentBuilder builder = factory.newDocumentBuilder(); 71 File xml = new File (baseDir + "src" + File.separator + "test-data" 72 + File.separator + "HelloworldService.wsdl"); 73 Document document = builder.parse(xml); 74 QName serviceName = new QName ( 75 "http://127.0.0.1:8080/axis/Helloworld.jws", "HelloworldService"); 76 List <QName > interfaces = WSDLUtil.getInterfacesForService(document, 77 serviceName); 78 assertEquals(interfaces.get(0), new QName ( 79 "http://127.0.0.1:8080/axis/Helloworld.jws", "Helloworld")); 80 } 81 82 } 83 | Popular Tags |