无法确定我的脚本是否在嵌入式cassandra中正确执行 [英] unable to figure out if my scripts executed correctly in embedded-cassandra

查看:71
本文介绍了无法确定我的脚本是否在嵌入式cassandra中正确执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个单元测试,该单元测试使用 embedded-cassandra 并执行一些脚本。但是我无法弄清楚这些脚本是否成功运行。

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()

    }
  }

用法中可能还存在另一个问题。虽然我正在创建 TestCassandra 。我没有将cassandraFactory实例传递给它。所以我想知道 embedded-cassandra 是否已经开始!

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!!

我试图创建 TestCassandra 通过 cassandraFactory cqlStatements 传递,但出现错误 TestCassandra中的参数过多

I tried to create TestCassandra by passing cassandraFactory and cqlStatements but I got error too many arguments in TestCassandra

推荐答案

无法设置版本

It is not possible to set a version from a configuration file.

您是否使用任何 slf4j 提供程序进行日志记录?

Do you use any of slf4j providers for logging ?

查看脚本已执行的最简单方法是为 com启用 debug 级别。github.nosan .embedded.cassandra.test.util.CqlUtils

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.


我试图通过传递cassandraFactory和
cqlStatements来创建TestCassandra,但是在TestCassandra中出现了太多的参数

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(...,...))

这篇关于无法确定我的脚本是否在嵌入式cassandra中正确执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆