我正在尝试迁移到SpringBoot 2和SDN 5,正在努力让单元测试运行。我的测试代码:
@SpringBootTest
@ContextConfiguration(classes = com.playerscoach.auth.context.PersistenceContext.class)
@RunWith(SpringRunner.class)
public class AthleteRepositoryTest {
private static final Logger log = LoggerFactory.getLogger(AthleteRepositoryTest.class);
@Autowired
UserRepository userRepository;
@Autowired
private Session session;
@Autowired
private AthleteRepository athleteRepo;
private GraphDatabaseService graphDb;
private GraphAwareRuntime runtime;
@Before
public void setUp() {
GraphDatabaseService graphDb = new GraphDatabaseFactory()
.newEmbeddedDatabase(new File("var/graphDb"));
GraphAwareRuntime runtime = GraphAwareRuntimeFactory
.createRuntime(graphDb);
}
@After
public void tearDown() {
session.purgeDatabase();
}
/**
* Test of findByTitle method, of class MovieRepository.
*/
@Test
public void testFindByEmail() {
Athlete athlete = new Athlete.Builder()
.firstName("Alper")
.lastName("Akture")
.emailAddress("alper@test.com")
.password("password").build();
athleteRepo.save(athlete);
String email = "alper@test.com";
Collection<Athlete> result = athleteRepo.findByEmailAddress(email);
assertThat(result, notNullValue());
assertThat(result.iterator().next().getPassword(), is("password"));
}
@Test
public void testFindByLastName() {
String lastName = "Akture";
Collection<Athlete> result = athleteRepo.findByLastName(lastName);
assertThat(result, notNullValue());
assertThat(result.iterator().next().getPassword(), is("password"));
}
}
我的存储库:
public interface AthleteRepository extends Neo4jRepository<Athlete, Long> {
Collection<Athlete> findByEmailAddress(@Param("emailAddress") String emailAddress);
Collection<Athlete> findByLastName(@Param("lastName") String lastName);
@Query("MATCH (a:Athlete) WHERE a.emailAddress =~ ('(?i).*'+{emailAddress}+'.*') RETURN a")
Collection<Athlete> findByEmailContaining(@Param("emailAddress") String emailAddress);
}
我的pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M4</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<neo4j-ogm.version>3.0.0</neo4j-ogm.version>
<spring-data-releasetrain.version>Kay-RELEASE</spring-data-releasetrain.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- uncomment to use embedded -->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-embedded-driver</artifactId>
<version>${neo4j-ogm.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.playerscoach.lib</groupId>
<artifactId>lib</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>timetree</artifactId>
<version>3.2.1.51.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.graphaware.neo4j/graphaware-framework-embedded -->
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>graphaware-framework-embedded</artifactId>
<version>3.2.5.51</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.graphaware.neo4j</groupId>
<artifactId>tests</artifactId>
<version>3.2.5.51</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>1.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>3.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>3.1.0</version>
<type>test-jar</type>
</dependency>
当我运行测试时,它会挂起日志文件中的最后一行输出:
07:53:03.526 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath:
转储整个类路径。
知道我哪里出错了?