use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class FileProjectSaverTest method testSaveForProjectFileWithRelatedPaths.
/**
* Method test fix for CAY-1780. If specify related fragments (for example ./../)
* in target file path then file must be created successfully.
*
* @throws Exception
*/
@Test
public void testSaveForProjectFileWithRelatedPaths() throws Exception {
File testFolder = setupTestDirectory("testSaveForProjectFileWithRelatedPaths");
String mapFilePath = testFolder.toURI() + "../test.map.xml";
String mapFileName = "test";
DataMap testDataMap = new DataMap(mapFileName);
testDataMap.setConfigurationSource(new URLResource(new URL(mapFilePath)));
Project project = new Project(new ConfigurationTree<DataMap>(testDataMap));
saver.save(project);
File target = new File(testFolder.getParentFile(), mapFileName + ".map.xml");
assertTrue(target.isFile());
}
use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class DefaultUpgradeServiceTest method getAdditionalDatamapResources.
@Test
public void getAdditionalDatamapResources() throws Exception {
URL url = getClass().getResource("../cayenne-PROJECT1.xml");
Resource resource = new URLResource(url);
Document document = readDocument(url);
UpgradeUnit unit = new UpgradeUnit(resource, document);
List<Resource> resources = upgradeService.getAdditionalDatamapResources(unit);
assertEquals(2, resources.size());
assertTrue(resources.get(0).getURL().sameFile(getClass().getResource("../testProjectMap1_1.map.xml")));
}
use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class BaseUpgradeHandlerTest method processDataMapDom.
Document processDataMapDom(String xmlResourceName) throws Exception {
UpgradeUnit unit = new UpgradeUnit(new URLResource(getClass().getResource(xmlResourceName)), documentFromResource(xmlResourceName));
handler.processDataMapDom(unit);
return unit.getDocument();
}
use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class BaseUpgradeHandlerTest method processProjectDom.
Document processProjectDom(String xmlResourceName) throws Exception {
UpgradeUnit unit = new UpgradeUnit(new URLResource(getClass().getResource(xmlResourceName)), documentFromResource(xmlResourceName));
handler.processProjectDom(unit);
return unit.getDocument();
}
use of org.apache.cayenne.resource.URLResource in project cayenne by apache.
the class DefaultDbImportActionTest method testSaveLoadedNoProject.
@Test
public void testSaveLoadedNoProject() throws Exception {
Logger log = mock(Logger.class);
Injector i = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(log), new DbImportModule());
DbImportConfiguration params = mock(DbImportConfiguration.class);
when(params.getCayenneProject()).thenReturn(null);
URL outUrl = new URL(getPackageURL(), "dbimport/testSaveLoaded1.map.xml");
DefaultDbImportAction action = (DefaultDbImportAction) i.getInstance(DbImportAction.class);
File out = new File(outUrl.toURI());
out.delete();
assertFalse(out.exists());
DataMap map = new DataMap("testSaveLoaded1");
map.setConfigurationSource(new URLResource(outUrl));
action.saveLoaded(map, params);
assertTrue(out.isFile());
String contents = Util.stringFromFile(out);
assertTrue("Has no project version saved", contents.contains("project-version=\""));
}
Aggregations