Search in sources :

Example 11 with ToolContext

use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.

the class ParameterProcessorTest method testAddParameter.

@Test
public void testAddParameter() throws Exception {
    ParameterProcessor processor = new ParameterProcessor(new ToolContext());
    JavaMethod method = new JavaMethod();
    JavaParameter p1 = new JavaParameter("request", String.class.getName(), null);
    p1.setStyle(JavaType.Style.IN);
    processor.addParameter(null, method, p1);
    JavaParameter p2 = new JavaParameter("request", String.class.getName(), null);
    p2.setStyle(JavaType.Style.OUT);
    processor.addParameter(null, method, p2);
    assertEquals(1, method.getParameters().size());
    assertEquals(JavaType.Style.INOUT, method.getParameters().get(0).getStyle());
}
Also used : JavaMethod(org.apache.cxf.tools.common.model.JavaMethod) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) ToolContext(org.apache.cxf.tools.common.ToolContext) Test(org.junit.Test)

Example 12 with ToolContext

use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.

the class InterfaceMapperTest method testMap.

@Test
public void testMap() throws Exception {
    InterfaceInfo interfaceInfo = new InterfaceInfo(new ServiceInfo(), new QName("http://apache.org/hello_world_soap_http", "interfaceTest"));
    ToolContext context = new ToolContext();
    context.put(ToolConstants.CFG_WSDLURL, "http://localhost/?wsdl");
    JavaInterface intf = new InterfaceMapper(context).map(interfaceInfo);
    assertNotNull(intf);
    assertEquals("interfaceTest", intf.getWebServiceName());
    assertEquals("InterfaceTest", intf.getName());
    assertEquals("http://apache.org/hello_world_soap_http", intf.getNamespace());
    assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());
    assertEquals("http://localhost/?wsdl", intf.getLocation());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) QName(javax.xml.namespace.QName) ToolContext(org.apache.cxf.tools.common.ToolContext) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 13 with ToolContext

use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.

the class JavaToWSTest method setUpResource.

@Before
public void setUpResource() throws Exception {
    super.setUp();
    env = new ToolContext();
    cp = System.getProperty("java.class.path");
    URL url = getClass().getResource(".");
    output = new File(url.toURI());
    System.setProperty("java.class.path", getClassPath());
    output = new File(output, "/generated/");
    FileUtils.mkDir(output);
    classDir = new File(output, "/classes/");
    FileUtils.mkDir(classDir);
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Example 14 with ToolContext

use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.

the class JAXRSContainerTest method testCodeGenInterfacesCustomPackage.

@Test
public void testCodeGenInterfacesCustomPackage() {
    try {
        JAXRSContainer container = new JAXRSContainer(null);
        ToolContext context = new ToolContext();
        context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
        context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
        context.put(WadlToolConstants.CFG_PACKAGENAME, "custom.books");
        context.put(WadlToolConstants.CFG_COMPILE, "true");
        container.setContext(context);
        container.execute();
        assertNotNull(output.list());
        verifyFiles("java", true, false, "superbooks", "custom.books", 11, true);
        verifyFiles("class", true, false, "superbooks", "custom.books", 11, true);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Example 15 with ToolContext

use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.

the class JAXRSContainerTest method testCodeGenInterfacesMultipleInXmlReps.

@Test
public void testCodeGenInterfacesMultipleInXmlReps() {
    try {
        JAXRSContainer container = new JAXRSContainer(null);
        ToolContext context = new ToolContext();
        context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
        context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
        context.put(WadlToolConstants.CFG_COMPILE, "true");
        context.put(WadlToolConstants.CFG_MULTIPLE_XML_REPS, "true");
        container.setContext(context);
        container.execute();
        assertNotNull(output.list());
        verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
        verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Aggregations

ToolContext (org.apache.cxf.tools.common.ToolContext)69 Test (org.junit.Test)45 URISyntaxException (java.net.URISyntaxException)35 File (java.io.File)23 ToolException (org.apache.cxf.tools.common.ToolException)13 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)7 WADLToJava (org.apache.cxf.tools.wadlto.WADLToJava)5 BufferedReader (java.io.BufferedReader)4 Method (java.lang.reflect.Method)4 URLClassLoader (java.net.URLClassLoader)4 QName (javax.xml.namespace.QName)4 Before (org.junit.Before)4 FileReader (java.io.FileReader)3 URI (java.net.URI)3 LinkedHashSet (java.util.LinkedHashSet)3 JavaInterface (org.apache.cxf.tools.common.model.JavaInterface)3 Artifact (org.apache.maven.artifact.Artifact)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 IOException (java.io.IOException)2 Writer (java.io.Writer)2