From 3348eec4e6ef1c633446d38985863c61af240cad Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Tue, 29 Mar 2011 22:04:32 +0200 Subject: [PATCH] Test for GraphDatabaseFactory --- .../graph/core/GraphDatabaseFactoryTest.java | 43 +++++++++++++++++++ .../GraphDatabaseFactory-context.xml | 24 +++++++++++ 2 files changed, 67 insertions(+) create mode 100644 spring-data-neo4j/src/test/java/org/springframework/data/graph/core/GraphDatabaseFactoryTest.java create mode 100644 spring-data-neo4j/src/test/resources/GraphDatabaseFactory-context.xml diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/graph/core/GraphDatabaseFactoryTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/graph/core/GraphDatabaseFactoryTest.java new file mode 100644 index 000000000..98278f4a8 --- /dev/null +++ b/spring-data-neo4j/src/test/java/org/springframework/data/graph/core/GraphDatabaseFactoryTest.java @@ -0,0 +1,43 @@ +package org.springframework.data.graph.core; + +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.data.graph.neo4j.support.LocalGraphDatabase; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsInstanceOf.instanceOf; +import static org.hamcrest.core.IsNot.not; +import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertThat; + +/** + * @author mh + * @since 29.03.11 + */ +public class GraphDatabaseFactoryTest { + + @Test + public void shouldCreateLocalDatabaseFromContext() throws Exception { + ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("GraphDatabaseFactory-context.xml"); + try { + GraphDatabase graphDatabase = ctx.getBean("graphDatabase", GraphDatabase.class); + assertThat(graphDatabase, is(not(nullValue()))); + assertThat(graphDatabase, is(instanceOf(LocalGraphDatabase.class))); + } finally { + ctx.close(); + } + + } + @Test + public void shouldCreateLocalDatabase() throws Exception { + GraphDatabaseFactory factory = new GraphDatabaseFactory(); + try { + factory.setStoreLocation("target/test-db"); + GraphDatabase graphDatabase = factory.getObject(); + assertThat(graphDatabase, is(not(nullValue()))); + assertThat(graphDatabase,is(instanceOf(LocalGraphDatabase.class))); + } finally { + factory.shutdown(); + } + } +} diff --git a/spring-data-neo4j/src/test/resources/GraphDatabaseFactory-context.xml b/spring-data-neo4j/src/test/resources/GraphDatabaseFactory-context.xml new file mode 100644 index 000000000..e1863ed64 --- /dev/null +++ b/spring-data-neo4j/src/test/resources/GraphDatabaseFactory-context.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + \ No newline at end of file