fixing tests for parallel transactional mode

This commit is contained in:
Michael Hunger
2011-10-07 05:45:11 +02:00
parent fbdb667858
commit cfa71a8362
9 changed files with 34 additions and 38 deletions

View File

@@ -66,7 +66,7 @@ public class CrossStoreNeo4jConfiguration extends Neo4jAspectConfiguration {
}
@Bean
public PlatformTransactionManager transactionManager() {
public PlatformTransactionManager neo4jTransactionManager() {
if (isUsingCrossStorePersistence()) {
JpaTransactionManager jpaTm = new JpaTransactionManager(getEntityManagerFactory());
JtaTransactionManager jtaTm = createJtaTransactionManager();

View File

@@ -95,6 +95,13 @@
<artifactId>flexjson</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>1.5-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>

View File

@@ -1,29 +1,25 @@
package com.springone.myrestaurants.data;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.springone.myrestaurants.domain.Restaurant;
import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.neo4j.support.GraphDatabaseContext;
import org.springframework.data.neo4j.support.node.Neo4jHelper;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import com.springone.myrestaurants.domain.Restaurant;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration

View File

@@ -1,12 +1,10 @@
package com.springone.myrestaurants.data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.springone.myrestaurants.domain.Recommendation;
import com.springone.myrestaurants.domain.Restaurant;
import com.springone.myrestaurants.domain.UserAccount;
import junit.framework.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,9 +13,9 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import com.springone.myrestaurants.domain.Recommendation;
import com.springone.myrestaurants.domain.Restaurant;
import com.springone.myrestaurants.domain.UserAccount;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration

View File

@@ -1,32 +1,19 @@
package com.springone.myrestaurants.data;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceUnit;
import com.springone.myrestaurants.domain.UserAccount;
import junit.framework.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional;
import com.springone.myrestaurants.domain.UserAccount;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import java.util.Date;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration

View File

@@ -51,6 +51,9 @@ public class EntityStateHandler {
public boolean isManaged(Object entity) {
return entity instanceof ManagedEntity;
}
public boolean isManaged(Class type) {
return ManagedEntity.class.isAssignableFrom(type);
}
@SuppressWarnings("unchecked")
public <S extends PropertyContainer> S getPersistentState(Object entity) {

View File

@@ -379,4 +379,5 @@ public class Neo4jNodeConverterTest {
final Node michaelNode = getRelatedNodes(groupNode, "persons", Direction.OUTGOING).get(0);
assertEquals("added member to group", michael.getId(), (Long) michaelNode.getId());
}
}

View File

@@ -76,7 +76,7 @@ public class Person {
@Query(value = "start person=node({self}) match (person)<-[?:boss]-(boss) return boss.name")
private String bossName;
@Query(value = "start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member",elementClass = Person.class)
@Query(value = "start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member")
private Iterable<Person> otherTeamMembers;
@Query(value = "start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member.name, member.age")

View File

@@ -54,6 +54,10 @@
Try editing the build path to <code>include **/*.aj</code> for the spring-data-neo4j project.
You can do this by selecting "Build Path -> Configure Build Path ..." from the Package Explorer.
Then for the <code>spring-data-neo4j/src/main/java</code> add <code>**/*.aj</code> to the Included path.
For importing an Spring Data Graph project into Eclipse with m2e.
Please make sure that the <ulink href="http://dist.springsource.org/release/AJDT/configurator">AspectJ Configurator</ulink> is installed and
</para>
</note>
<para>