Last active
December 20, 2015 17:59
-
-
Save ttiurani/6172164 to your computer and use it in GitHub Desktop.
Test for UUIDTransactionEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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