removed old dummy test
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="src" path="src/test/java"/>
|
||||
<classpathentry kind="src" path="src/test/resources"/>
|
||||
<classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0.0/persistence-api-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" sourcepath="M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0-sources.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/org/springframework/data/data-commons/1.0.0.CI-SNAPSHOT/data-commons-1.0.0.CI-SNAPSHOT.jar"/>
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
<wb-resource deploy-path="/" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/test/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/test/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -185,7 +185,7 @@
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<excludes>
|
||||
<exclude>**/*_Roo_*</exclude>
|
||||
</excludes>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.springframework.persistence.graph.neo4j;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.springframework.persistence.support.EntityInstantiator;
|
||||
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
||||
/**
|
||||
* Uses Sun internal libraries used in deserializations to instantiate
|
||||
* objects bypassing constructor.
|
||||
*
|
||||
* Code based on this http://www.javaspecialists.eu/archive/Issue175.html
|
||||
* TODO check license implications
|
||||
*
|
||||
* @author rodjohnson
|
||||
*
|
||||
*/
|
||||
public class ConstructorBypassingGraphEntityInstantiator implements EntityInstantiator<NodeBacked,Node> {
|
||||
|
||||
private static <T> T createWithoutConstructorInvocation(Class<T> clazz) {
|
||||
return createWithoutConstructorInvocation(clazz, Object.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T createWithoutConstructorInvocation(Class<T> clazz, Class<? super T> parent) {
|
||||
try {
|
||||
ReflectionFactory rf = ReflectionFactory.getReflectionFactory();
|
||||
Constructor objDef = parent.getDeclaredConstructor();
|
||||
Constructor intConstr = rf.newConstructorForSerialization(clazz,
|
||||
objDef);
|
||||
return clazz.cast(intConstr.newInstance());
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Cannot create object", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends NodeBacked> T createEntityFromState(Node n, Class<T> c) {
|
||||
T t = createWithoutConstructorInvocation(c);
|
||||
t.setUnderlyingNode(n);
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.springframework.persistence.graph.neo4j;
|
||||
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.springframework.persistence.support.AbstractConstructorEntityInstantiator;
|
||||
|
||||
/**
|
||||
* Try for a constructor taking a Neo4j Node: failing that, try a no-arg
|
||||
* constructor and then setUnderlyingNode().
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
public class Neo4jConstructorEntityInstantiator extends AbstractConstructorEntityInstantiator<NodeBacked, Node>{
|
||||
|
||||
@Override
|
||||
protected void setState(NodeBacked entity, Node s) {
|
||||
entity.setUnderlyingNode(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,5 +10,7 @@ import org.neo4j.graphdb.Node;
|
||||
public interface NodeBacked {
|
||||
|
||||
Node getUnderlyingNode();
|
||||
|
||||
void setUnderlyingNode(Node n);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.springframework.datastore.graph;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class GraphUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testSomething() {
|
||||
Assert.assertTrue( true );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.springframework.persistence.graph.neo4j;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class Neo4jGraphPersistenceTest {
|
||||
|
||||
@Autowired
|
||||
protected GraphDatabaseService graphDatabaseService;
|
||||
|
||||
@Test
|
||||
public void testGraphDatabaseServiceCreatedAndAutowired() {
|
||||
Assert.assertNotNull( graphDatabaseService );
|
||||
}
|
||||
|
||||
}
|
||||
6
src/test/resources/META-INF/spring/database.properties
Normal file
6
src/test/resources/META-INF/spring/database.properties
Normal file
@@ -0,0 +1,6 @@
|
||||
#Updated at Tue Mar 23 14:26:10 PDT 2010
|
||||
#Tue Mar 23 14:26:10 PDT 2010
|
||||
database.password=
|
||||
database.url=jdbc\:hsqldb\:mem\:test
|
||||
database.username=sa
|
||||
database.driverClassName=org.hsqldb.jdbcDriver
|
||||
1
src/test/resources/META-INF/spring/neo4j.properties
Normal file
1
src/test/resources/META-INF/spring/neo4j.properties
Normal file
@@ -0,0 +1 @@
|
||||
neo4j.databaseDirectory=target/data/test
|
||||
22
src/test/resources/log4j.properties
Normal file
22
src/test/resources/log4j.properties
Normal file
@@ -0,0 +1,22 @@
|
||||
log4j.rootLogger=info, stdout, R
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Print the date in ISO 8601 format
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||
|
||||
log4j.appender.R=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.R.File=application.log
|
||||
|
||||
log4j.appender.R.MaxFileSize=100KB
|
||||
# Keep one backup file
|
||||
log4j.appender.R.MaxBackupIndex=1
|
||||
|
||||
log4j.appender.R.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
|
||||
|
||||
log4j.category.org.springframework=DEBUG
|
||||
log4j.category.org.springframework.data=TRACE
|
||||
log4j.category.org.springframework.datastore=TRACE
|
||||
log4j.category.org.springframework.persistence=TRACE
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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">
|
||||
|
||||
<!--
|
||||
This will automatically locate any and all property files you have
|
||||
within your classpath, provided they fall under the META-INF/spring
|
||||
directory. The located property files are parsed and their values can
|
||||
then be used within application context files in the form of
|
||||
${propertyKey}.
|
||||
-->
|
||||
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
|
||||
|
||||
<!--
|
||||
Turn on AspectJ @Configurable support. As a result, any time you
|
||||
instantiate an object, Spring will attempt to perform dependency
|
||||
injection on that object. This occurs for instantiation via the "new"
|
||||
keyword, as well as via reflection. This is possible because AspectJ
|
||||
is used to "weave" Roo-based applications at compile time. In effect
|
||||
this feature allows dependency injection of any object at all in your
|
||||
system, which is a very useful feature (without @Configurable you'd
|
||||
only be able to dependency inject objects acquired from Spring or
|
||||
subsequently presented to a specific Spring dependency injection
|
||||
method). Roo applications use this useful feature in a number of
|
||||
areas, such as @PersistenceContext injection into entities.
|
||||
-->
|
||||
<context:spring-configured/>
|
||||
|
||||
<!--
|
||||
This declaration will cause Spring to locate every @Component,
|
||||
@Repository and @Service in your application. In practical terms this
|
||||
allows you to write a POJO and then simply annotate the new POJO as an
|
||||
@Service and Spring will automatically detect, instantiate and
|
||||
dependency inject your service at startup time. Importantly, you can
|
||||
then also have your new service injected into any other class that
|
||||
requires it simply by declaring a field for your service inside the
|
||||
relying class and Spring will inject it. Note that two exclude filters
|
||||
are declared. The first ensures that Spring doesn't spend time
|
||||
introspecting Roo-specific ITD aspects. The second ensures Roo doesn't
|
||||
instantiate your @Controller classes, as these should be instantiated
|
||||
by a web tier application context. Refer to web.xml for more details
|
||||
about the web tier application context setup services.
|
||||
|
||||
Furthermore, this turns on @Autowired, @PostConstruct etc support. These
|
||||
annotations allow you to use common Spring and Java Enterprise Edition
|
||||
annotations in your classes without needing to do any special configuration.
|
||||
The most commonly used annotation is @Autowired, which instructs Spring to
|
||||
dependency inject an object into your class.
|
||||
-->
|
||||
<context:component-scan base-package="org.springframework.persistence.test">
|
||||
<context:exclude-filter expression=".*_Roo_.*" type="regex"/>
|
||||
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
|
||||
</context:component-scan>
|
||||
|
||||
|
||||
<!--
|
||||
Start datastore config
|
||||
-->
|
||||
|
||||
<!--
|
||||
<bean class="org.springframework.persistence.graph.neo4j.Neo4jNodeBacking"
|
||||
factory-method="aspectOf" />
|
||||
|
||||
<bean class="org.springframework.persistence.graph.Neo4jSimpleNodePropertyStorageForeignStoreKeyManager"/>
|
||||
-->
|
||||
|
||||
<bean id="graphDbService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
|
||||
destroy-method="shutdown" >
|
||||
<constructor-arg index="0" value="${neo4j.databaseDirectory}" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.persistence.graph.neo4j.Neo4jConstructorEntityInstantiator" />
|
||||
|
||||
<!--
|
||||
<bean id="transactionManager" class="org.springframework.persistence.transaction.NaiveDoubleTransactionManager" >
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.orm.jpa.JpaTransactionManager" >
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
class="org.springframework.transaction.jta.JtaTransactionManager">
|
||||
<property name="transactionManager" ref="neo4jTransactionManagerService" />
|
||||
<property name="userTransaction" ref="neo4jUserTransactionService" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="neo4jTransactionManagerService" class="org.neo4j.kernel.impl.transaction.SpringTransactionManager" >
|
||||
<constructor-arg index="0" ref="graphDbService" />
|
||||
</bean>
|
||||
|
||||
<bean id="neo4jUserTransactionService" class="org.neo4j.kernel.impl.transaction.UserTransactionImpl">
|
||||
<constructor-arg index="0" ref="graphDbService" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
|
||||
<property name="driverClassName" value="${database.driverClassName}"/>
|
||||
<property name="url" value="${database.url}"/>
|
||||
<property name="username" value="${database.username}"/>
|
||||
<property name="password" value="${database.password}"/>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
|
||||
-->
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user