Search in sources :

Example 11 with WSDLToJava

use of org.apache.cxf.tools.wsdlto.WSDLToJava in project cxf by apache.

the class CodeGenBugTest method testCXF3105.

@Test
public void testCXF3105() throws Exception {
    String[] args = new String[] { "-d", output.getCanonicalPath(), "-impl", "-server", "-client", "-b", getLocation("/wsdl2java_wsdl/cxf3105/ws-binding.xml"), getLocation("/wsdl2java_wsdl/cxf3105/cxf3105.wsdl") };
    CommandInterfaceUtils.commandCommonMain();
    WSDLToJava w2j = new WSDLToJava(args);
    w2j.run(new ToolContext());
    assertNotNull(output);
    File f = new File(output, "org/apache/cxf/testcase/cxf3105/Login.java");
    assertTrue(f.exists());
    String contents = IOUtils.readStringFromStream(new FileInputStream(f));
    assertTrue(contents.contains("Loginrequesttype loginRequest"));
    assertTrue(contents.contains("<Loginresponsetype> loginResponse"));
}
Also used : WSDLToJava(org.apache.cxf.tools.wsdlto.WSDLToJava) ToolContext(org.apache.cxf.tools.common.ToolContext) File(java.io.File) FileInputStream(java.io.FileInputStream) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 12 with WSDLToJava

use of org.apache.cxf.tools.wsdlto.WSDLToJava in project cxf by apache.

the class CodeGenBugTest method testCommandLine.

@Test
public void testCommandLine() throws Exception {
    String[] args = new String[] { "-compile", "-d", output.getCanonicalPath(), "-classdir", output.getCanonicalPath() + "/classes", "-p", "org.cxf", "-p", "http://apache.org/hello_world_soap_http/types=org.apache.types", "-server", "-impl", getLocation("/wsdl2java_wsdl/hello_world.wsdl") };
    CommandInterfaceUtils.commandCommonMain();
    WSDLToJava w2j = new WSDLToJava(args);
    w2j.run(new ToolContext());
    Class<?> clz = classLoader.loadClass("org.cxf.Greeter");
    assertTrue("Generate " + clz.getName() + "error", clz.isInterface());
}
Also used : WSDLToJava(org.apache.cxf.tools.wsdlto.WSDLToJava) ToolContext(org.apache.cxf.tools.common.ToolContext) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 13 with WSDLToJava

use of org.apache.cxf.tools.wsdlto.WSDLToJava in project cxf by apache.

the class CodeGenBugTest method testCXF1662.

@Test
public void testCXF1662() throws Exception {
    String[] args = new String[] { "-d", output.getCanonicalPath(), "-p", "org.cxf", getLocation("/wsdl2java_wsdl/cxf1662/test.wsdl") };
    try {
        CommandInterfaceUtils.commandCommonMain();
        WSDLToJava w2j = new WSDLToJava(args);
        w2j.run(new ToolContext());
    } catch (ToolException tex) {
        assertTrue(tex.getMessage().contains(" -p option cannot be used when " + "wsdl contains mutiple schemas"));
    }
    String[] args2 = new String[] { "-d", output.getCanonicalPath(), "-p", "org.cxf", getLocation("/wsdl2java_wsdl/cxf1662/test2.wsdl") };
    try {
        CommandInterfaceUtils.commandCommonMain();
        WSDLToJava w2j = new WSDLToJava(args2);
        w2j.run(new ToolContext());
    } catch (ToolException tex) {
        assertNull(tex);
    }
    assertNotNull(output);
    File file = new File(output, "org/cxf/package-info.java");
    assertTrue(file.exists());
    String str = TestFileUtils.getStringFromFile(file);
    assertTrue(str.contains("http://child/xsd"));
}
Also used : WSDLToJava(org.apache.cxf.tools.wsdlto.WSDLToJava) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 14 with WSDLToJava

use of org.apache.cxf.tools.wsdlto.WSDLToJava in project cxf by apache.

the class CodeGenBugTest method testDefaultLoadNSMappingOFF.

@Test
public void testDefaultLoadNSMappingOFF() throws Exception {
    String[] args = new String[] { "-dns", "false", "-d", output.getCanonicalPath(), "-noAddressBinding", getLocation("/wsdl2java_wsdl/basic_callback.wsdl") };
    CommandInterfaceUtils.commandCommonMain();
    WSDLToJava w2j = new WSDLToJava(args);
    w2j.run(new ToolContext());
    assertNotNull(output);
    File org = new File(output, "org");
    assertTrue(org.exists());
    File w3 = new File(org, "w3");
    assertTrue(w3.exists());
    File p2005 = new File(w3, "_2005");
    assertTrue(p2005.exists());
    File p08 = new File(p2005, "_08");
    assertTrue(p08.exists());
    File address = new File(p08, "addressing");
    assertTrue(address.exists());
    File[] files = address.listFiles();
    assertEquals(11, files.length);
}
Also used : WSDLToJava(org.apache.cxf.tools.wsdlto.WSDLToJava) ToolContext(org.apache.cxf.tools.common.ToolContext) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Example 15 with WSDLToJava

use of org.apache.cxf.tools.wsdlto.WSDLToJava in project cxf by apache.

the class CodeGenBugTest method testExcludeNSWithPackageName.

@Test
public void testExcludeNSWithPackageName() throws Exception {
    String[] args = new String[] { "-d", output.getCanonicalPath(), "-nexclude", "http://apache.org/test/types=com.iona", "-nexclude", "http://apache.org/Invoice", "-compile", "-classdir", output.getCanonicalPath() + "/classes", getLocation("/wsdl2java_wsdl/hello_world_exclude.wsdl") };
    CommandInterfaceUtils.commandCommonMain();
    WSDLToJava w2j = new WSDLToJava(args);
    w2j.run(new ToolContext());
    assertNotNull(output);
    File com = new File(output, "com");
    assertFalse("Generated file has been excluded", com.exists());
    File iona = new File(com, "iona");
    assertFalse("Generated file has been excluded", iona.exists());
    File implFile = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/Greeter.java");
    String str = TestFileUtils.getStringFromFile(implFile);
    assertTrue(str.contains("com.iona.BareDocumentResponse"));
    File org = new File(output, "org");
    File apache = new File(org, "apache");
    File invoice = new File(apache, "Invoice");
    assertFalse("Generated file has been excluded", invoice.exists());
}
Also used : WSDLToJava(org.apache.cxf.tools.wsdlto.WSDLToJava) ToolContext(org.apache.cxf.tools.common.ToolContext) File(java.io.File) AbstractCodeGenTest(org.apache.cxf.tools.wsdlto.AbstractCodeGenTest) Test(org.junit.Test)

Aggregations

ToolContext (org.apache.cxf.tools.common.ToolContext)17 WSDLToJava (org.apache.cxf.tools.wsdlto.WSDLToJava)17 File (java.io.File)14 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)14 Test (org.junit.Test)14 ToolException (org.apache.cxf.tools.common.ToolException)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 WSDLRuntimeException (org.apache.cxf.wsdl11.WSDLRuntimeException)2 BufferedReader (java.io.BufferedReader)1 DataOutputStream (java.io.DataOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 FileReader (java.io.FileReader)1 FilenameFilter (java.io.FilenameFilter)1 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 URI (java.net.URI)1