1 7 package org.jboss.test.webservice.wsdlimport; 8 9 11 import java.io.File ; 12 import java.net.URL ; 13 14 import javax.wsdl.Definition; 15 import javax.xml.namespace.QName ; 16 import javax.xml.rpc.Service ; 17 import javax.xml.rpc.ServiceFactory ; 18 19 import junit.framework.TestCase; 20 21 import org.jboss.net.protocol.URLStreamHandlerFactory; 22 import org.jboss.webservice.metadata.wsdl.WSDL11DefinitionFactory; 23 24 30 public class SimpleFileImportTestCase extends TestCase 31 { 32 public static final String WSDL_LOCATION = "resources/webservice/wsdlimport/simplefile/SimpleFile.wsdl"; 33 34 public SimpleFileImportTestCase(String name) 35 { 36 super(name); 37 } 38 39 public void testFileURL() throws Exception 40 { 41 File wsdlFile = new File (WSDL_LOCATION); 42 assertTrue("File does not exist: " + wsdlFile.getCanonicalPath(), wsdlFile.exists()); 43 44 internalInitURLHandlers(); 46 47 URL wsdlURL = wsdlFile.toURL(); 48 Definition wsdlDefinition = WSDL11DefinitionFactory.newInstance().parse(wsdlURL); 49 assertNotNull(wsdlDefinition); 50 51 QName serviceName = (QName )wsdlDefinition.getServices().keySet().iterator().next(); 52 53 ServiceFactory serviceFactory = ServiceFactory.newInstance(); 55 Service service = serviceFactory.createService(wsdlURL, serviceName); 56 assertNotNull(service); 57 } 58 59 64 private void internalInitURLHandlers() 65 { 66 URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory()); 68 69 URLStreamHandlerFactory.preload(); 71 72 String handlerPkgs = System.getProperty("java.protocol.handler.pkgs"); 74 if (handlerPkgs != null) 75 { 76 handlerPkgs += "|org.jboss.net.protocol"; 77 } 78 else 79 { 80 handlerPkgs = "org.jboss.net.protocol"; 81 } 82 System.setProperty("java.protocol.handler.pkgs", handlerPkgs); 83 } 84 } 85 | Popular Tags |