use of org.apache.cxf.tools.corba.common.ProcessorEnvironment in project cxf by apache.
the class IDLToWSDLGenerationTest method testWSDLGeneration.
public void testWSDLGeneration(String sourceIdlFilename, String expectedWsdlFilename) throws Exception {
URL idl = getClass().getResource(sourceIdlFilename);
ProcessorEnvironment env = new ProcessorEnvironment();
Map<String, Object> cfg = new HashMap<>();
cfg.put(ToolCorbaConstants.CFG_IDLFILE, new File(idl.toURI()).getAbsolutePath());
env.setParameters(cfg);
IDLToWSDLProcessor processor = new IDLToWSDLProcessor();
processor.setEnvironment(env);
java.io.CharArrayWriter out = new java.io.CharArrayWriter();
processor.setOutputWriter(out);
processor.process();
URL orig = getClass().getResource(expectedWsdlFilename);
InputStream actualStream = new ByteArrayInputStream(out.toString().getBytes());
assertWsdlEquals(orig.openStream(), actualStream, DEFAULT_IGNORE_ATTR, DEFAULT_IGNORE_TAG);
}
use of org.apache.cxf.tools.corba.common.ProcessorEnvironment in project cxf by apache.
the class IDLToWSDLGenerationTest method testLogicalPhysicalSchemaGeneration.
public void testLogicalPhysicalSchemaGeneration(String idlFilename, String logicalName, String physicalName, String schemaFilename, String defaultFilename, String importName, String defaultImportName) throws Exception {
URL idl = getClass().getResource(idlFilename);
ProcessorEnvironment env = new ProcessorEnvironment();
Map<String, Object> cfg = new HashMap<>();
cfg.put(ToolCorbaConstants.CFG_IDLFILE, new File(idl.toURI()).getAbsolutePath());
if (logicalName != null) {
cfg.put(ToolCorbaConstants.CFG_LOGICAL, logicalName);
}
if (physicalName != null) {
cfg.put(ToolCorbaConstants.CFG_PHYSICAL, physicalName);
}
if (schemaFilename != null) {
cfg.put(ToolCorbaConstants.CFG_SCHEMA, schemaFilename);
}
env.setParameters(cfg);
IDLToWSDLProcessor processor = new IDLToWSDLProcessor();
processor.setEnvironment(env);
java.io.CharArrayWriter outD = new java.io.CharArrayWriter();
processor.setOutputWriter(outD);
java.io.CharArrayWriter outL = new java.io.CharArrayWriter();
java.io.CharArrayWriter outP = new java.io.CharArrayWriter();
java.io.CharArrayWriter outS = new java.io.CharArrayWriter();
if (logicalName != null) {
processor.setLogicalOutputWriter(outL);
}
if (physicalName != null) {
processor.setPhysicalOutputWriter(outP);
}
if (schemaFilename != null) {
processor.setSchemaOutputWriter(outS);
}
processor.process();
String userdir = System.getProperty("user.dir");
String sep = System.getProperty("file.separator");
File file = new File(userdir + sep + importName);
String location = file.toURI().toString();
File schemaFile = new File(userdir + sep + schemaFilename);
String schemaLocation = schemaFile.toURI().toString();
File defaultFile = new File(userdir + sep + defaultImportName);
String defaultLocation = defaultFile.toURI().toString();
if (logicalName != null) {
testCompare(logicalName, outL, schemaLocation);
}
if (physicalName != null) {
testCompare(physicalName, outP, location);
}
if (schemaFilename != null) {
InputStream origSchemaStream = getClass().getResourceAsStream("/idl/" + schemaFilename);
InputStream actualSchemaStream = new ByteArrayInputStream(outS.toString().getBytes());
assertWsdlEquals(origSchemaStream, actualSchemaStream, SCHEMA_IGNORE_ATTR, DEFAULT_IGNORE_TAG);
}
if (defaultFilename != null) {
testCompare(defaultFilename, outD, defaultLocation);
}
}
use of org.apache.cxf.tools.corba.common.ProcessorEnvironment in project cxf by apache.
the class WSDLToIDL method execute.
public void execute(boolean exitOnFinish) {
try {
super.execute(exitOnFinish);
if (!hasInfoOption()) {
ProcessorEnvironment env = new ProcessorEnvironment();
env.setParameters(getParametersMap(getArrayKeys()));
if (isVerboseOn()) {
env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
}
env.put(ToolConstants.CFG_CMD_ARG, args);
CommandDocument doc = super.getCommandDocument();
if (doc.hasParameter("corba")) {
env.put(ToolCorbaConstants.CFG_CORBA, Boolean.TRUE);
}
if (doc.hasParameter("idl")) {
env.put(ToolCorbaConstants.CFG_IDL, Boolean.TRUE);
}
initialise(env);
validate(env);
WSDLToCorbaProcessor corbaProcessor = new WSDLToCorbaProcessor();
corbaProcessor.setEnvironment(env);
corbaProcessor.process();
}
} catch (ToolException ex) {
err.println("Error : " + ex.getMessage());
if (ex.getCause() instanceof BadUsageException) {
printUsageException(TOOL_NAME, (BadUsageException) ex.getCause());
}
err.println();
if (isVerboseOn()) {
ex.printStackTrace(err);
}
throw ex;
} catch (Exception ex) {
err.println("Error : " + ex.getMessage());
err.println();
if (isVerboseOn()) {
ex.printStackTrace(err);
}
throw new ToolException(ex.getMessage(), ex.getCause());
}
}
use of org.apache.cxf.tools.corba.common.ProcessorEnvironment in project cxf by apache.
the class IDLToWSDLGenerationTest method testEncodingGeneration.
@Test
public void testEncodingGeneration() throws Exception {
try {
String sourceIdlFilename = "/idl/Enum.idl";
URL idl = getClass().getResource(sourceIdlFilename);
ProcessorEnvironment env = new ProcessorEnvironment();
Map<String, Object> cfg = new HashMap<>();
cfg.put(ToolCorbaConstants.CFG_IDLFILE, new File(idl.toURI()).getAbsolutePath());
cfg.put(ToolCorbaConstants.CFG_WSDL_ENCODING, "UTF-16");
env.setParameters(cfg);
IDLToWSDLProcessor processor = new IDLToWSDLProcessor();
processor.setEnvironment(env);
Writer out = processor.getOutputWriter("Enum.wsdl", ".");
if (out instanceof OutputStreamWriter) {
OutputStreamWriter writer = (OutputStreamWriter) out;
assertEquals("Encoding should be UTF-16", writer.getEncoding(), "UTF-16");
}
out.close();
} finally {
new File("Enum.wsdl").deleteOnExit();
}
}
use of org.apache.cxf.tools.corba.common.ProcessorEnvironment in project cxf by apache.
the class WSDLToProcessor method process.
public void process() throws ToolException {
if (env == null) {
env = new ProcessorEnvironment();
env.put("wsdlurl", wsdlDefinition.getDocumentBaseURI());
}
}
Aggregations