use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class XMLDataChannelDescriptorLoaderTest method testLoadDataEverything.
@Test
public void testLoadDataEverything() {
// create and initialize loader instance to test
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
String testConfigName = "testConfig3";
URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
assertNotNull(tree);
DataChannelDescriptor descriptor = tree.getRootNode();
assertNotNull(descriptor);
assertEquals(testConfigName, descriptor.getName());
Collection<DataMap> maps = descriptor.getDataMaps();
assertEquals(2, maps.size());
Iterator<DataMap> mapsIt = maps.iterator();
DataMap map1 = mapsIt.next();
DataMap map2 = mapsIt.next();
assertEquals("testConfigMap3_1", map1.getName());
assertEquals("testConfigMap3_2", map2.getName());
Collection<DataNodeDescriptor> nodes = descriptor.getNodeDescriptors();
assertEquals(1, nodes.size());
DataNodeDescriptor node1 = nodes.iterator().next();
assertEquals("testConfigNode3", node1.getName());
assertNull(node1.getParameters());
assertNotNull(node1.getDataSourceDescriptor());
assertEquals(1, node1.getDataSourceDescriptor().getMinConnections());
assertEquals(1, node1.getDataSourceDescriptor().getMaxConnections());
assertEquals("org.example.test.Adapter", node1.getAdapterType());
assertEquals("org.example.test.DataSourceFactory", node1.getDataSourceFactoryType());
assertEquals("org.example.test.SchemaUpdateStartegy", node1.getSchemaUpdateStrategyType());
assertNotNull(node1.getDataMapNames());
assertEquals(1, node1.getDataMapNames().size());
assertEquals("testConfigMap3_2", node1.getDataMapNames().iterator().next());
}
use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class XMLDataChannelDescriptorLoaderTest method testLoadEmpty.
@Test
public void testLoadEmpty() {
// create and initialize loader instance to test
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
String testConfigName = "testConfig1";
URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
assertNotNull(tree);
assertNotNull(tree.getRootNode());
assertEquals(testConfigName, tree.getRootNode().getName());
}
use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class XMLDataChannelDescriptorLoaderTest method testLoadDataMap.
@Test
public void testLoadDataMap() {
// create and initialize loader instance to test
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
String testConfigName = "testConfig2";
URL url = getClass().getResource("cayenne-" + testConfigName + ".xml");
ConfigurationTree<DataChannelDescriptor> tree = loader.load(new URLResource(url));
assertNotNull(tree);
assertNotNull(tree.getRootNode());
assertEquals(testConfigName, tree.getRootNode().getName());
Collection<DataMap> maps = tree.getRootNode().getDataMaps();
assertEquals(1, maps.size());
assertEquals("testConfigMap2", maps.iterator().next().getName());
}
use of org.apache.cayenne.configuration.DataChannelDescriptor 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.DataChannelDescriptor 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