我正在构建一个Neo4j(2.2.3)非托管扩展并尝试运行集成测试。按照文档中的示例,我有:
@Test
public void testInsertInitiative() throws Exception {
try ( ServerControls server = TestServerBuilders.newInProcessBuilder()
.withExtension("/graph/initiative", InitiativeController.class)
.withFixture(TestFixtures.foobar(x, y, z))
.newServer() )
{
HTTP.Response response = //... I can't get this far...
}
}
但是,每当我包含数据夹具时,测试都无法在a:
上初始化java.io.EOFException: No content to map to Object due to end of input
at org.neo4j.harness.internal.Fixtures.ensureInstallSuccessful(Fixtures.java:127)
at org.neo4j.harness.internal.Fixtures.applyTo(Fixtures.java:110)
at org.neo4j.harness.internal.InProcessServerBuilder.newServer(InProcessServerBuilder.java:75)
at org.mycompany.myproject.MyTestClass.myTest(MyTestClass.java:87)
如果我注释掉夹具的包含,测试会按预期运行,所以问题肯定存在(也可以从堆栈跟踪中推断出来......)。我已经验证了我的TestFixtures方法通过c / p生成一个有效的cypher语句,并将其导入控制台并成功执行。我也尝试用简单的
替换它.withFixture("CREATE (:foo)")
并得到了相同的结果。
版本2.2.3和2.2.2都会发生这种情况,无论是否加载我的扩展名都会发生这种情况。
在调试跟踪几层之后,我发现/harness/internal/Fixtures.java第109行的ClientResponse response = client.handle( req )
调用收到的响应状态为Server Error和一个空实体,我认为这导致了EOF ......
但为什么服务器出错?再一次,我从客户端的呼叫中获取有效负载并将其(成功)发布到非测试服务器。
以下是我的pom依赖项:
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<neo4j.version>2.2.3</neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>${neo4j.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.neo4j.test</groupId>
<artifactId>neo4j-harness</artifactId>
<version>${neo4j.version}</version>
<scope>test-jar</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
答案 0 :(得分:1)
摆脱这种依赖关系将使测试在你的SSCCE中传递:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>