问题
I have created a unit-test which uses embedded-cassandra
and executes some scripts. But I am not able to figure out if the scripts ran successfully or not.
I see the following two prints (maybe because I have two statements). Is there a way to get the result of the execution and print it on the console.
WARN c.d.d.c.Connection - /127.0.0.1:9042 did not send an authentication challenge; This is suspicious because the driver expects authentication (configured auth provider = com.datastax.driver.core.PlainTextAuthProvider)
WARN c.d.d.c.Connection - /127.0.0.1:9042 did not send an authentication challenge; This is suspicious because the driver expects authentication (configured auth provider = com.datastax.driver.core.PlainTextAuthProvider)
"UsersRepository Specs" should {
"create keyspace" in {
val factory = new LocalCassandraFactory
println(s"factory is ${factory}")
factory.setVersion(("3.11.1")) //TODOM . shall I pick these fromm a config file?
val statement1 =
"""
|CREATE KEYSPACE myspace
| WITH REPLICATION = {
| 'class' : 'SimpleStrategy',
| 'replication_factor' : 1
| };
""".stripMargin
val statement2 =
"""
|SELECT * FROM system_schema.keyspaces
""".stripMargin
val cqlStatements:CqlStatements = new CqlStatements(statement1,statement2)
val cassandraFactory = factory.create
val testCassandra = new TestCassandra();
try {
testCassandra.start()
testCassandra.executeScripts(cqlStatements)
} finally testCassandra.stop()
}
}
There might also be another issue in the usage. Though I am creating TestCassandra
. I am not passing cassandraFactory instance to it. So I am wondering if embedded-cassandra
has even started!!
I tried to create TestCassandra
by passing cassandraFactory
and cqlStatements
but I got error too many arguments in TestCassandra
回答1:
It is not possible to set a version from a configuration file.
Do you use any of slf4j
providers for logging ?
The easiest way to see that your scripts have been executed it just enables debug level for com.github.nosan.embedded.cassandra.test.util.CqlUtils
.
If you don't see any exceptions then there is no issues with scripts execution.
I tried to create TestCassandra by passing cassandraFactory and cqlStatements but I got error too many arguments in TestCassandra
I think you should use this constructor.
public TestCassandra(CassandraFactory cassandraFactory, CqlScript... scripts) {}
new TestCassandra(cassandraFactory, CqlScripts.statemets(...,...))
来源:https://stackoverflow.com/questions/56205743/unable-to-figure-out-if-my-scripts-executed-correctly-in-embedded-cassandra