Skip to content

Instantly share code, notes, and snippets.

@ttiurani
Last active December 20, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttiurani/6172164 to your computer and use it in GitHub Desktop.
Save ttiurani/6172164 to your computer and use it in GitHub Desktop.
Test for UUIDTransactionEventHandler.java
package example;
import org.junit.Test;
import org.neo4j.extension.uuid.UUIDPluginLifecycle;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.server.WrappingNeoServerBootstrapper;
import org.neo4j.server.configuration.Configurator;
import org.neo4j.server.configuration.ServerConfigurator;
public class PluginLifecycleTest{
@Test
public void shouldCreateUUIDToNewNode()
{
GraphDatabaseAPI graphdb = (GraphDatabaseAPI) new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( "/tmp/neo4j-test" )
.newGraphDatabase();
new UUIDPluginLifecycle().start(graphdb, null);
ServerConfigurator config;
config = new ServerConfigurator( graphdb );
config.configuration().setProperty(
Configurator.THIRD_PARTY_PACKAGES_KEY, "org.neo4j.extension.uuid=/uuid");
config.configuration().setProperty(
Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7473);
WrappingNeoServerBootstrapper srv = new WrappingNeoServerBootstrapper( graphdb, config );
srv.start();
Transaction tx = graphdb.beginTx();
Node node = graphdb.createNode();
node.setProperty("test", "test");
long id = node.getId();
tx.success();
tx = graphdb.beginTx();
node = graphdb.getNodeById(id);
node.getProperty("test");
// New nodes should have a "uuid" property
node.getProperty("uuid");
tx.success();
srv.stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment