我想对我的cassandra service
进行单元测试,因此找到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>
答案 0 :(得分:0)
你可以看一下这个帖子: https://github.com/jsevellec/cassandra-unit/issues/128
基本上你应该增加超时: https://github.com/jsevellec/cassandra-unit/pull/127
在带有配置文件的@EmbeddedCassandra注释中,您还可以设置超时。