Released Mocked Streams for Apache Kafka
Kafka Streams is a deployment-agnostic stream processing library written in Java. Even though Kafka has a great test coverage, there is no easy way to write unit-tests for processing topologies, until now. I released Mocked Streams for Scala, which simply allows you to unit-test multi-input and output stateful stream topologies (since Apache Kafka >= 0.10.1) without Zookeeper and Kafka Brokers in your favorite Scala testing framework e.g. ScalaTest and Specs2.
import com.madewithtea.mockedstreams.MockedStreams
val input = Seq(("x", "v1"), ("y", "v2"))
val expe = Seq(("x", "V1"), ("y", "V2"))
val strings = Serdes.String()
MockedStreams()
.topology { builder => builder.stream(...) [...] }
.input("topic-in", strings, strings, input)
.output("topic-out", strings, strings, expe.size) shouldEqual expe
Mocked Streams
Mocked Streams 1.0 is a library which allows you to do the latter without much boilerplate code and in your favourite Scala testing framework. It wraps the org.apache.kafka.test.ProcessorTopologyTestDriver class, but adds more syntactic sugar to keep your test code simple. The features of the 1.0 release include:
- Multiple input and output streams
- Specify your topologies as a function: (KStreamBuilder => Unit)
- Use .config to pass your Kafka Streams configuration (e.g. Timestamp extractor)
- Use .outputTable to match against the compacted table output as Map[K,V]
- Support for Scala 2.11.8
- Support for Apache Kafka 0.10.1.0
Multiple Inputs and Outputs
val ms = MockedStreams()
.topology { builder => builder.stream(...) [...] }
.input("in-a", strings, ints, inputA)
.input("in-b", strings, ints, inputB)
.stores(Seq("store-name")) ms.output("out-a", strings, ints, expA.size) shouldEqual(expectedA)
ms.output("out-b", strings, ints, expB.size) shouldEqual(expectedB)
Getting Started
See the README for using Mocked Streams. For examples check out the test code of Mocked Streams itself. Mocked Streams is also located in the Maven Central Repository, hence you just need to add:
libraryDependencies += "com.madewithtea" %% "mockedstreams" % "1.0.0" % "test"
If you have any questions or issues regarding Mocked Streams, get in touch via Github. Alternatively, you can get in contact via mail.
Released Mocked Streams for Apache Kafka的更多相关文章
- Apache Samza - Reliable Stream Processing atop Apache Kafka and Hadoop YARN
http://engineering.linkedin.com/data-streams/apache-samza-linkedins-real-time-stream-processing-fram ...
- Apache Kafka for Item Setup
At Walmart.com in the U.S. and at Walmart's 11 other websites around the world, we provide seamless ...
- Apache Kafka:下一代分布式消息系统
[http://www.infoq.com/cn/articles/apache-kafka/]分布式发布-订阅消息系统. Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和可复制的提交日 ...
- Apache Kafka: Next Generation Distributed Messaging System---reference
Introduction Apache Kafka is a distributed publish-subscribe messaging system. It was originally dev ...
- DataPipeline |《Apache Kafka实战》作者胡夕:Apache Kafka监控与调优
胡夕 <Apache Kafka实战>作者,北航计算机硕士毕业,现任某互金公司计算平台总监,曾就职于IBM.搜狗.微博等公司.国内活跃的Kafka代码贡献者. 前言 虽然目前Apache ...
- An Overview of End-to-End Exactly-Once Processing in Apache Flink (with Apache Kafka, too!)
01 Mar 2018 Piotr Nowojski (@PiotrNowojski) & Mike Winters (@wints) This post is an adaptation o ...
- How Cigna Tuned Its Spark Streaming App for Real-time Processing with Apache Kafka
Explore the configuration changes that Cigna’s Big Data Analytics team has made to optimize the perf ...
- 《Apache Kafka 实战》读书笔记-认识Apache Kafka
<Apache Kafka 实战>读书笔记-认识Apache Kafka 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.kafka概要设计 kafka在设计初衷就是 ...
- Streaming SQL for Apache Kafka
KSQL是基于Kafka的Streams API进行构建的流式SQL引擎,KSQL降低了进入流处理的门槛,提供了一个简单的.完全交互式的SQL接口,用于处理Kafka的数据. KSQL是一套基于Apa ...
随机推荐
- ios The App Life Cycle
先推荐ios 必读文章 App Programming Guide for iOS ,请在苹果官网搜索,并仔细阅读所有内容 State Description Not running The app ...
- iOS keyChain 的使用
详细资料,请参看苹果官方文档Keychain Services Reference . ios中的keychain,用于保存用户的机密信息,对keychain的操作有4种,就是 增,删,改,查: Se ...
- 无IDE时编译和运行Java
最近 Java subreddit 出现了一篇”在没有IDE的情况下编译Java包” 的帖子,这个帖子抛出了这么一个问题,“是否存在一个命令可以编译一组处于同一文件夹下独立包内的java文件的方法(这 ...
- c语言实现面向对象OOC
这种问题比较锻炼思维,同时考察c和c++的掌握程度.如果你遇到过类似问题,此题意义自不必说.如果用c实现c++,主要解决如何实现封装,继承和多态三大问题,本文分两块说. 1.封装 // Example ...
- jquery 中的一写常用方法
$('form').submit(); // 表单提交 window.parent.location.reload(); // 子窗口刷新父页面 window.location.reload(); / ...
- 【资料】Boost的资料
http://blog.csdn.net/pongba/article/details/1561110
- asp.net 曲线图
public void draw(DataTable dt) { //取得记录数量 int count = dt.Rows.Count; //记算图表宽度 int wd = 80 + 20 * (co ...
- MongoDB配置文件YAML-based选项全解
配置文件部分 MongoDB引入一个YAML-based格式的配置文件.2.4版本以前的仍然兼容. 我的mongodb配置文件: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
- MyBatis mapper文件中的变量引用方式#{}与${}的差别
MyBatis mapper文件中的变量引用方式#{}与${}的差别 #{},和 ${}传参的区别如下:使用#传入参数是,sql语句解析是会加上"",当成字符串来解析,这样相比于$ ...
- NYOJ题目112指数运算
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs0AAAIICAIAAAAaCETRAAAgAElEQVR4nO3drW7jWtwv4PcmwnMhxb ...