Skip to content

Commit

Permalink
#96
Browse files Browse the repository at this point in the history
  • Loading branch information
augustearth committed Aug 25, 2022
1 parent 4b6f683 commit a1f1861
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package carnival.core.util



import java.nio.file.Path
import java.nio.file.Files
import java.nio.file.SimpleFileVisitor
import java.nio.file.FileVisitResult
import java.nio.file.attribute.BasicFileAttributes



class FilesUtil {

static Path delete(Path start) {

Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException
{
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException e)
throws IOException
{
if (e == null) {
Files.delete(dir);
return FileVisitResult.CONTINUE;
} else {
// directory iteration failed
throw e;
}
}
});

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package carnival.core.graph



import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files

import spock.lang.Specification
import spock.lang.Unroll
import spock.lang.Shared
Expand All @@ -18,6 +22,7 @@ import org.neo4j.configuration.connectors.BoltConnector
import org.neo4j.configuration.helpers.SocketAddress*/

import carnival.graph.*
import carnival.core.util.FilesUtil



Expand Down Expand Up @@ -88,6 +93,28 @@ class CarnivalNeo4jSpec extends Specification {
}*/


def "test configuration graph directory"() {
when:
CarnivalNeo4jConfiguration conf2 = CarnivalNeo4jConfiguration.defaultConfiguration()
conf2.gremlin.neo4j.directory += "2"
assert conf2.gremlin.neo4j.directory.endsWith("2")
Path graphDir = Paths.get(conf2.gremlin.neo4j.directory)

then:
!Files.exists(graphDir)

when:
def carnival2 = CarnivalNeo4j.create(conf2)

then:
Files.exists(graphDir)

cleanup:
carnival2.graph.close()
FilesUtil.delete(graphDir)
}



@IgnoreIf({ !CarnivalNeo4jConfiguration.defaultConfiguration().gremlin.neo4j.conf.dbms.directories.plugins })
def "test apoc"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package carnival.core.vine


import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files
import groovy.transform.ToString
import spock.lang.Specification
import spock.lang.Shared

import carnival.core.util.FilesUtil


/**
JvsTestVine has to be top level classes.
Expand Down Expand Up @@ -202,6 +207,29 @@ class JsonVineSpec extends Specification {
cf.exists()
}


def "custom cache directory"() {
when:
def vine = new JvsTestVineDefault()
vine.vineConfiguration.cache.directory += "2"
Path cacheDirPath = Paths.get(vine.vineConfiguration.cache.directory)

then:
vine.vineConfiguration.cache.directory.endsWith("2")
!Files.exists(cacheDirPath)

when:
def vm = vine.method('PersonVineMethod')
.args(p1:'alice')
.call(CacheMode.OPTIONAL)

then:
Files.exists(cacheDirPath)

cleanup:
FilesUtil.delete(cacheDirPath)
}


def "default cache directory"() {
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class MappedDataTable extends DataTable {
*
* @param idVal The record identifier.
* @param fieldName The name of the field for which to get the value.
* @param args.verbose Defaults to [verbose:false].
* @param args.verbose Verbose logging; default is [verbose:false].
* @return The value of field fieldName for the record identified by idVal
* as a String if it exists, otherwise null.
*
Expand Down

0 comments on commit a1f1861

Please sign in to comment.