嵌入式的Cassandra单元测试选项

发布于 2025-01-24 04:26:31 字数 545 浏览 2 评论 0原文

我们的团队正在更新我们的依赖项,其中之一是 cassandra单位。我注意到上一次图书馆是更新是在2020年1月的很长一段时间没有任何活动。此外,还有12个刚刚坐着的开放请求。我确实注意到有些开发人员已经分配了此存储库,以添加他们想要的功能。

我们喜欢使用此库通过JUNIT在DAO对象中测试CQL,并计划升级到最新版本(4.3.1.0)。

我希望领导这项工作的开发人员(JSEVELLEC)做得很好。但是,在此存储库中没有活动和长期思考的情况下,我想知道还有哪些可用的库可以通过JUNIT使用嵌入式的Cassandra实例来易于测试,而Junit可以更积极地支持。

Our team was in the process of updating our dependencies and one of those is Cassandra Unit. I noticed that the last time this library was updated was in January of 2020 and that there hasn't been any activity in a long time. In addition there are 12 open pull requests that have just been sitting. I did notice some developers have forked this repo to add features they wanted.

We have enjoyed using this library to test CQL in our DAO objects via JUnit and are planning to upgrade to the latest version (4.3.1.0).

I hope that the developer (jsevellec) that was leading this effort is doing well. But in the absence of activity on this repo, and thinking longer term, I was wondering what other libraries might be available that allow ease of testing using an embedded Cassandra instance via JUnit that are more actively supported.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2025-01-31 04:26:31

到目前为止,我看到了两种方法:

  1. jsevellec合作,如果您喜欢
  2. 使用 testContainers+Cassandra
     公共类
    
        @规则
        公共Cassandracontainer Cassandra =新的Cassandracontainer();
    
    
        @测试
        公共void test(){
            群集群集= cassandra.getCluster();
    
            尝试(session session = cluster.connect()){
    
                session.execute(“创建键空间(如果不存在),则使用replication = \ n” +
                        “ {'class':'simplertategy','replication_factor':'1'};”);
    
                列表< keyspacemetadata> keyspaces = session.getCluster()。getMetadata()。getKeySpaces();
                列表< keyspacemetadata>过滤keyspaces =键空间
                        。溪流()
                        。
                        .Collect(collectors.tolist());
    
                assertequals(1,filteredkeyspaces.size());
            }
        }
    }
     

    这里有一些与Spring + TestContainers + Cassandra有关的问题,

So far I see two ways:

  1. Cooperation with jsevellec if you like that product
  2. Using testcontainers+cassandra
    public class SomeTest {
    
        @Rule
        public CassandraContainer cassandra = new CassandraContainer();
    
    
        @Test
        public void test(){
            Cluster cluster = cassandra.getCluster();
    
            try(Session session = cluster.connect()) {
    
                session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH replication = \n" +
                        "{'class':'SimpleStrategy','replication_factor':'1'};");
    
                List<KeyspaceMetadata> keyspaces = session.getCluster().getMetadata().getKeyspaces();
                List<KeyspaceMetadata> filteredKeyspaces = keyspaces
                        .stream()
                        .filter(km -> km.getName().equals("test"))
                        .collect(Collectors.toList());
    
                assertEquals(1, filteredKeyspaces.size());
            }
        }
    }
    

    There are some questions related to Spring + Testcontainers + Cassandra here https://stackoverflow.com/a/58673372/6916890

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文