use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testNoTargetNamespace.
@Test
public void testNoTargetNamespace() {
try {
JAXRSContainer container = new JAXRSContainer(null);
ToolContext context = new ToolContext();
context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceSchemaNoTargetNamespace.xml"));
context.put(WadlToolConstants.CFG_SCHEMA_PACKAGENAME, "=custom");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
List<File> files = FileUtils.getFilesRecurse(output, ".+\\.class" + "$");
assertEquals(3, files.size());
assertTrue(checkContains(files, "application" + ".Resource.class"));
assertTrue(checkContains(files, "custom" + ".TestCompositeObject.class"));
assertTrue(checkContains(files, "custom" + ".ObjectFactory.class"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testResourceWithEPRNoSchemaGen.
@Test
public void testResourceWithEPRNoSchemaGen() {
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/2005/08/addressing}EndpointReferenceType=" + "javax.xml.ws.wsaddressing.W3CEndpointReference");
context.put(WadlToolConstants.CFG_NO_ADDRESS_BINDING, "true");
context.put(WadlToolConstants.CFG_NO_TYPES, "true");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
assertEquals(1, files.size());
assertTrue(checkContains(files, "application" + ".BookstoreResource.class"));
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenWithImportedSchema.
@Test
public void testCodeGenWithImportedSchema() {
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_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();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenInterfaceAndImpl.
@Test
public void testCodeGenInterfaceAndImpl() {
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_INTERFACE, "true");
context.put(WadlToolConstants.CFG_IMPL, "true");
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
verifyFiles("java", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 14, true);
verifyFiles("class", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 14, true);
} catch (Exception e) {
fail();
e.printStackTrace();
}
}
use of org.apache.cxf.tools.common.ToolContext in project cxf by apache.
the class JAXRSContainerTest method testCodeGenInterfacesWithJaxbClassNameSuffix.
@Test
public void testCodeGenInterfacesWithJaxbClassNameSuffix() {
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_JAXB_CLASS_NAME_SUFFIX, "DTO");
context.put(WadlToolConstants.CFG_BINDING, getLocation("/wadl/jaxbSchemaBindings.xml"));
context.put(WadlToolConstants.CFG_COMPILE, "true");
container.setContext(context);
container.execute();
assertNotNull(output.list());
List<File> schemafiles = FileUtils.getFilesRecurse(output, ".+\\." + "java" + "$");
assertEquals(10, schemafiles.size());
doVerifyTypesWithSuffix(schemafiles, "superbooks", "java");
List<File> classfiles = FileUtils.getFilesRecurse(output, ".+\\." + "class" + "$");
assertEquals(10, classfiles.size());
doVerifyTypesWithSuffix(classfiles, "superbooks", "class");
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations