use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WSDLToJavaScriptTest method testGeneration.
// just run with a minimum of fuss.
@Test
public void testGeneration() throws Exception {
JavaScriptContainer container = new JavaScriptContainer(null);
ToolContext context = new ToolContext();
context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
context.put(ToolConstants.CFG_OUTPUTDIR, output.toString());
String[] prefixes = new String[1];
prefixes[0] = "http://apache.org/hello_world_soap_http=murble";
context.put(ToolConstants.CFG_JSPACKAGEPREFIX, prefixes);
container.setContext(context);
container.execute();
// now we really want to check some results.
Path path = FileSystems.getDefault().getPath(output.getPath(), "SOAPService_Test1.js");
assertTrue(Files.isReadable(path));
String javascript = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
assertTrue(javascript.contains("xmlns:murble='http://apache.org/hello_world_soap_http'"));
assertEquals("Number of '{' does not match number of '}' in generated JavaScript.", countChar(javascript, '{'), countChar(javascript, '}'));
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JavaToProcessorTest method testGetWSDLVersion.
@Test
public void testGetWSDLVersion() {
processor.setEnvironment(new ToolContext());
assertEquals(WSDLConstants.WSDLVersion.WSDL11, processor.getWSDLVersion());
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JaxwsServiceBuilderTest method setUp.
@Before
public void setUp() throws Exception {
JAXBContextCache.clearCaches();
builder = new JaxwsServiceBuilder();
builder.setBus(BusFactory.getDefaultBus());
generator.setBus(builder.getBus());
generator.setToolContext(new ToolContext());
Bus b = builder.getBus();
assertNotNull(b.getExtension(DestinationFactoryManager.class).getDestinationFactory("http://schemas.xmlsoap.org/soap/http"));
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WADLToJava method main.
public static void main(String[] pargs) {
System.setProperty("org.apache.cxf.JDKBugHacks.defaultUsesCaches", "true");
CommandInterfaceUtils.commandCommonMain();
WADLToJava w2j = new WADLToJava(pargs);
try {
w2j.run(new ToolContext());
} catch (ToolException ex) {
System.err.println();
System.err.println("WADLToJava Error: " + ex.getMessage());
System.err.println();
if (w2j.isVerbose()) {
ex.printStackTrace();
}
if (w2j.isExitOnFinish()) {
System.exit(1);
}
} catch (Exception ex) {
System.err.println("WADLToJava Error: " + ex.getMessage());
System.err.println();
if (w2j.isVerbose()) {
ex.printStackTrace();
}
if (w2j.isExitOnFinish()) {
System.exit(1);
}
}
if (w2j.isExitOnFinish()) {
System.exit(0);
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WrapperStyleNameCollisionValidator method isValidOperation.
private boolean isValidOperation(OperationInfo operation) {
ToolContext context = service.getProperty(ToolContext.class.getName(), ToolContext.class);
boolean c = context.optionSet(ToolConstants.CFG_AUTORESOLVE);
boolean valid = false;
if (operation.getUnwrappedOperation() == null) {
valid = true;
}
String operationName = operation.getName().getLocalPart();
operationName = ProcessorUtil.mangleNameToVariableName(operationName);
JAXWSBinding binding = operation.getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
binding = operation.getInterface().getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
binding = operation.getInterface().getService().getDescription().getExtensor(JAXWSBinding.class);
if (binding != null) {
if (!binding.isEnableWrapperStyle()) {
valid = true;
} else if (binding.getMethodName() != null) {
operationName = binding.getMethodName();
}
}
valid |= checkBare(context, operationName);
if (valid) {
return true;
}
MessagePartInfo input = null;
MessagePartInfo output = null;
if (operation.getInput() != null && operation.getInput().getMessagePartsNumber() == 1) {
input = operation.getInput().getFirstMessagePart();
}
if (operation.getOutput() != null && operation.getOutput().getMessagePartsNumber() == 1) {
output = operation.getOutput().getFirstMessagePart();
}
if (!c) {
Map<String, QName> names = new HashMap<>();
if (input != null) {
for (WrapperElement element : ProcessorUtil.getWrappedElement(context, input.getElementQName())) {
String mappedName = mapElementName(operation, operation.getUnwrappedOperation().getInput(), element);
if (names.containsKey(mappedName) && (names.get(mappedName) == element.getSchemaTypeName() || names.get(mappedName).equals(element.getSchemaTypeName()))) {
handleErrors(names.get(mappedName), element);
return false;
}
names.put(mappedName, element.getSchemaTypeName());
}
}
if (output != null) {
List<WrapperElement> els = ProcessorUtil.getWrappedElement(context, output.getElementQName());
if (els.size() > 1) {
for (WrapperElement element : els) {
String mappedName = mapElementName(operation, operation.getUnwrappedOperation().getOutput(), element);
QName mn = names.get(mappedName);
if (names.containsKey(mappedName) && !(mn == element.getSchemaTypeName() || (mn != null && mn.equals(element.getSchemaTypeName())))) {
handleErrors(names.get(mappedName), element);
return false;
}
names.put(mappedName, element.getSchemaTypeName());
}
}
}
}
return true;
}
Aggregations