我想对我的cassandra service进行单元测试,这样我就可以使用found cassandra-unit了。因此,我正在使用cassandra-unit:3.1.1.0对我的cassandraservice进行单元测试,遵循了一个找到Here的示例项目,但是我无法运行embedded cassandra服务器来运行我的单元测试。请告诉我哪里出了问题,或者有没有其他库可以用来测试cassandra。
我的测试类
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ CassandraUnitTestExecutionListener.class })
@CassandraDataSet(value = { "simple.cql" })
@EmbeddedCassandra(configuration = "cassandra.yml")
public class CassandraServiceTest {
@Test
public void should_execute_batch() throws Exception {
ResultSetFuture result = session.executeAsync(batch);
assertNotNull(result);
}
}获取超时错误-
我总是收到超时错误,不确定如何增加EmbeddedServer的超时间隔
16:14:13.056 [main] ERROR org.cassandraunit.utils.EmbeddedCassandraServerHelper - Cassandra daemon did not start after 10000 ms. Consider increasing the timeout
16:14:13.067 [main] WARN org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.cassandraunit.spring.CassandraUnitTestExecutionListener@704921a5] to process 'before' execution of test method [public void CassandraServiceTest.should_execute_batch() throws java.lang.Exception] for test instance [CassandraServiceTest@45a37759]
java.lang.AssertionError: Cassandra daemon did not start within timeout依赖关系
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit-spring</artifactId>
<version>3.1.1.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.cassandraunit</groupId>
<artifactId>cassandra-unit</artifactId>
<classifier>shaded</classifier>
<version>3.1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hectorclient</groupId>
<artifactId>hector-core</artifactId>
<version>2.0-0</version>
</dependency>发布于 2017-02-03 12:53:23
你可以看看这个帖子:https://github.com/jsevellec/cassandra-unit/issues/128
基本上你应该增加超时时间:https://github.com/jsevellec/cassandra-unit/pull/127
在您的@EmbeddedCassandra注释with config文件中,您还可以设置超时。
https://stackoverflow.com/questions/42015632
复制相似问题