Skip to content

Commit

Permalink
Tentative fix for the Window build
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegrohmann committed Sep 17, 2015
1 parent 623bf5d commit 2f27f07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Expand Up @@ -22,16 +22,25 @@ package org.neo4j.cypher.internal.compiler.v2_3.pipes
import java.net.{URI, URL}
import java.nio.file.Paths

import org.apache.commons.lang3.SystemUtils
import org.neo4j.cypher.internal.compiler.v2_3.ExecutionContext
import org.neo4j.cypher.internal.frontend.v2_3.symbols.CTNumber
import org.neo4j.cypher.internal.frontend.v2_3.test_helpers.CypherFunSuite

class LoadCSVPipeTest extends CypherFunSuite with PipeTestSupport {

test("should map unix path") {
val url = new URL("file:///tmp/data/import.csv")
val url = if (SystemUtils.IS_OS_WINDOWS)
new URL("file:///C:/tmp/data/import.csv")
else
new URL("file:///tmp/data/import.csv")

val path = Paths.get(url.toURI)
path.toAbsolutePath should equal( Paths.get("/tmp", "data", "import.csv") )

val prefix = if (SystemUtils.IS_OS_WINDOWS)
"C:\\tmp"
else
"/tmp"
path.toAbsolutePath should equal(Paths.get(prefix, "data", "import.csv"))
}
}
Expand Up @@ -19,6 +19,7 @@
*/
package org.neo4j.kernel.impl.security;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Test;

import java.net.URL;
Expand Down Expand Up @@ -91,14 +92,19 @@ public void shouldThrowWhenFileAccessIsDisabled() throws Exception
@Test
public void shouldAdjustURLToWithinImportDirectory() throws Exception
{
final URL url = new URL( "file:///bar/baz.csv" );
final URL url = SystemUtils.IS_OS_WINDOWS
? new URL( "file:///C:/bar/baz.csv" )
: new URL( "file:///bar/baz.csv" );
final GraphDatabaseAPI gdb = mock( GraphDatabaseAPI.class );
final DependencyResolver mockResolver = mock( DependencyResolver.class );
when( gdb.getDependencyResolver() ).thenReturn( mockResolver );
final Config config = new Config( MapUtil.stringMap( GraphDatabaseSettings.load_csv_file_url_root.name(), "/var/lib/neo4j/import" ) );
when( mockResolver.resolveDependency( eq( Config.class ) ) ).thenReturn( config );

URL accessURL = URLAccessRules.fileAccess().validate( gdb, url );
assertThat( accessURL, equalTo( new URL( "file:///var/lib/neo4j/import/bar/baz.csv" ) ) );
URL expected = SystemUtils.IS_OS_WINDOWS
? new URL( "file:///C:/var/lib/neo4j/import/bar/baz.csv" )
: new URL( "file:///var/lib/neo4j/import/bar/baz.csv" );
assertThat( accessURL, equalTo( expected ) );
}
}

0 comments on commit 2f27f07

Please sign in to comment.