Package org.apache.tinkerpop.gremlin
Class AbstractGraphProvider
- java.lang.Object
- 
- org.apache.tinkerpop.gremlin.AbstractGraphProvider
 
- 
- All Implemented Interfaces:
- GraphProvider
 - Direct Known Subclasses:
- AbstractFileGraphProvider
 
 public abstract class AbstractGraphProvider extends Object implements GraphProvider A basic GraphProvider which simply requires the implementer to supply their base configuration for their Graph instance. Minimally this is just the setting for "gremlin.graph".- Author:
- Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.GraphProviderGraphProvider.Descriptor, GraphProvider.TestListener
 
- 
 - 
Field Summary- 
Fields inherited from interface org.apache.tinkerpop.gremlin.GraphProviderCORE_IMPLEMENTATIONS
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractGraphProvider()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringcleanParameters(String methodName)protected static voiddeleteDirectory(File directory)Helper method for those buildingGraphProviderimplementations that need to clean directories between test runs.abstract Map<String,Object>getBaseConfiguration(String graphName, Class<?> test, String testMethodName, LoadGraphWith.GraphData loadGraphWith)Provides a basic configuration for a particularGraphinstance and uses thegraphNameto ensure that the instance is unique.voidloadGraphData(Graph graph, LoadGraphWith loadGraphWith, Class testClass, String testName)Tests are annotated with aLoadGraphWithannotation.protected StringmakeTestDirectory(String graphName, Class<?> test, String testMethodName)Utility method to help produce an appropriate unique directory for a test.org.apache.commons.configuration2.ConfigurationnewGraphConfiguration(String graphName, Class<?> test, String testMethodName, Map<String,Object> configurationOverrides, LoadGraphWith.GraphData loadGraphWith)When implementing this method ensure that a test suite can override any settings EXCEPT the "gremlin.graph" setting which should be defined by the implementer.protected voidreadIntoGraph(Graph graph, String path)Used by the default implementation ofloadGraphData(Graph, LoadGraphWith, Class, String)to read the graph from a Kryo file using the defaultGryoReaderimplementation.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.tinkerpop.gremlin.GraphProviderclear, clear, convertId, convertLabel, getGraphComputer, getImplementations, getStaticFeatures, getTestListener, getWorkingDirectory, newGraphConfiguration, openTestGraph, standardGraphConfiguration, standardTestGraph, traversal, traversal
 
- 
 
- 
- 
- 
Method Detail- 
getBaseConfigurationpublic abstract Map<String,Object> getBaseConfiguration(String graphName, Class<?> test, String testMethodName, LoadGraphWith.GraphData loadGraphWith) Provides a basic configuration for a particularGraphinstance and uses thegraphNameto ensure that the instance is unique. It is up to the Gremlin implementation to determine how best to use thegraphNameto ensure uniqueness. For example, Neo4j, might use thegraphNamemight be used to create a different sub-directory where the graph is stored. The @{code test} and @{code testMethodName} can be used to alter graph configurations for specific tests. For example, a graph that has support for different transaction isolation levels might only support a feature in a specific configuration. Using these arguments, the implementation could detect when a test was being fired that required the database to be configured in a specific isolation level and return a configuration to support that. Ultimately, the returnedMapshould minimally contain a configuration that can be given to aGraphFactoryso that it can be instantiated.- Parameters:
- graphName- a value that represents a unique configuration for a graph
- test- the test class
- testMethodName- the name of the test method
- loadGraphWith- the data set to load and will be null if no data is to be loaded
- Returns:
- a configuration Mapthat should be unique per thegraphName
 
 - 
newGraphConfigurationpublic org.apache.commons.configuration2.Configuration newGraphConfiguration(String graphName, Class<?> test, String testMethodName, Map<String,Object> configurationOverrides, LoadGraphWith.GraphData loadGraphWith) Description copied from interface:GraphProviderWhen implementing this method ensure that a test suite can override any settings EXCEPT the "gremlin.graph" setting which should be defined by the implementer. It should provide aConfigurationthat will generate a graph unique to thatgraphName.- Specified by:
- newGraphConfigurationin interface- GraphProvider
- Parameters:
- graphName- a unique test graph name
- test- the test class
- testMethodName- the name of the test
- configurationOverrides- settings to override defaults with.
- loadGraphWith- the data set to load and will be null if no data is to be loaded
 
 - 
loadGraphDatapublic void loadGraphData(Graph graph, LoadGraphWith loadGraphWith, Class testClass, String testName) Description copied from interface:GraphProviderTests are annotated with aLoadGraphWithannotation. These annotations tell the test what kind of data to preload into the graph instance. It is up to the implementation to load the graph with the data specified by that annotation. This method also represents the place where indices should be configured according the theGraphimplementation's API. Implementers can use thetestClassandtestNamearguments to implement test specific configurations to their graphs.- Specified by:
- loadGraphDatain interface- GraphProvider
- Parameters:
- graph- the- Graphinstance to load data into constructed by this- GraphProvider
- loadGraphWith- the annotation for the currently running test - this value may be null if no graph data is to be loaded in front of the test.
- testClass- the test class being executed
- testName- the name of the test method being executed
 
 - 
deleteDirectoryprotected static void deleteDirectory(File directory) Helper method for those buildingGraphProviderimplementations that need to clean directories between test runs.
 - 
makeTestDirectoryprotected String makeTestDirectory(String graphName, Class<?> test, String testMethodName) Utility method to help produce an appropriate unique directory for a test. Designed to be called fromgetBaseConfiguration(String, Class, String, LoadGraphWith.GraphData)for those graph providers that need a data directory for theirGraphimplementations.
 - 
readIntoGraphprotected void readIntoGraph(Graph graph, String path) throws IOException Used by the default implementation ofloadGraphData(Graph, LoadGraphWith, Class, String)to read the graph from a Kryo file using the defaultGryoReaderimplementation. If the default implementation does not work (perhaps a graph implementation needs to register some specialIoRegistrythen this method or its caller should be overridden to suit the implementation.- Parameters:
- graph- the graph to load to
- path- the path to the file to load into the graph
- Throws:
- IOException
 
 
- 
 
-