use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class ValidateWadlTest method testInvalidWadl.
@Test
public void testInvalidWadl() throws Exception {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/invalidWadl.xml"));
context.put(WadlToolConstants.CFG_VALIDATE_WADL, "true");
container.setContext(context);
container.execute();
fail("Validation exception expected");
} catch (ValidationException e) {
// expected
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WADLToJavaTest method testGenerateJAXBToString.
@Test
public void testGenerateJAXBToString() throws Exception {
try {
String[] args = new String[] { "-d", output.getCanonicalPath(), "-p", "custom.service", "-async getName,delete", "-compile", "-xjc-episode " + output.getAbsolutePath() + "/test.episode", "-xjc-XtoString", getLocation("/wadl/bookstore.xml") };
WADLToJava tool = new WADLToJava(args);
tool.run(new ToolContext());
assertNotNull(output.list());
verifyFiles("java", true, false, "superbooks", "custom.service");
verifyFiles("class", true, false, "superbooks", "custom.service");
assertTrue(new File(output.getAbsolutePath() + "/test.episode").exists());
List<Class<?>> schemaClassFiles = getSchemaClassFiles();
assertEquals(4, schemaClassFiles.size());
for (Class<?> c : schemaClassFiles) {
c.getMethod("toString");
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WADLToJavaTest method testCodeGenInterfaces.
@Test
public void testCodeGenInterfaces() {
try {
String[] args = new String[] { "-d", output.getCanonicalPath(), "-p", "custom.service", "-tMap", "{http://www.w3.org/2001/XMLSchema}date=java.util.List..String", "-async getName,delete", "-inheritResourceParams first", "-compile", getLocation("/wadl/bookstore.xml") };
WADLToJava tool = new WADLToJava(args);
tool.run(new ToolContext());
assertNotNull(output.list());
verifyFiles("java", true, false, "superbooks", "custom.service");
verifyFiles("class", true, false, "superbooks", "custom.service");
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WSDLToJavaContainerTest method testValidateorSuppressWarningsIsOn.
@Test
public void testValidateorSuppressWarningsIsOn() throws Exception {
WSDLToJavaContainer container = new WSDLToJavaContainer("dummy", null);
ToolContext context = new ToolContext();
context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
container.setContext(context);
try {
container.execute();
} catch (ToolException te) {
assertEquals(getLogMessage("FOUND_NO_FRONTEND"), te.getMessage());
} catch (Exception e) {
fail("Should not throw any exception but ToolException.");
}
assertTrue(context.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class WSDLToJavaContainerTest method testNoPlugin.
@Test
public void testNoPlugin() throws Exception {
WSDLToJavaContainer container = new WSDLToJavaContainer("dummy", null);
ToolContext context = new ToolContext();
context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
container.setContext(context);
try {
container.execute();
} catch (ToolException te) {
assertEquals(getLogMessage("FOUND_NO_FRONTEND"), te.getMessage());
} catch (Exception e) {
fail("Should not throw any exception but ToolException.");
}
}
Aggregations