added ChainedTransactionManager, fixed config for RecommendationTest
This commit is contained in:
@@ -152,11 +152,6 @@
|
||||
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>neo4j-public-repository</id>
|
||||
<name>Neo4J Public Repository</name>
|
||||
<url>http://m2.neo4j.org</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jboss-repository</id>
|
||||
<name>JBoss Public Repository</name>
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.kernel.impl.transaction.SpringTransactionManager;
|
||||
import org.neo4j.kernel.impl.transaction.UserTransactionImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.graph.neo4j.fieldaccess.Neo4jConversionServiceFactoryBean;
|
||||
@@ -55,6 +56,7 @@ public class Neo4jConfiguration {
|
||||
return graphDatabaseService;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setGraphDatabaseService(GraphDatabaseService graphDatabaseService) {
|
||||
this.graphDatabaseService = graphDatabaseService;
|
||||
@@ -66,6 +68,7 @@ public class Neo4jConfiguration {
|
||||
return entityManagerFactory;
|
||||
}
|
||||
|
||||
@Qualifier("&entityManagerFactory")
|
||||
@Autowired(required = false)
|
||||
public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
|
||||
this.entityManagerFactory = entityManagerFactory;
|
||||
|
||||
@@ -73,7 +73,6 @@ public class PropertyFieldAccessorFactory implements FieldAccessorFactory<GraphB
|
||||
|
||||
@Override
|
||||
public final Object getValue(final GraphBacked<PropertyContainer> graphBacked) {
|
||||
System.out.println("### getValue "+field.getDeclaringClass().getSimpleName()+"."+field.getName());
|
||||
return doReturn(doGetValue(graphBacked));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,39 +9,35 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
* @since 14.02.11
|
||||
*/
|
||||
public class ChainedTransactionManager implements PlatformTransactionManager {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
private final static Log logger = LogFactory.getLog(ChainedTransactionManager.class);
|
||||
|
||||
private final List<PlatformTransactionManager> transactionManagers = new ArrayList<PlatformTransactionManager>();
|
||||
private SynchronizationManager sychronizationManager ;
|
||||
private final List<PlatformTransactionManager> transactionManagers;
|
||||
private final SynchronizationManager synchronizationManager;
|
||||
|
||||
ChainedTransactionManager(SynchronizationManager sychronizationManager) {
|
||||
this.sychronizationManager = sychronizationManager;
|
||||
public ChainedTransactionManager(PlatformTransactionManager... transactionManagers) {
|
||||
this(new DefaultSynchronizationManager(),transactionManagers);
|
||||
}
|
||||
|
||||
public ChainedTransactionManager() {
|
||||
this(new DefaultSynchronizationManager());
|
||||
public ChainedTransactionManager(SynchronizationManager synchronizationManager, PlatformTransactionManager... transactionManagers) {
|
||||
this.synchronizationManager = synchronizationManager;
|
||||
this.transactionManagers=asList(transactionManagers);
|
||||
}
|
||||
|
||||
public void setTransactionManagers(List<PlatformTransactionManager> transactionManagers) {
|
||||
this.transactionManagers.addAll(transactionManagers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public MultiTransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
|
||||
|
||||
MultiTransactionStatus mts = new MultiTransactionStatus(transactionManagers.get(0)/*First TM is main TM*/);
|
||||
|
||||
if (!sychronizationManager.isSynchronizationActive()) {
|
||||
sychronizationManager.initSynchronization();
|
||||
if (!synchronizationManager.isSynchronizationActive()) {
|
||||
synchronizationManager.initSynchronization();
|
||||
mts.setNewSynchonization();
|
||||
}
|
||||
|
||||
@@ -81,7 +77,7 @@ public class ChainedTransactionManager implements PlatformTransactionManager {
|
||||
}
|
||||
|
||||
if (multiTransactionStatus.isNewSynchonization()){
|
||||
sychronizationManager.clearSynchronization();
|
||||
synchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
if (commitException != null) {
|
||||
@@ -115,7 +111,7 @@ public class ChainedTransactionManager implements PlatformTransactionManager {
|
||||
}
|
||||
|
||||
if (multiTransactionStatus.isNewSynchonization()){
|
||||
sychronizationManager.clearSynchronization();
|
||||
synchronizationManager.clearSynchronization();
|
||||
}
|
||||
|
||||
if (rollbackException != null) {
|
||||
@@ -124,7 +120,7 @@ public class ChainedTransactionManager implements PlatformTransactionManager {
|
||||
}
|
||||
}
|
||||
|
||||
private <T> Iterable<T> reverse(Collection<T> collection) {
|
||||
private <T> Iterable<T> reverse(Collection<T> collection) {
|
||||
List<T> list = new ArrayList<T>(collection);
|
||||
Collections.reverse(list);
|
||||
return list;
|
||||
|
||||
@@ -174,6 +174,7 @@ public class GraphDatabaseContext {
|
||||
* @return an instance of the entity type
|
||||
*/
|
||||
public <S, T extends GraphBacked> T createEntityFromState(final S state, final Class<T> type) {
|
||||
if (state==null) throw new IllegalArgumentException("state has to be either a Node or Relationship, not null");
|
||||
if (state instanceof Node)
|
||||
return (T) graphEntityInstantiator.createEntityFromState((Node) state, nodeTypeStrategy.confirmType((Node)state, (Class<? extends NodeBacked>)type));
|
||||
else
|
||||
@@ -274,7 +275,20 @@ public class GraphDatabaseContext {
|
||||
* @return
|
||||
*/
|
||||
public Node getOrCreateSubReferenceNode(final RelationshipType relType) {
|
||||
return new GraphDatabaseUtil(graphDatabaseService).getOrCreateSubReferenceNode(relType);
|
||||
return getOrCreateSingleOtherNode(graphDatabaseService.getReferenceNode(), relType, Direction.OUTGOING);
|
||||
}
|
||||
|
||||
private Node getOrCreateSingleOtherNode(Node fromNode, RelationshipType type,
|
||||
Direction direction) {
|
||||
Relationship singleRelationship = fromNode.getSingleRelationship(type, direction);
|
||||
if (singleRelationship != null) {
|
||||
return singleRelationship.getOtherNode(fromNode);
|
||||
}
|
||||
|
||||
Node otherNode = graphDatabaseService.createNode();
|
||||
fromNode.createRelationshipTo(otherNode, type);
|
||||
return otherNode;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.graph.neo4j.support.GraphDatabaseContext;
|
||||
import org.springframework.data.graph.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;
|
||||
@@ -22,7 +23,8 @@ import javax.sql.DataSource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/partial/Neo4jGraphRecommendationTest-context.xml"})
|
||||
@Ignore("NaiveDoubleTM seems to break things in the graph store")
|
||||
@Ignore("seems to break things in the graph store")
|
||||
@DirtiesContext
|
||||
public class RecommendationTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package org.springframework.data.graph.neo4j.support;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.junit.Test;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.junit.internal.matchers.TypeSafeMatcher;
|
||||
import org.springframework.transaction.*;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.data.graph.neo4j.support.ChainedTransactionManagerTest.TestPlatformTransactionManager.createFailingTransactionManager;
|
||||
import static org.springframework.data.graph.neo4j.support.ChainedTransactionManagerTest.TestPlatformTransactionManager.createNonFailingTransactionManager;
|
||||
import static org.springframework.data.graph.neo4j.support.ChainedTransactionManagerTest.TransactionManagerMatcher.isCommitted;
|
||||
import static org.springframework.data.graph.neo4j.support.ChainedTransactionManagerTest.TransactionManagerMatcher.wasRolledback;
|
||||
import static org.springframework.transaction.HeuristicCompletionException.getStateString;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
@@ -17,55 +21,271 @@ import static junit.framework.Assert.assertTrue;
|
||||
*/
|
||||
public class ChainedTransactionManagerTest {
|
||||
|
||||
private ChainedTransactionManager tm;
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldCompleteSuccessfully() throws Exception {
|
||||
ChainedTransactionManager tm = new ChainedTransactionManager(new NullSynchronizationManager());
|
||||
TestPlatformTransactionManager transactionManager = new TestPlatformTransactionManager();
|
||||
tm.setTransactionManagers(Arrays.<PlatformTransactionManager>asList(transactionManager));
|
||||
MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
|
||||
tm.commit(transaction);
|
||||
PlatformTransactionManager transactionManager = createNonFailingTransactionManager("single");
|
||||
setupTransactionManagers(transactionManager);
|
||||
|
||||
assertTrue("TM didn't commit", transactionManager.isCommited());
|
||||
createAndCommitTransaction();
|
||||
|
||||
assertThat(transactionManager, isCommitted());
|
||||
}
|
||||
|
||||
private static class NullSynchronizationManager implements SynchronizationManager {
|
||||
@Test
|
||||
public void shouldThrowRolledBackExceptionForSingleTMFailure() throws Exception {
|
||||
|
||||
setupTransactionManagers(createFailingTransactionManager("single"));
|
||||
try
|
||||
{
|
||||
createAndCommitTransaction();
|
||||
fail("Didn't throw the expected exception");
|
||||
} catch (HeuristicCompletionException e){
|
||||
assertEquals(HeuristicCompletionException.STATE_ROLLED_BACK, e.getOutcomeState());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupTransactionManagers(PlatformTransactionManager... transactionManagers) {
|
||||
tm = new ChainedTransactionManager(new TestSynchronizationManager(), transactionManagers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCommitAllRegisteredTM() throws Exception {
|
||||
PlatformTransactionManager first = createNonFailingTransactionManager("first");
|
||||
PlatformTransactionManager second = createNonFailingTransactionManager("second");
|
||||
setupTransactionManagers(first, second);
|
||||
createAndCommitTransaction();
|
||||
assertThat(first, isCommitted());
|
||||
assertThat(second, isCommitted());
|
||||
}
|
||||
@Test
|
||||
public void shouldCommitInReverseOrder() throws Exception {
|
||||
PlatformTransactionManager first = createNonFailingTransactionManager("first");
|
||||
PlatformTransactionManager second = createNonFailingTransactionManager("second");
|
||||
setupTransactionManagers(first, second);
|
||||
createAndCommitTransaction();
|
||||
assertTrue("second tm commited before first ", commitTime(first) >= commitTime(second));
|
||||
|
||||
// assertThat(second, committedBefore(first));
|
||||
}
|
||||
|
||||
private Long commitTime(PlatformTransactionManager transactionManager) {
|
||||
return ((TestPlatformTransactionManager)transactionManager).getCommitTime();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldThrowMixedRolledBackExceptionForNonFirstTMFailure() throws Exception {
|
||||
|
||||
setupTransactionManagers(
|
||||
TestPlatformTransactionManager.createFailingTransactionManager("first"),
|
||||
createNonFailingTransactionManager("second"));
|
||||
try
|
||||
{
|
||||
createAndCommitTransaction();
|
||||
fail("Didn't throw the expected exception");
|
||||
} catch (HeuristicCompletionException e){
|
||||
assertHeuristicException(HeuristicCompletionException.STATE_MIXED, e.getOutcomeState());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRollbackAllTransactionManagers() throws Exception {
|
||||
|
||||
PlatformTransactionManager first = createNonFailingTransactionManager("first");
|
||||
PlatformTransactionManager second = createNonFailingTransactionManager("second");
|
||||
setupTransactionManagers(first, second);
|
||||
createAndRollbackTransaction();
|
||||
assertThat(first, wasRolledback());
|
||||
assertThat(second, wasRolledback());
|
||||
|
||||
}
|
||||
@Test(expected = UnexpectedRollbackException.class )
|
||||
public void shouldThrowExceptionOnFailingRollback() throws Exception {
|
||||
PlatformTransactionManager first = createFailingTransactionManager("first");
|
||||
setupTransactionManagers(first);
|
||||
createAndRollbackTransaction();
|
||||
}
|
||||
|
||||
private void createAndRollbackTransaction() {
|
||||
MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
|
||||
tm.rollback(transaction);
|
||||
}
|
||||
|
||||
private void assertHeuristicException(final int expected, final int actual) {
|
||||
assertEquals(getStateString(expected), getStateString(actual));
|
||||
}
|
||||
|
||||
private void createAndCommitTransaction() {
|
||||
MultiTransactionStatus transaction = tm.getTransaction(new DefaultTransactionDefinition());
|
||||
tm.commit(transaction);
|
||||
}
|
||||
|
||||
private static class TestSynchronizationManager implements SynchronizationManager {
|
||||
private boolean synchronizationActive;
|
||||
|
||||
@Override
|
||||
public void initSynchronization() {
|
||||
|
||||
synchronizationActive=true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynchronizationActive() {
|
||||
return true;
|
||||
return synchronizationActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSynchronization() {
|
||||
|
||||
synchronizationActive=false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestPlatformTransactionManager implements PlatformTransactionManager {
|
||||
static class TestPlatformTransactionManager implements PlatformTransactionManager {
|
||||
|
||||
private boolean commited;
|
||||
private Long commitTime;
|
||||
private String name;
|
||||
private Long rollbackTime;
|
||||
|
||||
public TestPlatformTransactionManager(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Factory
|
||||
static PlatformTransactionManager createFailingTransactionManager(String name) {
|
||||
return new TestPlatformTransactionManager(name+"-failing")
|
||||
{
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Factory
|
||||
static PlatformTransactionManager createNonFailingTransactionManager(String name) {
|
||||
return new TestPlatformTransactionManager(name+"-non-failing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + (isCommitted() ? " (committed) " : " (not committed)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
|
||||
return null;
|
||||
return new TestTransactionStatus(definition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
commited = true;
|
||||
commitTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
rollbackTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isCommitted() {
|
||||
return commitTime!=null;
|
||||
}
|
||||
public boolean wasRolledBack() {
|
||||
return rollbackTime!=null;
|
||||
}
|
||||
|
||||
public Long getCommitTime() {
|
||||
return commitTime;
|
||||
}
|
||||
|
||||
private static class TestTransactionStatus implements TransactionStatus {
|
||||
|
||||
public TestTransactionStatus(TransactionDefinition definition) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewTransaction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSavepoint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRollbackOnly() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRollbackOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompleted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createSavepoint() throws TransactionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollbackToSavepoint(Object savepoint) throws TransactionException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseSavepoint(Object savepoint) throws TransactionException {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TransactionManagerMatcher extends TypeSafeMatcher<PlatformTransactionManager> {
|
||||
private boolean commitCheck;
|
||||
|
||||
public TransactionManagerMatcher(boolean commitCheck) {
|
||||
this.commitCheck = commitCheck;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(PlatformTransactionManager platformTransactionManager) {
|
||||
TestPlatformTransactionManager ptm = (TestPlatformTransactionManager) platformTransactionManager;
|
||||
if (commitCheck) {
|
||||
return ptm.isCommitted();
|
||||
} else {
|
||||
return ptm.wasRolledBack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommited() {
|
||||
return commited;
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("that a "+(commitCheck ? "committed":"rolled-back")+" TransactionManager");
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static TransactionManagerMatcher isCommitted() {
|
||||
return new TransactionManagerMatcher(true);
|
||||
}
|
||||
@Factory
|
||||
public static TransactionManagerMatcher wasRolledback() {
|
||||
return new TransactionManagerMatcher(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.data.graph.neo4j.Group;
|
||||
import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,6 +30,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class EntityPropertyValidationTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -27,6 +28,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class FinderTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.finder.RelationshipFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,6 +33,7 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class IndexTest {
|
||||
|
||||
private static final String NAME = "name";
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -21,6 +22,7 @@ import static org.springframework.data.graph.neo4j.support.HasRelationshipMatche
|
||||
|
||||
@RunWith( SpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"} )
|
||||
@DirtiesContext
|
||||
public class ModificationOutsideOfTransactionTest
|
||||
{
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -26,6 +27,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class NodeEntityRelationshipTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.finder.RelationshipFinder;
|
||||
import org.springframework.data.graph.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;
|
||||
@@ -31,6 +32,7 @@ import static org.junit.Assert.assertNull;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class NodeEntityTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.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;
|
||||
@@ -28,6 +29,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class ProjectionTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.data.graph.neo4j.Personality;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.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;
|
||||
@@ -32,6 +33,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class PropertyTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -22,6 +23,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class RelationshipEntityTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.data.graph.neo4j.Volvo;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -35,6 +36,7 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class SubReferenceNodeTypeStrategyTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.data.graph.neo4j.Person;
|
||||
import org.springframework.data.graph.neo4j.finder.FinderFactory;
|
||||
import org.springframework.data.graph.neo4j.finder.NodeFinder;
|
||||
import org.springframework.data.graph.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;
|
||||
@@ -31,6 +32,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:org/springframework/data/graph/neo4j/support/Neo4jGraphPersistenceTest-context.xml"})
|
||||
@DirtiesContext
|
||||
public class TraversalTest {
|
||||
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.data.graph.neo4j.support.node.Neo4jConstructorGraphEntityInstantiator"/>
|
||||
</constructor-arg>
|
||||
<constructor-arg ref="entityManagerFactory"/>
|
||||
<constructor-arg ref="entityManager"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="conversionService">
|
||||
@@ -137,21 +137,21 @@
|
||||
|
||||
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.persistence.transaction.NaiveDoubleTransactionManager" >
|
||||
<bean id="transactionManager" class="org.springframework.data.graph.neo4j.support.ChainedTransactionManager" >
|
||||
<constructor-arg>
|
||||
<list>
|
||||
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="jpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
||||
</bean>
|
||||
<!--bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean-->
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
<bean
|
||||
<bean
|
||||
class="org.springframework.transaction.jta.JtaTransactionManager">
|
||||
<property name="transactionManager" ref="neo4jTransactionManagerService" />
|
||||
<property name="userTransaction" ref="neo4jUserTransactionService" />
|
||||
</bean>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
@@ -177,5 +177,7 @@
|
||||
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
|
||||
</bean>
|
||||
|
||||
<!--bean id="neoEntityManager" class="org.springframework.persistence.graph.neo4j.Neo4jEntityManager" scope="prototype"/-->
|
||||
<bean id="entityManager" class="org.springframework.orm.jpa.SharedEntityManagerCreator" factory-method="createSharedEntityManager">
|
||||
<constructor-arg ref="entityManagerFactory"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user