use of com.sun.tools.ws.wscompile.WsgenTool 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.WsgenTool in project axis-axis2-java-core by apache.
the class JAXWS2WSDLCodegenEngine method generate.
/**
* Generate.
*
* @throws Exception
* the exception
*/
public void generate() throws Exception {
WsgenTool genTool = new WsgenTool(new WriterOutputStream(new LogWriter(log)));
List<String> args = new ArrayList<String>();
configurImportToolOptions(args);
mergeOriginalArgs(args);
boolean success = genTool.run(args.toArray(new String[args.size()]));
if (success) {
log.info("Code generation completed");
}
}
use of com.sun.tools.ws.wscompile.WsgenTool in project metro-jax-ws by eclipse-ee4j.
the class NillableArrayTest method testNillableArray.
public void testNillableArray() {
File destDir;
List<String> options;
destDir = new File(System.getProperty("java.io.tmpdir"), NillableArrayTest.class.getSimpleName());
destDir.mkdirs();
options = new ArrayList<>();
options.add("-d");
options.add(destDir.getAbsolutePath());
options.add("-cp");
options.add(System.getProperty("java.class.path") + File.pathSeparator + System.getProperty("jdk.module.path"));
options.add("com.sun.tools.ws.test.processor.modeler.annotation.NillableTestWs");
options.add("-wsdl");
Properties props = System.getProperties();
props.setProperty("com.sun.xml.ws.jaxb.allowNonNillableArray", "true");
WsgenTool wsgen = new WsgenTool(System.out);
try {
wsgen.run(options.toArray(new String[options.size()]));
File file = new File(destDir, "NillableTestWsService_schema1.xsd");
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
NodeList complexTypesNodes = doc.getElementsByTagName("xs:complexType");
for (int i = 0; i < complexTypesNodes.getLength(); i++) {
// the nillable value is not set so nillable attribute in the schema for that array element will be true
if ((complexTypesNodes.item(i).getAttributes().getNamedItem("name").getNodeValue()).equals("setEntitlements")) {
Assert.assertEquals("true", complexTypesNodes.item(i).getChildNodes().item(1).getChildNodes().item(1).getAttributes().getNamedItem("nillable").getNodeValue());
}
// the nillable value is set to false so nillable attribute in the schema for that element will be null
if ((complexTypesNodes.item(i).getAttributes().getNamedItem("name").getNodeValue()).equals("getEntitlementsResponse")) {
Assert.assertNull(complexTypesNodes.item(i).getChildNodes().item(1).getChildNodes().item(1).getAttributes().getNamedItem("nillable"));
}
}
} catch (Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
} finally {
System.clearProperty("com.sun.xml.ws.jaxb.allowNonNillableArray");
}
}
Aggregations