Search in sources :

Example 56 with ToolContext

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

the class AbstractGeneratorTest method testKeep.

@Test
public void testKeep() throws Exception {
    gen = new DummyGenerator();
    util = new FileWriterUtil(output.toString(), null);
    context = new ToolContext();
    context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());
    gen.setEnvironment(context);
    Writer writer = util.getWriter(packageName, className + ".java");
    writer.write("hello world");
    writer.flush();
    writer.close();
    context.put(ToolConstants.CFG_GEN_NEW_ONLY, "keep");
    assertNull(gen.parseOutputName(packageName, className));
}
Also used : FileWriterUtil(org.apache.cxf.tools.util.FileWriterUtil) ToolContext(org.apache.cxf.tools.common.ToolContext) Writer(java.io.Writer) Test(org.junit.Test)

Example 57 with ToolContext

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

the class InterfaceMapperTest method testMapWithUniqueWsdlLoc.

@Test
public void testMapWithUniqueWsdlLoc() 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");
    context.put(ToolConstants.CFG_WSDLLOCATION, "/foo/blah.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("/foo/blah.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 58 with ToolContext

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

the class WSDLToService method execute.

public void execute(boolean exitOnFinish) {
    WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("WSDLToService Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("WSDLToService Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } finally {
        tearDown();
    }
}
Also used : WSDLToServiceProcessor(org.apache.cxf.tools.misc.processor.WSDLToServiceProcessor) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 59 with ToolContext

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

the class WSDLToSoap method execute.

public void execute(boolean exitOnFinish) {
    WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            setEnvParamDefValues(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("WSDLToSoap Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("WSDLToSoap Error : " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } finally {
        tearDown();
    }
}
Also used : BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) WSDLToSoapProcessor(org.apache.cxf.tools.misc.processor.WSDLToSoapProcessor) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

Example 60 with ToolContext

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

the class WSDLToXML method execute.

public void execute(boolean exitOnFinish) {
    WSDLToXMLProcessor processor = new WSDLToXMLProcessor();
    try {
        super.execute(exitOnFinish);
        if (!hasInfoOption()) {
            ToolContext env = new ToolContext();
            env.setParameters(getParametersMap(getArrayKeys()));
            if (isVerboseOn()) {
                env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
            }
            env.put(ToolConstants.CFG_CMD_ARG, getArgument());
            validate(env);
            setEnvParamDefValues(env);
            processor.setEnvironment(env);
            processor.process();
        }
    } catch (ToolException ex) {
        if (ex.getCause() instanceof BadUsageException) {
            printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
        }
        err.println();
        err.println("WSDLToXML Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } catch (Exception ex) {
        err.println();
        err.println("WSDLToXML Error: " + ex.getMessage());
        if (isVerboseOn()) {
            ex.printStackTrace(err);
        }
    } finally {
        tearDown();
    }
}
Also used : WSDLToXMLProcessor(org.apache.cxf.tools.misc.processor.WSDLToXMLProcessor) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException)

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