Search in sources :

Example 1 with WsgenOptions

use of com.sun.tools.ws.wscompile.WsgenOptions in project metro-jax-ws by eclipse-ee4j.

the class WebServiceApTest method getOptions.

private static WsgenOptions getOptions(WsgenTool tool) {
    Field field = null;
    try {
        field = tool.getClass().getDeclaredField("options");
        field.setAccessible(true);
        return (WsgenOptions) field.get(tool);
    } catch (ReflectiveOperationException | SecurityException ex) {
        throw new RuntimeException(ex);
    } finally {
        if (field != null) {
            field.setAccessible(false);
        }
    }
}
Also used : Field(java.lang.reflect.Field) WsgenOptions(com.sun.tools.ws.wscompile.WsgenOptions)

Example 2 with WsgenOptions

use of com.sun.tools.ws.wscompile.WsgenOptions in project metro-jax-ws by eclipse-ee4j.

the class WebServiceAp method init.

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    exceptionElement = processingEnv.getElementUtils().getTypeElement(Exception.class.getName()).asType();
    runtimeExceptionElement = processingEnv.getElementUtils().getTypeElement(RuntimeException.class.getName()).asType();
    defHolderElement = processingEnv.getElementUtils().getTypeElement(Holder.class.getName());
    if (options == null) {
        options = new WsgenOptions();
        out = new PrintStream(new ByteArrayOutputStream());
        doNotOverWrite = getOption(DO_NOT_OVERWRITE);
        ignoreNoWebServiceFoundWarning = getOption(IGNORE_NO_WEB_SERVICE_FOUND_WARNING);
        options.verbose = getOption(VERBOSE);
        isCommandLineInvocation = true;
    }
    options.filer = processingEnv.getFiler();
}
Also used : PrintStream(java.io.PrintStream) WsgenOptions(com.sun.tools.ws.wscompile.WsgenOptions) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ModelerException(com.sun.tools.ws.processor.modeler.ModelerException) AbortException(com.sun.tools.ws.wscompile.AbortException)

Example 3 with WsgenOptions

use of com.sun.tools.ws.wscompile.WsgenOptions in project metro-jax-ws by eclipse-ee4j.

the class WebServiceApTest method testRemoteException.

public void testRemoteException() {
    options.add("-r");
    options.add(destDir.getAbsolutePath());
    options.add("-wsdl");
    options.add("-inlineSchemas");
    options.add("-verbose");
    options.add("com.sun.tools.ws.test.processor.modeler.annotation.RMITestWs");
    WsgenTool wsgen = new WsgenTool(System.out);
    wsgen.run(options.toArray(new String[options.size()]));
    WsgenOptions opts = getOptions(wsgen);
    int count = 0;
    for (File f : opts.getGeneratedFiles()) {
        count++;
    }
    Assert.assertEquals(11, count);
    try {
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(destDir, "RMITestWsService.wsdl"));
        NodeList faults = doc.getElementsByTagName("fault");
        Assert.assertEquals("CustomEx", faults.item(1).getAttributes().getNamedItem("name").getTextContent());
        Assert.assertEquals(faults.item(0).getAttributes().getNamedItem("name").getTextContent(), faults.item(1).getAttributes().getNamedItem("name").getTextContent());
        Assert.assertEquals(2, faults.getLength());
    } catch (ParserConfigurationException | SAXException | IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : WsgenOptions(com.sun.tools.ws.wscompile.WsgenOptions) WsgenTool(com.sun.tools.ws.wscompile.WsgenTool) NodeList(org.w3c.dom.NodeList) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Document(org.w3c.dom.Document) File(java.io.File) SAXException(org.xml.sax.SAXException)

Example 4 with WsgenOptions

use of com.sun.tools.ws.wscompile.WsgenOptions in project metro-jax-ws by eclipse-ee4j.

the class WebServiceApTest method testRemoteIfaceArg.

public void testRemoteIfaceArg() {
    options.add("-proc:only");
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    WsgenOptions wsgenOptions = new WsgenOptions();
    wsgenOptions.verbose = true;
    JavaCompiler.CompilationTask task = getCompilationTask("com.sun.tools.ws.test.processor.modeler.annotation.RemoteArgTestWS", options, wsgenOptions, diagnostics);
    try {
        task.call();
    } catch (RuntimeException re) {
        if (!(re.getCause() instanceof ModelerException)) {
            fail(ModelerException.class.getName() + " should have been thrown - spec requirement");
        }
    }
}
Also used : ModelerException(com.sun.tools.ws.processor.modeler.ModelerException) SimpleJavaFileObject(javax.tools.SimpleJavaFileObject) JavaFileObject(javax.tools.JavaFileObject) WsgenOptions(com.sun.tools.ws.wscompile.WsgenOptions) JavaCompiler(javax.tools.JavaCompiler) DiagnosticCollector(javax.tools.DiagnosticCollector)

Example 5 with WsgenOptions

use of com.sun.tools.ws.wscompile.WsgenOptions in project metro-jax-ws by eclipse-ee4j.

the class WebServiceApTest method testRemoteIfaceReturn.

public void testRemoteIfaceReturn() {
    options.add("-proc:only");
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    WsgenOptions wsgenOptions = new WsgenOptions();
    wsgenOptions.verbose = true;
    JavaCompiler.CompilationTask task = getCompilationTask("com.sun.tools.ws.test.processor.modeler.annotation.RemoteReturnTestWs", options, wsgenOptions, diagnostics);
    try {
        task.call();
    } catch (RuntimeException re) {
        if (!(re.getCause() instanceof ModelerException)) {
            fail(ModelerException.class.getName() + " should have been thrown - spec requirement");
        }
    }
}
Also used : ModelerException(com.sun.tools.ws.processor.modeler.ModelerException) SimpleJavaFileObject(javax.tools.SimpleJavaFileObject) JavaFileObject(javax.tools.JavaFileObject) WsgenOptions(com.sun.tools.ws.wscompile.WsgenOptions) JavaCompiler(javax.tools.JavaCompiler) DiagnosticCollector(javax.tools.DiagnosticCollector)

Aggregations

WsgenOptions (com.sun.tools.ws.wscompile.WsgenOptions)6 ModelerException (com.sun.tools.ws.processor.modeler.ModelerException)3 IOException (java.io.IOException)2 DiagnosticCollector (javax.tools.DiagnosticCollector)2 JavaCompiler (javax.tools.JavaCompiler)2 JavaFileObject (javax.tools.JavaFileObject)2 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)2 CodeWriter (com.sun.codemodel.CodeWriter)1 ProgressCodeWriter (com.sun.codemodel.writer.ProgressCodeWriter)1 AbortException (com.sun.tools.ws.wscompile.AbortException)1 FilerCodeWriter (com.sun.tools.ws.wscompile.FilerCodeWriter)1 WsgenTool (com.sun.tools.ws.wscompile.WsgenTool)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 Field (java.lang.reflect.Field)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1 SAXException (org.xml.sax.SAXException)1