/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with shapefiles, using an * absolute path to the data. */ @Test public void testShapeMappingsAbsolute() throws Exception { String mappingFileNameRelativeShape = "ArchSiteNillable.xml"; String configFilePathRelativeShape = getTestDirPath(mappingFileNameRelativeShape); String mappingFileNameAbsoluteShape = "ArchSiteAbsolute.xml"; String configFilePathAbsoluteShape = getTestDirPath(mappingFileNameAbsoluteShape); AppSchemaDataAccess dSAbsolute = null; try { // now lets test a mapping file with an absolute path to the shapefile // because we don't know the absolute path in advance, we must create the mapping file copyRelativeToAbsolute(configFilePathRelativeShape, configFilePathAbsoluteShape); // create the DataAccess based on shapefile configured with a absolute path dSAbsolute = buildDataAccess(mappingFileNameAbsoluteShape); // there should be a single target feature in this data access assertEquals(1, dSAbsolute.getNames().size()); // there should be 25 features in this data access assertEquals(25, countFeatures(dSAbsolute)); } finally { if (dSAbsolute != null) { dSAbsolute.dispose(); } } }
/** * Create the test directory. * * @see junit.framework.TestCase#setUp() */ @Before public void setUp() throws IOException { FileUtils.deleteDirectory(testDir); // copy all the test data into the test directory copyTestData("ArchSite.xsd", testDir); copyTestData("ArchSiteNillable.xml", testDir); copyTestData("AppSchemaFileDataTest.xml", testDir); copyTestData("PointFeatureGeomPropertyfile.properties", new File(testDir, "directory")); }
String resolvedPath = extendFilename(testDir.getPath(), relativePath); absolutePath = (new File(resolvedPath)).getAbsolutePath(); line = line.replace(relativePath, absolutePath);
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with shapefiles, using a * relative paths to the data */ @Test public void testShapeMappings() throws Exception { String mappingFileNameRelativeShape = "ArchSiteNillable.xml"; AppSchemaDataAccess dSRelative = null; try { // create the DataAccess based on shapefile configured with a relative path dSRelative = buildDataAccess(mappingFileNameRelativeShape); // there should be a single target feature in this data access assertEquals(1, dSRelative.getNames().size()); // there should be 25 features in this data access assertEquals(25, countFeatures(dSRelative)); } finally { if (dSRelative != null) { dSRelative.dispose(); } } }
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with *.properties files using a * relative and paths to the data just to be sure we didn't break these while we were playing * around with shapefiles. */ @Test public void testPropertiesMappings() throws Exception { String mappingFileNameRelativeProperties = "AppSchemaFileDataTest.xml"; AppSchemaDataAccess dSRelative = null; try { // create the DataAccess based on properties file configured with a relative path dSRelative = buildDataAccess(mappingFileNameRelativeProperties); // there should be a single target feature in this data access assertEquals(1, dSRelative.getNames().size()); // there should be 2 features in this data access assertEquals(2, countFeatures(dSRelative)); } finally { if (dSRelative != null) { dSRelative.dispose(); } } }
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with *.properties files using * an absolute path to the data just to be sure we didn't break these while we were playing * around with shapefiles. */ @Test public void testPropertiesMappingsAbsolute() throws Exception { String mappingFileNameRelativeProperties = "AppSchemaFileDataTest.xml"; String configFilePathRelativeProperties = getTestDirPath(mappingFileNameRelativeProperties); String mappingFileNameAbsoluteProperties = "AppSchemaFileDataTestAbsolute.xml"; String configFilePathAbsoluteProperties = getTestDirPath(mappingFileNameAbsoluteProperties); AppSchemaDataAccess dSAbsolute = null; try { // now let's test a mapping file with an absolute path to the properties file // because we don't know the absolute path in advance, we must create the mapping file copyRelativeToAbsolute( configFilePathRelativeProperties, configFilePathAbsoluteProperties); // create the DataAccess based on properties file configured with a absolute path dSAbsolute = buildDataAccess(mappingFileNameAbsoluteProperties); // there should be a single target feature in this data access assertEquals(1, dSAbsolute.getNames().size()); // there should be 2 features in this data access assertEquals(2, countFeatures(dSAbsolute)); } finally { if (dSAbsolute != null) { dSAbsolute.dispose(); } } }
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with *.properties files using a * relative and paths to the data just to be sure we didn't break these while we were playing * around with shapefiles. */ @Test public void testPropertiesMappings() throws Exception { String mappingFileNameRelativeProperties = "AppSchemaFileDataTest.xml"; AppSchemaDataAccess dSRelative = null; try { // create the DataAccess based on properties file configured with a relative path dSRelative = buildDataAccess(mappingFileNameRelativeProperties); // there should be a single target feature in this data access assertEquals(1, dSRelative.getNames().size()); // there should be 2 features in this data access assertEquals(2, countFeatures(dSRelative)); } finally { if (dSRelative != null) { dSRelative.dispose(); } } }
private AppSchemaDataAccess buildDataAccess(String mappingsFileName) throws Exception { // generate the path to a mappings-file in the resources directory String configFilePath = extendFilename(testDir.getPath(), mappingsFileName); URL configFileUrl = URLs.fileToUrl(new File(configFilePath)); // parse the mappings-file XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // generate the set of mappings needed to build the application-schema datastore Set<FeatureTypeMapping> mappings; mappings = AppSchemaDataAccessConfigurator.buildMappings(config); AppSchemaDataAccess datastore = new AppSchemaDataAccess(mappings); return datastore; }
/** * Create the test directory. * * @see junit.framework.TestCase#setUp() */ @Before public void setUp() throws IOException { FileUtils.deleteDirectory(testDir); // copy all the test data into the test directory copyTestData("ArchSite.xsd", testDir); copyTestData("ArchSiteNillable.xml", testDir); copyTestData("AppSchemaFileDataTest.xml", testDir); copyTestData("PointFeatureGeomPropertyfile.properties", new File(testDir, "directory")); }
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with *.properties files using * an absolute path to the data just to be sure we didn't break these while we were playing * around with shapefiles. */ @Test public void testPropertiesMappingsAbsolute() throws Exception { String mappingFileNameRelativeProperties = "AppSchemaFileDataTest.xml"; String configFilePathRelativeProperties = getTestDirPath(mappingFileNameRelativeProperties); String mappingFileNameAbsoluteProperties = "AppSchemaFileDataTestAbsolute.xml"; String configFilePathAbsoluteProperties = getTestDirPath(mappingFileNameAbsoluteProperties); AppSchemaDataAccess dSAbsolute = null; try { // now let's test a mapping file with an absolute path to the properties file // because we don't know the absolute path in advance, we must create the mapping file copyRelativeToAbsolute(configFilePathRelativeProperties, configFilePathAbsoluteProperties); // create the DataAccess based on properties file configured with a absolute path dSAbsolute = buildDataAccess(mappingFileNameAbsoluteProperties); // there should be a single target feature in this data access assertEquals(1, dSAbsolute.getNames().size()); // there should be 2 features in this data access assertEquals(2, countFeatures(dSAbsolute)); } finally { if (dSAbsolute != null) { dSAbsolute.dispose(); } } }
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with shapefiles, using a * relative paths to the data */ @Test public void testShapeMappings() throws Exception { String mappingFileNameRelativeShape = "ArchSiteNillable.xml"; AppSchemaDataAccess dSRelative = null; try { // create the DataAccess based on shapefile configured with a relative path dSRelative = buildDataAccess(mappingFileNameRelativeShape); // there should be a single target feature in this data access assertEquals(1, dSRelative.getNames().size()); // there should be 25 features in this data access assertEquals(25, countFeatures(dSRelative)); } finally { if (dSRelative != null) { dSRelative.dispose(); } } }
String resolvedPath = extendFilename(testDir.getPath(), relativePath); absolutePath = (new File(resolvedPath)).getAbsolutePath(); line = line.replace(relativePath, absolutePath);
/** * Test the AppSchemaDataAccessConfigurator.buildMappings method with shapefiles, using an * absolute path to the data. */ @Test public void testShapeMappingsAbsolute() throws Exception { String mappingFileNameRelativeShape = "ArchSiteNillable.xml"; String configFilePathRelativeShape = getTestDirPath(mappingFileNameRelativeShape); String mappingFileNameAbsoluteShape = "ArchSiteAbsolute.xml"; String configFilePathAbsoluteShape = getTestDirPath(mappingFileNameAbsoluteShape); AppSchemaDataAccess dSAbsolute = null; try { // now lets test a mapping file with an absolute path to the shapefile // because we don't know the absolute path in advance, we must create the mapping file copyRelativeToAbsolute(configFilePathRelativeShape, configFilePathAbsoluteShape); // create the DataAccess based on shapefile configured with a absolute path dSAbsolute = buildDataAccess(mappingFileNameAbsoluteShape); // there should be a single target feature in this data access assertEquals(1, dSAbsolute.getNames().size()); // there should be 25 features in this data access assertEquals(25, countFeatures(dSAbsolute)); } finally { if (dSAbsolute != null) { dSAbsolute.dispose(); } } }
private AppSchemaDataAccess buildDataAccess(String mappingsFileName) throws Exception { // generate the path to a mappings-file in the resources directory String configFilePath = extendFilename(testDir.getPath(), mappingsFileName); URL configFileUrl = DataUtilities.fileToURL(new File(configFilePath)); // parse the mappings-file XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // generate the set of mappings needed to build the application-schema datastore Set<FeatureTypeMapping> mappings; mappings = AppSchemaDataAccessConfigurator.buildMappings(config); AppSchemaDataAccess datastore = new AppSchemaDataAccess(mappings); return datastore; }