You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/03/18 14:30:51 UTC
[03/50] incubator-tinkerpop git commit: Added a TestListener to
notify GraphProviders of test start/stop activities.
Added a TestListener to notify GraphProviders of test start/stop activities.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/3d2a8967
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/3d2a8967
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/3d2a8967
Branch: refs/heads/master
Commit: 3d2a8967e886f1530da6977529eb7e221c9233bd
Parents: ac804fc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 11 19:52:10 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Mar 17 17:01:13 2016 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/AbstractGremlinTest.java | 2 ++
.../apache/tinkerpop/gremlin/GraphManager.java | 6 ++++++
.../apache/tinkerpop/gremlin/GraphProvider.java | 19 +++++++++++++++++++
3 files changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3d2a8967/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index 394d5c7..3f5b5c3 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@ -76,6 +76,7 @@ public abstract class AbstractGremlinTest {
final LoadGraphWith.GraphData loadGraphWithData = null == loadGraphWith ? null : loadGraphWith.value();
graphProvider = GraphManager.getGraphProvider();
+ graphProvider.getTestListener().ifPresent(l -> l.onTestStart(this.getClass(), name.getMethodName()));
config = graphProvider.standardGraphConfiguration(this.getClass(), name.getMethodName(), loadGraphWithData);
// this should clear state from a previously unfinished test. since the graph does not yet exist,
@@ -130,6 +131,7 @@ public abstract class AbstractGremlinTest {
@After
public void tearDown() throws Exception {
if (null != graphProvider) {
+ graphProvider.getTestListener().ifPresent(l -> l.onTestEnd(this.getClass(), name.getMethodName()));
graphProvider.clear(graph, config);
// All GraphProvider objects should be an instance of ManagedGraphProvider, as this is handled by GraphManager
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3d2a8967/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphManager.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphManager.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphManager.java
index 4f43a08..571658d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphManager.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphManager.java
@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
/**
@@ -171,6 +172,11 @@ public class GraphManager {
public Set<Class> getImplementations() {
return innerGraphProvider.getImplementations();
}
+
+ @Override
+ public Optional<TestListener> getTestListener() {
+ return innerGraphProvider.getTestListener();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3d2a8967/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
index 0e3a448..ee77702 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
@@ -49,6 +49,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
/**
@@ -285,6 +286,14 @@ public interface GraphProvider {
}
/**
+ * Returns a {@link TestListener} implementation that provides feedback to the {@link GraphProvider} implementation.
+ * By default, this returns an empty listener.
+ */
+ public default Optional<TestListener> getTestListener() {
+ return Optional.empty();
+ }
+
+ /**
* An annotation to be applied to a {@code GraphProvider} implementation that provides additional information
* about its intentions. The {@code Descriptor} is required by those {@code GraphProvider} implementations
* that will be assigned to test suites that use
@@ -302,4 +311,14 @@ public interface GraphProvider {
*/
public Class<? extends GraphComputer> computer();
}
+
+ public interface TestListener {
+ public default void onTestStart(final Class<?> test, final String testName) {
+ // do nothing
+ }
+
+ public default void onTestEnd(final Class<?> test, final String testName) {
+ // do nothing
+ }
+ }
}