Skip to content

Commit

Permalink
[GEOT-6045] Unnecessary assert prevents EPSG HSQL database in path wi…
Browse files Browse the repository at this point in the history
…th spaces
  • Loading branch information
bencaradocdavies committed Jun 20, 2018
1 parent fdb6995 commit dd12933
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions modules/plugin/epsg-hsql/pom.xml
Expand Up @@ -132,6 +132,11 @@
<artifactId>commons-dbcp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
Expand Down
Expand Up @@ -211,7 +211,6 @@ protected DataSource createDataSource() throws SQLException {
url.append(DATABASE_NAME);
url.append(";shutdown=true;readonly=true");
source.setDatabase(url.toString());
assert directory.equals(getDirectory(source)) : url;
}
/*
* If the temporary directory do not exists or can't be created, lets the 'database'
Expand Down
Expand Up @@ -16,10 +16,16 @@
*/
package org.geotools.referencing.factory.epsg;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.lang.reflect.Method;
import java.util.Set;
import org.apache.commons.io.FileUtils;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.AbstractIdentifiedObject;
import org.geotools.referencing.CRS;
Expand Down Expand Up @@ -331,4 +337,29 @@ public void testDelay() throws Exception {
factory.getAuthorityCodes(CoordinateReferenceSystem.class);
assertTrue(factory.isConnected());
}

/** Test data source creation when <code>java.io.tmpdir</code> contains spaces. */
@Test
public void testTmpWithSpaces() throws Exception {
final String JAVA_IO_TMPDIR_PROPERTY = "java.io.tmpdir";
String oldTmpDir = System.getProperty(JAVA_IO_TMPDIR_PROPERTY);
File tmpDir = new File("target/tmp with spaces");
FileUtils.deleteQuietly(tmpDir);
tmpDir.mkdirs();
try {
System.setProperty(JAVA_IO_TMPDIR_PROPERTY, tmpDir.getPath());
// force data source re-creation
factory.dispose();
assertNotNull(factory.createCoordinateReferenceSystem("EPSG:4326"));
String creationMarker =
String.format(
"Geotools/Databases/HSQL/v%s/EPSG_creation_marker.txt",
ThreadedHsqlEpsgFactory.VERSION);
assertTrue((new File(tmpDir, creationMarker)).exists());
} finally {
System.setProperty(JAVA_IO_TMPDIR_PROPERTY, oldTmpDir);
factory.dispose();
FileUtils.deleteQuietly(tmpDir);
}
}
}

0 comments on commit dd12933

Please sign in to comment.