unable to figure out if my scripts executed correctly in embedded-cassandra

允我心安 提交于 2019-12-24 08:58:33

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!