use of org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader in project cayenne by apache.
the class DBCleaner method clean.
public void clean() throws SQLException {
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
URL url = getClass().getClassLoader().getResource(location);
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
for (DataMap map : tree.getRootNode().getDataMaps()) {
List<DbEntity> entities = schemaBuilder.dbEntitiesInDeleteOrder(map);
for (DbEntity entity : entities) {
dbHelper.deleteAll(entity.getName());
}
}
}
use of org.apache.cayenne.configuration.xml.XMLDataChannelDescriptorLoader in project cayenne by apache.
the class ManyToManyCandidateEntityTest method setUp.
@Before
public void setUp() throws Exception {
Module testModule = binder -> {
binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);
binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);
binder.bind(HandlerFactory.class).to(DefaultHandlerFactory.class);
binder.bind(DataChannelMetaData.class).to(NoopDataChannelMetaData.class);
binder.bind(XMLReader.class).toProviderInstance(new XMLReaderProvider(false)).withoutScope();
};
Injector injector = DIBootstrap.createInjector(testModule);
// create and initialize loader instance to test
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
String testConfigName = "relationship-optimisation";
URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
map = tree.getRootNode().getDataMap(testConfigName);
}
Aggregations