Search in sources :

Example 6 with JAXWSContainer

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer in project cxf by apache.

the class ValidatorTest method testXMLFormat.

@Test
public void testXMLFormat() throws Exception {
    processor = new JAXWSContainer(null);
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/xml_format_root.wsdl"));
    processor.setContext(env);
    try {
        processor.execute();
        fail("xml_format_root.wsdl is not a valid wsdl, should throws exception here");
    } catch (Exception e) {
        String expected = "Binding(Greeter_XMLBinding):BindingOperation" + "({http://apache.org/xml_http_bare}sayHi)-input: empty value of rootNode attribute, " + "the value should be {http://apache.org/xml_http_bare}sayHi";
        assertEquals(expected, e.getMessage().trim());
    }
}
Also used : JAXWSContainer(org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer) Test(org.junit.Test)

Example 7 with JAXWSContainer

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer in project cxf by apache.

the class JavaToJSProcessorTest method testDocLitUseClassPathFlag.

@Test
public void testDocLitUseClassPathFlag() throws Exception {
    File classFile = new java.io.File(output.getCanonicalPath() + "/classes");
    classFile.mkdir();
    System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath() + File.separatorChar);
    env.put(ToolConstants.CFG_COMPILE, ToolConstants.CFG_COMPILE);
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
    env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
    env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    env.put(ToolConstants.CFG_PACKAGENAME, "org.apache.cxf.classpath");
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/hello_world_doc_lit.wsdl"));
    JAXWSContainer w2jProcessor = new JAXWSContainer(null);
    w2jProcessor.setContext(env);
    w2jProcessor.execute();
    System.setProperty("java.class.path", "");
    // test flag
    String[] args = new String[] { "-o", "java2wsdl.js", "-jsutils", "-cp", classFile.getCanonicalPath(), "-d", output.getPath(), "org.apache.cxf.classpath.Greeter" };
    JavaToJS.main(args);
    File jsFile = new File(output, "java2wsdl.js");
    assertTrue("Generate JS Fail", jsFile.exists());
}
Also used : JAXWSContainer(org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer) File(java.io.File) Test(org.junit.Test)

Example 8 with JAXWSContainer

use of org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer in project cxf by apache.

the class JavaToProcessorTest method testDocLitUseClassPathFlag.

@Test
public void testDocLitUseClassPathFlag() throws Exception {
    File classFile = new java.io.File(output.getCanonicalPath() + "/classes");
    classFile.mkdir();
    System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath() + File.separatorChar);
    env.put(ToolConstants.CFG_COMPILE, ToolConstants.CFG_COMPILE);
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(FrontEndProfile.class, PluginLoader.getInstance().getFrontEndProfile("jaxws"));
    env.put(DataBindingProfile.class, PluginLoader.getInstance().getDataBindingProfile("jaxb"));
    env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
    env.put(ToolConstants.CFG_PACKAGENAME, "org.apache.cxf.classpath");
    env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
    env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl/hello_world_doc_lit.wsdl"));
    JAXWSContainer w2jProcessor = new JAXWSContainer(null);
    w2jProcessor.setContext(env);
    w2jProcessor.execute();
    String tns = "http://apache.org/sepecifiedTns";
    String serviceName = "cxfService";
    String portName = "cxfPort";
    System.setProperty("java.class.path", "");
    // test flag
    String[] args = new String[] { "-o", "java2wsdl.wsdl", "-cp", classFile.getCanonicalPath(), "-t", tns, "-servicename", serviceName, "-portname", portName, "-soap12", "-d", output.getPath(), "-wsdl", "org.apache.cxf.classpath.Greeter" };
    JavaToWS.main(args);
    File wsdlFile = new File(output, "java2wsdl.wsdl");
    assertTrue("Generate Wsdl Fail", wsdlFile.exists());
    Definition def = wsdlHelper.getDefinition(wsdlFile);
    Service wsdlService = def.getService(new QName(tns, serviceName));
    assertNotNull("Generate WSDL Service Error", wsdlService);
    Port wsdlPort = wsdlService.getPort(portName);
    assertNotNull("Generate service port error ", wsdlPort);
}
Also used : QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) JAXWSContainer(org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer) Service(javax.wsdl.Service) File(java.io.File) Test(org.junit.Test)

Aggregations

JAXWSContainer (org.apache.cxf.tools.wsdlto.frontend.jaxws.JAXWSContainer)8 Test (org.junit.Test)6 File (java.io.File)3 URISyntaxException (java.net.URISyntaxException)2 QName (javax.xml.namespace.QName)2 ToolContext (org.apache.cxf.tools.common.ToolContext)2 JavaException (org.apache.cxf.tools.common.model.JavaException)2 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)2 JavaMethod (org.apache.cxf.tools.common.model.JavaMethod)2 JavaModel (org.apache.cxf.tools.common.model.JavaModel)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Definition (javax.wsdl.Definition)1 Port (javax.wsdl.Port)1 Service (javax.wsdl.Service)1 FrontEndGenerator (org.apache.cxf.tools.common.FrontEndGenerator)1 JavaPort (org.apache.cxf.tools.common.model.JavaPort)1 JavaServiceClass (org.apache.cxf.tools.common.model.JavaServiceClass)1 ServiceValidator (org.apache.cxf.tools.validator.ServiceValidator)1 FrontEndProfile (org.apache.cxf.tools.wsdlto.core.FrontEndProfile)1