restructuring tests + aspect location
This commit is contained in:
@@ -44,11 +44,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
@@ -215,49 +210,58 @@
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>aspectj-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjtools</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<weaveDependencies>
|
||||
</weaveDependencies>
|
||||
<outxml>true</outxml>
|
||||
<aspectLibraries>
|
||||
<aspectLibrary>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
</aspectLibrary>
|
||||
<!--aspectLibrary>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
</aspectLibrary-->
|
||||
</aspectLibraries>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>aspectj-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjtools</artifactId>
|
||||
<version>${aspectj.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<!--aspectDirectory>src/main/java</aspectDirectory>
|
||||
<testAspectDirectory>src/test/java</testAspectDirectory-->
|
||||
<!--weaveDependencies>
|
||||
<weaveDependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<type>test-jar</type>
|
||||
</weaveDependency>
|
||||
</weaveDependencies-->
|
||||
<outxml>true</outxml>
|
||||
<aspectLibraries>
|
||||
<aspectLibrary>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aspects</artifactId>
|
||||
</aspectLibrary>
|
||||
</aspectLibraries>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.data.neo4j.aspects.support.node;
|
||||
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright 2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.neo4j.aspects.support;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.neo4j.aspects.FriendshipRepository;
|
||||
import org.springframework.data.neo4j.aspects.GroupRepository;
|
||||
import org.springframework.data.neo4j.aspects.PersonRepository;
|
||||
import org.springframework.data.neo4j.repository.DirectGraphRepositoryFactory;
|
||||
import org.springframework.data.neo4j.support.GraphDatabaseContext;
|
||||
import org.springframework.data.neo4j.support.node.Neo4jHelper;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
* @since 15.10.11
|
||||
*/
|
||||
public class EntityTestBase {
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@Autowired protected GraphDatabaseContext graphDatabaseContext;
|
||||
@Autowired protected ConversionService conversionService;
|
||||
|
||||
@Autowired protected GraphDatabaseService graphDatabaseService;
|
||||
|
||||
@Autowired protected DirectGraphRepositoryFactory graphRepositoryFactory;
|
||||
|
||||
@Autowired protected PersonRepository personRepository;
|
||||
@Autowired protected GroupRepository groupRepository;
|
||||
@Autowired protected FriendshipRepository friendshipRepository;
|
||||
protected TestTeam testTeam;
|
||||
|
||||
@Before
|
||||
public void createTeam() throws Exception {
|
||||
testTeam = new TestTeam(graphDatabaseContext);
|
||||
}
|
||||
|
||||
protected Node getNodeState(Object entity) {
|
||||
return graphDatabaseContext.getPersistentState(entity);
|
||||
}
|
||||
protected Long getNodeId(Object entity) {
|
||||
final Node node = graphDatabaseContext.getPersistentState(entity);
|
||||
return node == null ? null : node.getId();
|
||||
}
|
||||
protected Long getRelationshipId(Object entity) {
|
||||
final Relationship rel = graphDatabaseContext.getPersistentState(entity);
|
||||
return rel == null ? null : rel.getId();
|
||||
}
|
||||
|
||||
protected boolean hasPersistentState(Object entity) {
|
||||
return graphDatabaseContext.getPersistentState(entity)!=null;
|
||||
}
|
||||
|
||||
protected Relationship getRelationshipState(Object entity) {
|
||||
return graphDatabaseContext.getPersistentState(entity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T persist(T entity) {
|
||||
return (T) graphDatabaseContext.save(entity);
|
||||
}
|
||||
|
||||
protected <T> Set<T> set(T... values) {
|
||||
return new HashSet<T>(Arrays.<T>asList(values));
|
||||
}
|
||||
|
||||
protected void manualCleanDb() {
|
||||
Transaction tx = graphDatabaseService.beginTx();
|
||||
try {
|
||||
cleanDb();
|
||||
tx.success();
|
||||
} finally {
|
||||
tx.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeTransaction
|
||||
public void cleanDb() {
|
||||
Neo4jHelper.cleanDb(graphDatabaseContext);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user