I want to use the embedded driver with an absolute path, but this will always throw an exception in EmbeddedDriver.createPermanentFileStore(String). The path I want to use does not exist!
Maybe a very simple workaround is to use file.toPath() instead of Paths.get( uri.getRawPath() ). This will work with the 1. and 3. uri.
Testcase:
import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Test;
public class EmbeddedDriverWithAbsolutePath {
@Test
public void test() {
final String[] uris = new String[] {
// URI shown in Firefox
// => java.nio.file.InvalidPathException: Illegal char <:> at index 2: /D:/git/xom/core/temp/neo4j-junit/
// This one should work!
"file:///D:/temp/neo4j-junit/",
// 2. test
// => java.lang.IllegalArgumentException: URI has an authority component
"file://D:/temp/neo4j-junit/",
// URI when i use new File("d:/ ....).toURI().toString()
// => java.nio.file.InvalidPathException: Illegal char <:> at index 2: /D:/git/xom/core/temp/neo4j-junit/
// This one should work!
"file:/D:/temp/neo4j-junit/",
// 4. Test
// => java.lang.IllegalArgumentException: URI is not hierarchical
"file:D:/temp/neo4j-junit/" };
for ( final String strPath : uris ) {
try {
final URI uri = new URI( strPath );
final File file = new File( uri );
if ( !file.exists() ) {
final Path graphDir = Files.createDirectories( Paths.get( uri.getRawPath() ) );
// Possible workaround:
final Path graphDirWorking = Files.createDirectories( file.toPath() );
}
}
catch ( final Exception e ) {
System.out.println( "URI: " + strPath );
e.printStackTrace();
}
}
}
}
Neo4j OGM Version 2.0.3 / Java 8 / Windows 10
I want to use the embedded driver with an absolute path, but this will always throw an exception in EmbeddedDriver.createPermanentFileStore(String). The path I want to use does not exist!
Maybe a very simple workaround is to use
file.toPath()
instead ofPaths.get( uri.getRawPath() )
. This will work with the 1. and 3. uri.Testcase: