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);
}
}
}
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();
}
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);
}
}
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");
}
}
}
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");
}
}
}
Aggregations