Test for GraphDatabaseFactory
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:annotation-config />
|
||||
|
||||
|
||||
<bean name="graphDatabase" class="org.springframework.data.graph.core.GraphDatabaseFactory">
|
||||
<property name="storeLocation" value="target/test-db"/>
|
||||
|
||||
</bean>
|
||||
</beans>
|
||||
Reference in New Issue
Block a user