diff --git a/community/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java b/enterprise/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java similarity index 81% rename from community/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java rename to enterprise/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java index 37b319fd4a715..2ab0ee9d75893 100644 --- a/community/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java +++ b/enterprise/cypher/acceptance-spec-suite/src/test/java/org/neo4j/internal/cypher/acceptance/TestResourceProcedure.java @@ -5,17 +5,17 @@ * 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. + * it under the terms of the GNU Affero 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. + * GNU Affero 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 . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package org.neo4j.internal.cypher.acceptance; @@ -54,13 +54,13 @@ public static class SimulateFailureOnCloseException extends SimulateFailureBaseE public static class Counters { - public int closeCountTestResourceProcedure = 0; - public int closeCountTestFailingResourceProcedure = 0; - public int closeCountTestOnCloseFailingResourceProcedure = 0; + public int closeCountTestResourceProcedure; + public int closeCountTestFailingResourceProcedure; + public int closeCountTestOnCloseFailingResourceProcedure; - public int openCountTestResourceProcedure = 0; - public int openCountTestFailingResourceProcedure = 0; - public int openCountTestOnCloseFailingResourceProcedure = 0; + public int openCountTestResourceProcedure; + public int openCountTestFailingResourceProcedure; + public int openCountTestOnCloseFailingResourceProcedure; public int liveCountTestResourceProcedure() { @@ -107,9 +107,8 @@ public Output( Long value ) @Description( "Returns a stream of integers from 1 to the given argument" ) public Stream testResourceProcedure( @Name( value = "resultCount", defaultValue = "4" ) long resultCount ) throws Exception { - Stream stream = Stream.iterate( 1L, (i) -> i + 1 ).limit( resultCount ).map( Output::new ); - stream.onClose( () -> - { + Stream stream = Stream.iterate( 1L, i -> i + 1 ).limit( resultCount ).map( Output::new ); + stream.onClose( () -> { counters.closeCountTestResourceProcedure++; } ); counters.openCountTestResourceProcedure++; @@ -137,13 +136,12 @@ public Output next() { throw new SimulateFailureException(); } - return new Output(step++); + return new Output( step++ ); } }; Iterable failingIterable = () -> failingIterator; - Stream stream = StreamSupport.stream(failingIterable.spliterator(), false); - stream.onClose( () -> - { + Stream stream = StreamSupport.stream( failingIterable.spliterator(), false ); + stream.onClose( () -> { counters.closeCountTestFailingResourceProcedure++; } ); counters.openCountTestFailingResourceProcedure++; @@ -154,9 +152,8 @@ public Output next() @Description( "Returns a stream of integers from 1 to the given argument. Throws an exception on close." ) public Stream testOnCloseFailingResourceProcedure( @Name( value = "resultCount", defaultValue = "4" ) long resultCount ) throws Exception { - Stream stream = Stream.iterate( 1L, (i) -> i + 1 ).limit( resultCount ).map( Output::new ); - stream.onClose( () -> - { + Stream stream = Stream.iterate( 1L, i -> i + 1 ).limit( resultCount ).map( Output::new ); + stream.onClose( () -> { counters.closeCountTestOnCloseFailingResourceProcedure++; throw new SimulateFailureOnCloseException(); } ); diff --git a/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala similarity index 88% rename from community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala rename to enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala index a778c3c851faf..e747b636245eb 100644 --- a/community/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/ReflectiveProcedureCallAcceptanceTest.scala @@ -5,17 +5,17 @@ * 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. + * it under the terms of the GNU Affero 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. + * GNU Affero 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 . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package org.neo4j.internal.cypher.acceptance @@ -23,11 +23,11 @@ import java.io.PrintWriter import org.apache.commons.lang3.exception.ExceptionUtils import org.neo4j.cypher._ -import org.neo4j.cypher.internal.compiler.v3_1.test_helpers.CreateTempFileTestSupport +import org.neo4j.cypher.internal.runtime.CreateTempFileTestSupport import org.neo4j.graphdb.{QueryExecutionException, TransactionFailureException} -import org.neo4j.internal.cypher.acceptance.TestResourceProcedure.{SimulateFailureException, SimulateFailureOnCloseException} -import org.neo4j.kernel.api.KernelTransaction -import org.neo4j.kernel.api.security.SecurityContext.AUTH_DISABLED +import org.neo4j.internal.cypher.acceptance.TestResourceProcedure._ +import org.neo4j.internal.kernel.api.Transaction +import org.neo4j.internal.kernel.api.security.LoginContext import org.neo4j.kernel.impl.proc.Procedures import scala.collection.mutable.ArrayBuffer @@ -53,7 +53,7 @@ class ReflectiveProcedureCallAcceptanceTest extends ExecutionEngineFunSuite with private def setUpProcedures(): TestResourceProcedure.Counters = { val procedures = graph.getDependencyResolver.resolveDependency(classOf[Procedures]) val counters = new TestResourceProcedure.Counters - procedures.registerComponent(classOf[TestResourceProcedure.Counters], TestResourceProcedure.countersProvider(counters)) + procedures.registerComponent(classOf[TestResourceProcedure.Counters], TestResourceProcedure.countersProvider(counters), true) procedures.registerProcedure(classOf[TestResourceProcedure]) procedures.registerFunction(classOf[TestResourceProcedure]) @@ -87,7 +87,7 @@ class ReflectiveProcedureCallAcceptanceTest extends ExecutionEngineFunSuite with test("should close resources on mid-stream transaction close") { val counters = setUpProcedures() - val tx = graph.beginTransaction(KernelTransaction.Type.`implicit`, AUTH_DISABLED) + val tx = graph.beginTransaction(Transaction.Type.`implicit`, LoginContext.AUTH_DISABLED) val result = graph.execute(defaultQuery) // Pull one row and then close the transaction @@ -115,7 +115,7 @@ class ReflectiveProcedureCallAcceptanceTest extends ExecutionEngineFunSuite with test("should not leave any resources open on transaction close before pulling on the result") { val counters = setUpProcedures() - val tx = graph.beginTransaction(KernelTransaction.Type.`implicit`, AUTH_DISABLED) + val tx = graph.beginTransaction(Transaction.Type.`implicit`, LoginContext.AUTH_DISABLED) val result = graph.execute(defaultQuery) // Close the transaction directly without pulling the result @@ -130,7 +130,7 @@ class ReflectiveProcedureCallAcceptanceTest extends ExecutionEngineFunSuite with val counters = setUpProcedures() val numberOfRows = 100 - val tx = graph.beginTransaction(KernelTransaction.Type.`implicit`, AUTH_DISABLED) + val tx = graph.beginTransaction(Transaction.Type.`implicit`, LoginContext.AUTH_DISABLED) val result = graph.execute(s"UNWIND range(1,$numberOfRows) as i CALL org.neo4j.test.testResourceProcedure(1) YIELD value RETURN value") // Pull one row and then close the transaction