From eeb04c328ea72ecb7180ae6b64a66f60b01a436c Mon Sep 17 00:00:00 2001 From: Stefan Plantikow Date: Wed, 15 Jun 2016 19:20:40 +0200 Subject: [PATCH] Factor tck suite tooling into separate module o Remove old DatabaseConfigProvider cucumber plugin o Restructure directory layout of db-config provisioning --- community/cypher/compatibility-suite/pom.xml | 79 +----- .../test/java/cypher/UnpackedResources.java | 2 +- ...ps.scala => CompatibilitySuiteSteps.scala} | 12 +- community/cypher/pom.xml | 1 + .../feature/parser/CypherMatchersCreator.java | 0 .../parser/CypherParametersCreator.java | 0 .../feature/parser/ParsingErrorListener.java | 0 .../cypher/feature/parser/ResultsParser.java | 0 .../parser/matchers/BooleanMatcher.java | 0 .../feature/parser/matchers/FloatMatcher.java | 0 .../parser/matchers/IntegerMatcher.java | 0 .../feature/parser/matchers/ListMatcher.java | 0 .../feature/parser/matchers/MapMatcher.java | 0 .../feature/parser/matchers/Matcher.java | 0 .../feature/parser/matchers/NodeMatcher.java | 0 .../parser/matchers/PathLinkMatcher.java | 0 .../feature/parser/matchers/PathMatcher.java | 0 .../matchers/QueryStatisticsMatcher.java | 0 .../parser/matchers/RelationshipMatcher.java | 0 .../parser/matchers/ResultMatcher.java | 0 .../parser/matchers/ResultWrapper.java | 0 .../feature/parser/matchers/RowMatcher.java | 0 .../parser/matchers/StringMatcher.java | 0 .../parser/matchers/TckSerializer.java | 0 .../parser/matchers/UnorderedListMatcher.java | 0 .../feature/parser/matchers/ValueMatcher.java | 0 .../reporting/CombinationChartWriter.java | 0 .../parser/reporting/CoverageChartWriter.java | 0 .../cypher/cucumber/CucumberAdapter.scala | 0 .../cypher/cucumber/db/DatabaseArchive.scala | 0 .../cucumber/db/DatabaseConfigProvider.scala | 0 .../cypher/cucumber/db/DeleteDirectory.scala | 0 .../cypher/cucumber/db/GraphArchive.scala | 0 .../cucumber/db/GraphArchiveImporter.scala | 0 .../cucumber/db/GraphArchiveLibrary.scala | 4 - .../cucumber/db/GraphFileRepository.scala | 16 +- .../cucumber/db/GraphRecipeLoader.scala | 0 .../scala/cypher/cucumber/db/package.scala | 0 .../feature/parser/ParsingFunctions.scala | 0 .../reporting/CypherResultReporter.scala | 0 .../cypher/feature/reporting/JsonResult.scala | 0 .../feature/reporting/OutputProducer.scala | 0 .../src/test/java/cypher/MapRow.java | 0 .../feature/parser/ParsingTestSupport.scala | 0 .../parser/expectedResultsParserTest.scala | 0 .../parser/matchers/BooleanMatcherTest.scala | 0 .../parser/matchers/FloatMatcherTest.scala | 0 .../parser/matchers/IntegerMatcherTest.scala | 0 .../parser/matchers/ListMatcherTest.scala | 0 .../parser/matchers/MapMatcherTest.scala | 0 .../parser/matchers/NodeMatcherTest.scala | 0 .../parser/matchers/PathLinkMatcherTest.scala | 0 .../parser/matchers/PathMatcherTest.scala | 0 .../matchers/RelationshipMatcherTest.scala | 0 .../parser/matchers/ResultMatcherTest.scala | 0 .../parser/matchers/RowMatcherTest.scala | 0 .../parser/matchers/StringMatcherTest.scala | 0 .../parser/matchers/TckSerializerTest.scala | 0 .../matchers/UnorderedListMatcherTest.scala | 0 .../parser/matchers/ValueMatcherTest.scala | 0 .../feature/parser/paramsParserTest.scala | 0 .../CombinationChartWriterTest.scala | 0 .../feature/parser/statisticsParserTest.scala | 0 .../cypher/feature/steps/SpecSuiteSteps.scala | 236 ++++++++++++++++++ .../feature/steps/TCKErrorHandler.scala | 0 65 files changed, 252 insertions(+), 98 deletions(-) rename community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/{CypherTCKSteps.scala => CompatibilitySuiteSteps.scala} (89%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/CypherMatchersCreator.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/CypherParametersCreator.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/ParsingErrorListener.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/ResultsParser.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/BooleanMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/FloatMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/IntegerMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/ListMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/MapMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/Matcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/NodeMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/PathLinkMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/PathMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/QueryStatisticsMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/RelationshipMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/ResultMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/ResultWrapper.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/RowMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/StringMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/TckSerializer.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/UnorderedListMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/matchers/ValueMatcher.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/reporting/CombinationChartWriter.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/java/cypher/feature/parser/reporting/CoverageChartWriter.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/scala/cypher/cucumber/CucumberAdapter.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/DatabaseArchive.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/DatabaseConfigProvider.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/DeleteDirectory.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/GraphArchive.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/GraphArchiveImporter.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/GraphArchiveLibrary.scala (95%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/GraphFileRepository.scala (66%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/GraphRecipeLoader.scala (100%) rename community/cypher/{compatibility-suite/src/test => spec-suite-tools/src/main}/scala/cypher/cucumber/db/package.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/scala/cypher/feature/parser/ParsingFunctions.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/scala/cypher/feature/reporting/CypherResultReporter.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/scala/cypher/feature/reporting/JsonResult.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/main/scala/cypher/feature/reporting/OutputProducer.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/java/cypher/MapRow.java (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/ParsingTestSupport.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/expectedResultsParserTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/ListMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/MapMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/NodeMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/PathLinkMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/PathMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/RelationshipMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/ResultMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/RowMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/StringMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/TckSerializerTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/UnorderedListMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/matchers/ValueMatcherTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/paramsParserTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/reporting/CombinationChartWriterTest.scala (100%) rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/parser/statisticsParserTest.scala (100%) create mode 100644 community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/SpecSuiteSteps.scala rename community/cypher/{compatibility-suite => spec-suite-tools}/src/test/scala/cypher/feature/steps/TCKErrorHandler.scala (100%) diff --git a/community/cypher/compatibility-suite/pom.xml b/community/cypher/compatibility-suite/pom.xml index f237184120bd1..9c6e742d8e39b 100644 --- a/community/cypher/compatibility-suite/pom.xml +++ b/community/cypher/compatibility-suite/pom.xml @@ -87,46 +87,6 @@ - - org.opencypher - tck - ${opencypher.version} - - - - org.opencypher - grammar - ${opencypher.version} - - - - - - org.codehaus.jackson - jackson-core-asl - test - - - - org.codehaus.jackson - jackson-mapper-asl - test - - - - - - org.jfree - jfreechart - 1.0.19 - - - - org.apache.xmlgraphics - batik-svggen - 1.8 - - @@ -148,7 +108,6 @@ - org.scalautils scalautils_2.11 @@ -160,7 +119,6 @@ - org.scalacheck scalacheck_2.11 @@ -169,11 +127,6 @@ - - org.neo4j - neo4j-kernel - - org.neo4j neo4j-cypher @@ -181,16 +134,11 @@ test - - org.neo4j - neo4j-cypher-compiler-3.1 - ${project.version} - - org.neo4j neo4j-cypher-spec-suite-tools ${project.version} + test @@ -198,6 +146,7 @@ org.neo4j neo4j-kernel + ${project.version} test-jar test @@ -205,15 +154,8 @@ org.neo4j neo4j-io - test-jar - test - - - - org.neo4j - neo4j-cypher - test-jar ${project.version} + test-jar test @@ -224,20 +166,5 @@ test-jar test - - - - - com.novus - salat-core_2.11 - 1.9.9 - - - org.scala-lang - scala-library - - - - diff --git a/community/cypher/compatibility-suite/src/test/java/cypher/UnpackedResources.java b/community/cypher/compatibility-suite/src/test/java/cypher/UnpackedResources.java index dd4c02ddee365..7ece0d02f842f 100644 --- a/community/cypher/compatibility-suite/src/test/java/cypher/UnpackedResources.java +++ b/community/cypher/compatibility-suite/src/test/java/cypher/UnpackedResources.java @@ -105,7 +105,7 @@ public static File targetDirectory( String suffix ) private static File obtainTargetDirectory( boolean create, String suffix ) { - File directory = new File( new File( "target" ), suffix ); + File directory = new File( new File( "target" ), suffix ).getAbsoluteFile(); if ( !directory.exists() ) { if ( !(create && directory.mkdirs()) ) diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CypherTCKSteps.scala b/community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CompatibilitySuiteSteps.scala similarity index 89% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CypherTCKSteps.scala rename to community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CompatibilitySuiteSteps.scala index cda5192d99c59..3e1260f54a6db 100644 --- a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CypherTCKSteps.scala +++ b/community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/CompatibilitySuiteSteps.scala @@ -24,7 +24,7 @@ import cypher.{CompatibilitySuiteTest, UnpackedResources} import scala.reflect.io.Path -class CypherTCKSteps extends SpecSuiteSteps { +class CompatibilitySuiteSteps extends SpecSuiteSteps { override val requiredScenarioName: String = CompatibilitySuiteTest.SCENARIO_NAME_REQUIRED.trim.toLowerCase @@ -51,14 +51,14 @@ class CypherTCKSteps extends SpecSuiteSteps { "Fail when using property access on primitive type", // change error detail "Fail when comparing nodes to relationships", "Many CREATE clauses", // stack overflow - "Null-setting one property with ON CREATE", // wrong ouput format (?) - "Copying properties from node with ON CREATE", // wrong ouput format (?) - "Copying properties from node with ON MATCH", // wrong ouput format (?) - "Copying properties from literal map with ON CREATE", // wrong ouput format (?) + "Null-setting one property with ON CREATE", // wrong output format (?) + "Copying properties from node with ON CREATE", // wrong output format (?) + "Copying properties from node with ON MATCH", // wrong output format (?) + "Copying properties from literal map with ON CREATE", // wrong output format (?) "Copying properties from literal map with ON MATCH" // wrong output format (?) ) - override val graphArchiveLibrary = new GraphArchiveLibrary(new GraphFileRepository(Path(UnpackedResources.targetDirectory("graphs").getAbsoluteFile))) + override val graphArchiveLibrary = new GraphArchiveLibrary(new GraphFileRepository(Path(UnpackedResources.targetDirectory("graphs")))) } diff --git a/community/cypher/pom.xml b/community/cypher/pom.xml index e218002924485..0717347d193f4 100644 --- a/community/cypher/pom.xml +++ b/community/cypher/pom.xml @@ -36,6 +36,7 @@ frontend-3.1 cypher-compiler-3.1 cypher + spec-suite-tools acceptance compatibility-suite diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/CypherMatchersCreator.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/CypherMatchersCreator.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/CypherMatchersCreator.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/CypherMatchersCreator.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/CypherParametersCreator.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/CypherParametersCreator.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/CypherParametersCreator.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/CypherParametersCreator.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/ParsingErrorListener.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/ParsingErrorListener.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/ParsingErrorListener.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/ParsingErrorListener.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/ResultsParser.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/ResultsParser.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/ResultsParser.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/ResultsParser.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/BooleanMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/BooleanMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/BooleanMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/BooleanMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/FloatMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/FloatMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/FloatMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/FloatMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/IntegerMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/IntegerMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/IntegerMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/IntegerMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ListMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ListMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ListMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ListMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/MapMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/MapMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/MapMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/MapMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/Matcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/Matcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/Matcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/Matcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/NodeMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/NodeMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/NodeMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/NodeMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/PathLinkMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/PathLinkMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/PathLinkMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/PathLinkMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/PathMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/PathMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/PathMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/PathMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/QueryStatisticsMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/QueryStatisticsMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/QueryStatisticsMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/QueryStatisticsMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/RelationshipMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/RelationshipMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/RelationshipMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/RelationshipMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ResultMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ResultMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ResultMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ResultMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ResultWrapper.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ResultWrapper.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ResultWrapper.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ResultWrapper.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/RowMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/RowMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/RowMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/RowMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/StringMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/StringMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/StringMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/StringMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/TckSerializer.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/TckSerializer.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/TckSerializer.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/TckSerializer.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/UnorderedListMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/UnorderedListMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/UnorderedListMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/UnorderedListMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ValueMatcher.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ValueMatcher.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/matchers/ValueMatcher.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/matchers/ValueMatcher.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/reporting/CombinationChartWriter.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/reporting/CombinationChartWriter.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/reporting/CombinationChartWriter.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/reporting/CombinationChartWriter.java diff --git a/community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/reporting/CoverageChartWriter.java b/community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/reporting/CoverageChartWriter.java similarity index 100% rename from community/cypher/compatibility-suite/src/main/java/cypher/feature/parser/reporting/CoverageChartWriter.java rename to community/cypher/spec-suite-tools/src/main/java/cypher/feature/parser/reporting/CoverageChartWriter.java diff --git a/community/cypher/compatibility-suite/src/main/scala/cypher/cucumber/CucumberAdapter.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/CucumberAdapter.scala similarity index 100% rename from community/cypher/compatibility-suite/src/main/scala/cypher/cucumber/CucumberAdapter.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/CucumberAdapter.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DatabaseArchive.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DatabaseArchive.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DatabaseArchive.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DatabaseArchive.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DatabaseConfigProvider.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DatabaseConfigProvider.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DatabaseConfigProvider.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DatabaseConfigProvider.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DeleteDirectory.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DeleteDirectory.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/DeleteDirectory.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/DeleteDirectory.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchive.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchive.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchive.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchive.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchiveImporter.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchiveImporter.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchiveImporter.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchiveImporter.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchiveLibrary.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchiveLibrary.scala similarity index 95% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchiveLibrary.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchiveLibrary.scala index c21d222068f38..8c13079902d00 100644 --- a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphArchiveLibrary.scala +++ b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphArchiveLibrary.scala @@ -23,10 +23,6 @@ import java.nio.file.Files import scala.reflect.io.Path -object GraphArchiveLibrary { - val default = new GraphArchiveLibrary(GraphFileRepository.default) -} - class GraphArchiveLibrary(val repository: GraphFileRepository) { def recipe(name: String) = repository.graphRecipeLoader(name) diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphFileRepository.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphFileRepository.scala similarity index 66% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphFileRepository.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphFileRepository.scala index 1d8d2894985e6..ea7695098469f 100644 --- a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphFileRepository.scala +++ b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphFileRepository.scala @@ -21,24 +21,18 @@ package cypher.cucumber.db import java.util.UUID -import cypher.UnpackedResources - import scala.reflect.io.{File, Path} -object GraphFileRepository { - val default = new GraphFileRepository(Path(UnpackedResources.targetDirectory("graphs").getAbsoluteFile)) -} - -class GraphFileRepository(graphs: Path) { +class GraphFileRepository(root: Path) { self => val graphRecipeLoader = GraphRecipeLoader.forRepository(self) - def graphImportFile(name: String) = graphs / File(s"$name.json") - def graphScriptFile(name: String) = graphs / File(s"$name.cypher") - def graphArchivePath(descriptor: GraphArchive.Descriptor) = graphs / Path(descriptor.toString) + def graphImportFile(name: String) = root / File(s"$name.json") + def graphScriptFile(name: String) = root / File(s"$name.cypher") + def graphArchivePath(descriptor: GraphArchive.Descriptor) = root / Path(descriptor.toString) def graphArchiveImportStatusFile(descriptor: GraphArchive.Descriptor) = graphArchivePath(descriptor) / "IMPORTED" - def temporarySnapshotPath = DeleteDirectory.onExit(graphs / Path(UUID.randomUUID().toString)) + def temporarySnapshotPath = DeleteDirectory.onExit(root / Path(UUID.randomUUID().toString)) } diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphRecipeLoader.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphRecipeLoader.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/GraphRecipeLoader.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/GraphRecipeLoader.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/package.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/package.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/cucumber/db/package.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/cucumber/db/package.scala diff --git a/community/cypher/compatibility-suite/src/main/scala/cypher/feature/parser/ParsingFunctions.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/feature/parser/ParsingFunctions.scala similarity index 100% rename from community/cypher/compatibility-suite/src/main/scala/cypher/feature/parser/ParsingFunctions.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/feature/parser/ParsingFunctions.scala diff --git a/community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/CypherResultReporter.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/CypherResultReporter.scala similarity index 100% rename from community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/CypherResultReporter.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/CypherResultReporter.scala diff --git a/community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/JsonResult.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/JsonResult.scala similarity index 100% rename from community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/JsonResult.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/JsonResult.scala diff --git a/community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/OutputProducer.scala b/community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/OutputProducer.scala similarity index 100% rename from community/cypher/compatibility-suite/src/main/scala/cypher/feature/reporting/OutputProducer.scala rename to community/cypher/spec-suite-tools/src/main/scala/cypher/feature/reporting/OutputProducer.scala diff --git a/community/cypher/compatibility-suite/src/test/java/cypher/MapRow.java b/community/cypher/spec-suite-tools/src/test/java/cypher/MapRow.java similarity index 100% rename from community/cypher/compatibility-suite/src/test/java/cypher/MapRow.java rename to community/cypher/spec-suite-tools/src/test/java/cypher/MapRow.java diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/ParsingTestSupport.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/ParsingTestSupport.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/ParsingTestSupport.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/ParsingTestSupport.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/expectedResultsParserTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/expectedResultsParserTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/expectedResultsParserTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/expectedResultsParserTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/BooleanMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/FloatMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/IntegerMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ListMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ListMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ListMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ListMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/MapMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/MapMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/MapMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/MapMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/NodeMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/NodeMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/NodeMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/NodeMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/PathLinkMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/PathLinkMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/PathLinkMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/PathLinkMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/PathMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/PathMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/PathMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/PathMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/RelationshipMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/RelationshipMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/RelationshipMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/RelationshipMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ResultMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ResultMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ResultMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ResultMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/RowMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/RowMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/RowMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/RowMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/StringMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/StringMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/StringMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/StringMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/TckSerializerTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/TckSerializerTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/TckSerializerTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/TckSerializerTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/UnorderedListMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/UnorderedListMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/UnorderedListMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/UnorderedListMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ValueMatcherTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ValueMatcherTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/matchers/ValueMatcherTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/matchers/ValueMatcherTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/paramsParserTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/paramsParserTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/paramsParserTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/paramsParserTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/reporting/CombinationChartWriterTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/reporting/CombinationChartWriterTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/reporting/CombinationChartWriterTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/reporting/CombinationChartWriterTest.scala diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/statisticsParserTest.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/statisticsParserTest.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/parser/statisticsParserTest.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/parser/statisticsParserTest.scala diff --git a/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/SpecSuiteSteps.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/SpecSuiteSteps.scala new file mode 100644 index 0000000000000..27d716399b779 --- /dev/null +++ b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/SpecSuiteSteps.scala @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2002-2016 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package cypher.feature.steps + +import java.util + +import cucumber.api.DataTable +import cypher.cucumber.db.DatabaseConfigProvider._ +import cypher.cucumber.db.{GraphArchive, GraphArchiveImporter, GraphArchiveLibrary} +import cypher.feature.parser.matchers.ResultWrapper +import cypher.feature.parser.{MatcherMatchingSupport, constructResultMatcher, parseParameters, statisticsParser} +import org.neo4j.graphdb.factory.{GraphDatabaseFactory, GraphDatabaseSettings} +import org.neo4j.graphdb.{GraphDatabaseService, Result} +import org.neo4j.test.TestGraphDatabaseFactory +import org.opencypher.tools.tck.TCKCucumberTemplate +import org.opencypher.tools.tck.constants.TCKStepDefinitions._ +import org.scalatest.{FunSuiteLike, Matchers} + +import scala.collection.JavaConverters._ +import scala.reflect.io.Path +import scala.util.{Failure, Success, Try} + +trait SpecSuiteSteps extends FunSuiteLike with Matchers with TCKCucumberTemplate with MatcherMatchingSupport { + + // Implement in subclasses + + def requiredScenarioName: String + def unsupportedScenarios: Set[String] + def graphArchiveLibrary: GraphArchiveLibrary + + // Stateful + + var graph: GraphDatabaseService = null + var result: Try[Result] = null + var params: util.Map[String, AnyRef] = new util.HashMap[String, AnyRef]() + var currentScenarioName: String = "" + + // Steps + + After() { _ => + ifEnabled { + // TODO: postpone this till the last scenario + graph.shutdown() + } + } + + Before() { scenario => + currentScenarioName = scenario.getName.toLowerCase + } + + Background(BACKGROUND) { + // do nothing, but necessary for the scala match + } + + Given(NAMED_GRAPH) { (dbName: String) => + ifEnabled { + initNamed(dbName) + } + } + + Given(ANY_GRAPH) { + ifEnabled { + // We could do something fancy here, like randomising a state, + // in order to guarantee that we aren't implicitly relying on an empty db. + initEmpty() + } + } + + Given(EMPTY_GRAPH) { + ifEnabled { + initEmpty() + } + } + + And(INIT_QUERY) { (query: String) => + ifEnabled { + // side effects are necessary for setting up graph state + graph.execute(query) + } + } + + And(PARAMETERS) { (values: DataTable) => + ifEnabled { + params = parseParameters(values) + } + } + + When(EXECUTING_QUERY) { (query: String) => + ifEnabled { + result = Try { + graph.execute(query, params) + } + } + } + + Then(EXPECT_RESULT) { (expectedTable: DataTable) => + ifEnabled { + val matcher = constructResultMatcher(expectedTable) + + val assertedSuccessful = successful(result) + inTx { + matcher should accept(assertedSuccessful) + } + } + } + + Then(EXPECT_RESULT_UNORDERED_LISTS) { (expectedTable: DataTable) => + ifEnabled { + val matcher = constructResultMatcher(expectedTable, unorderedLists = true) + + val assertedSuccessful = successful(result) + inTx { + matcher should accept(assertedSuccessful) + } + } + } + + + Then(EXPECT_ERROR) { (typ: String, phase: String, detail: String) => + ifEnabled { + TCKErrorHandler(typ, phase, detail).check(result) + } + } + + Then(EXPECT_SORTED_RESULT) { (expectedTable: DataTable) => + ifEnabled { + val matcher = constructResultMatcher(expectedTable) + + val assertedSuccessful = successful(result) + inTx { + matcher should acceptOrdered(assertedSuccessful) + } + } + } + + Then(EXPECT_EMPTY_RESULT) { + ifEnabled { + withClue("Expected empty result") { + successful(result).hasNext shouldBe false + } + } + } + + And(SIDE_EFFECTS) { (expectations: DataTable) => + ifEnabled { + statisticsParser(expectations) should accept(successful(result).getQueryStatistics) + } + } + + And(NO_SIDE_EFFECTS) { + ifEnabled { + withClue("Expected no side effects") { + successful(result).getQueryStatistics.containsUpdates() shouldBe false + } + } + } + + When(EXECUTING_CONTROL_QUERY) { (query: String) => + result = Try { + graph.execute(query, params) + } + } + + private def ifEnabled(f: => Unit): Unit = { + val blacklist = unsupportedScenarios.map(_.toLowerCase) + if (!blacklist(currentScenarioName) && (requiredScenarioName.isEmpty || currentScenarioName.contains(requiredScenarioName))) { + f + } + } + + private def successful(value: Try[Result]): Result = value match { + case Success(r) => new ResultWrapper(r) + case Failure(e) => fail(s"Expected successful result, but got error: $e") + } + + private def inTx(f: => Unit) = { + val tx = graph.beginTx() + f + tx.success() + tx.close() + } + + private def initEmpty() = + if (graph == null || !graph.isAvailable(1L)) { + val builder = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder() + builder.setConfig(currentDatabaseConfig("8M").asJava) + graph = builder.newGraphDatabase() + } + + private def initNamed(dbName: String) = { + val recipe = graphArchiveLibrary.recipe(dbName) + val recommendedPcSize = recipe.recommendedPageCacheSize + val pcSize = (recommendedPcSize/MB(32)+1)*MB(32) + // TODO: force read only + val config = currentDatabaseConfig(pcSize.toString) + val archive = GraphArchive(recipe, config) + val path = graphArchiveLibrary.lendForReadingOnly(archive)(graphImporter) + val builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(path.jfile) + builder.setConfig(config.asJava) + graph = builder.newGraphDatabase() + } + + private def MB(v: Int) = v * 1024 * 1024 + + private def currentDatabaseConfig(sizeHint: String) = { + val builder = Map.newBuilder[String, String] + builder += GraphDatabaseSettings.pagecache_memory.name() -> sizeHint + cypherConfig().foreach { case (s, v) => builder += s.name() -> v } + builder.result() + } + + object graphImporter extends GraphArchiveImporter { + protected def createDatabase(archive: GraphArchive.Descriptor, destination: Path): GraphDatabaseService = { + val builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(destination.jfile) + builder.setConfig(archive.dbConfig.asJava) + builder.newGraphDatabase() + } + } +} diff --git a/community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/TCKErrorHandler.scala b/community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/TCKErrorHandler.scala similarity index 100% rename from community/cypher/compatibility-suite/src/test/scala/cypher/feature/steps/TCKErrorHandler.scala rename to community/cypher/spec-suite-tools/src/test/scala/cypher/feature/steps/TCKErrorHandler.scala