use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class XMLDataChannelDescriptorLoaderTest method loadInvalidNamespace.
@Test(expected = CayenneRuntimeException.class)
public void loadInvalidNamespace() throws Exception {
XMLDataChannelDescriptorLoader loader = new XMLDataChannelDescriptorLoader();
injector.injectMembers(loader);
URL url = getClass().getResource("cayenne-testConfig5.xml");
loader.load(new URLResource(url));
}
use of org.apache.cayenne.resource.URLResource 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.resource.URLResource in project cayenne by apache.
the class XMLDataMapLoaderTest method loadEmptyConfig.
@Test
public void loadEmptyConfig() throws Exception {
URL url = getClass().getResource("testConfigMap2.map.xml");
DataMap map = loader.load(new URLResource(url));
assertNotNull(map);
assertEquals("testConfigMap2", map.getName());
assertTrue(map.getDbEntities().isEmpty());
assertTrue(map.getObjEntities().isEmpty());
assertTrue(map.getProcedures().isEmpty());
assertTrue(map.getQueryDescriptors().isEmpty());
assertTrue(map.getEmbeddables().isEmpty());
assertNull(map.getDefaultCatalog());
assertNull(map.getDefaultSchema());
assertNull(map.getDefaultPackage());
assertFalse(map.isClientSupported());
}
use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class XMLDataMapLoaderTest method loadWrongVersionConfig.
@Test(expected = CayenneRuntimeException.class)
public void loadWrongVersionConfig() throws Exception {
URL url = getClass().getResource("testConfigMap5.map.xml");
loader.load(new URLResource(url));
}
use of org.apache.cayenne.resource.URLResource 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());
}
}
}
Aggregations