use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenImpl.
@Test
public void testCodeGenImpl() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
context.put(WadlToolConstants.CFG_IMPL, "true");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
} catch (Exception e) {
fail();
e.printStackTrace();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenTypesOnly.
@Test
public void testCodeGenTypesOnly() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
context.put(WadlToolConstants.CFG_TYPES, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
verifyTypes("superbooks", "java", true);
} catch (Exception e) {
fail();
e.printStackTrace();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testResourceWithEPR.
@Test
public void testResourceWithEPR() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceWithEPR.xml"));
context.put(WadlToolConstants.CFG_SCHEMA_TYPE_MAP, "{http://www.w3.org/2001/XMLSchema}date=javax.xml.datatype.XMLGregorianCalendar");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
assertEquals(4, files.size());
assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
assertTrue(checkContains(files, "superbooks" + ".Book.class"));
assertTrue(checkContains(files, "superbooks" + ".ObjectFactory.class"));
assertTrue(checkContains(files, "superbooks" + ".package-info.class"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenInterfaces.
@Test
public void testCodeGenInterfaces() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstore.xml"));
context.put(WadlToolConstants.CFG_MEDIA_TYPE_MAP, "application/xml=javax.xml.transform.Source");
context.put(WadlToolConstants.CFG_MEDIA_TYPE_MAP, "multipart/form-data=org.apache.cxf.jaxrs.ext.multipart.MultipartBody");
context.put(WadlToolConstants.CFG_NO_VOID_FOR_EMPTY_RESPONSES, "true");
context.put(WadlToolConstants.CFG_GENERATE_RESPONSE_IF_HEADERS_SET, "true");
context.put(WadlToolConstants.CFG_GENERATE_RESPONSE_FOR_METHODS, "getName");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 11, true);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenWithImportedSchemaAndBinding.
@Test
public void testCodeGenWithImportedSchemaAndBinding() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/bookstoreImport.xml"));
context.put(WadlToolConstants.CFG_BINDING, getLocation("/wadl/jaxbBindingWithSchemaLoc.xml"));
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
verifyFiles("java", false, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 9);
verifyFiles("class", false, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 9);
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations