Skip to content

Commit

Permalink
Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronp committed Sep 16, 2019
1 parent 4afebd3 commit f473a92
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ val scalaTwelve = "2.12.10"
val defaultScalaVersion = scalaTwelve
crossScalaVersions := Seq(scalaTwelve)

paradoxProperties += ("project.url" -> "https://aaronp.github.io/kafka4m/docs/current/")\
paradoxProperties += ("project.url" -> "https://aaronp.github.io/kafka4m/docs/current/")

Compile / paradoxMaterialTheme ~= {
_.withLanguage(java.util.Locale.ENGLISH)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/docker/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ export JVM_ARGS="$JVM_ARGS -Dlogback.configurationFile=/app/config/logback.xml"

echo "Starting w/ $JVM_ARGS on $IPADDR with $# args $@ (first is '$1')"

java ${JVM_ARGS} -cp /app/config:/app/lib/app.jar kafka4m.Kafka4mApp $@ kafka4m-docker.conf
java ${JVM_ARGS} -cp /app/config:/app/lib/app.jar kafka4m.Kafka4mApp $@ kafka4m-docker.conf
2 changes: 1 addition & 1 deletion src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</encoder>
</appender>

<logger name="kafka4m" level="trace" />
<logger name="kafka4m" level="info" />
<logger name="org.apache.kafka" level="warn" />

<root level="info">
Expand Down
9 changes: 5 additions & 4 deletions src/test/scala/kafka4m/io/FileSourceTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ class FileSourceTest extends BaseKafka4mSpec {
}
"repeat non-cached data " in withTestDir { dir =>
val data: Observable[(String, Array[Byte])] = FileSource.keysAndData(
EtlConfig(dir.toAbsolutePath.toString, cache = false, rateLimitPerSecond = None, limit = None,repeat = true, fileNamesAsKeys = true)
EtlConfig(dir.toAbsolutePath.toString, cache = false, rateLimitPerSecond = None, limit = None, repeat = true, fileNamesAsKeys = true)
)

Schedulers.using { implicit s =>
val actual = data.takeList(6).map {
case (name, bytes) => name -> new String(bytes, StandardCharsets.UTF_8)
}

actual.toMap shouldBe Map(
("file2-0.txt", "world"),
("file1-1.txt", "hello"),
Expand All @@ -58,7 +59,7 @@ class FileSourceTest extends BaseKafka4mSpec {
}
"honor the 'fileNamesAsKeys' setting" in withTestDir { dir =>
val data: Observable[(String, Array[Byte])] = FileSource.keysAndData(
EtlConfig(dir.toAbsolutePath.toString, cache = false, rateLimitPerSecond = None, limit = None,repeat = true, fileNamesAsKeys = false)
EtlConfig(dir.toAbsolutePath.toString, cache = false, rateLimitPerSecond = None, limit = None, repeat = true, fileNamesAsKeys = false)
)

Schedulers.using { implicit s =>
Expand All @@ -81,15 +82,15 @@ class FileSourceTest extends BaseKafka4mSpec {
"be able to repeat the contents" in withTestDir { dir =>
Schedulers.using { implicit s =>
val data = FileSource.listChildrenObservable(dir, true)
data.takeList(4).map(_.fileName) should contain theSameElementsAs List("eltInputFile1.txt", "file2.txt", "eltInputFile1.txt", "file2.txt")
data.takeList(4).map(_.fileName) should contain theSameElementsAs List("file1.txt", "file2.txt", "file1.txt", "file2.txt")
}
}
}

def withTestDir(f: Path => Unit) = {
import eie.io._
val dir = s"target/FileSourceTest/${System.currentTimeMillis}".asPath.mkDirs()
val file1 = dir.resolve("eltInputFile1.txt").text = "hello"
val file1 = dir.resolve("file1.txt").text = "hello"
val file2 = dir.resolve("file2.txt").text = "world"
try {
f(dir)
Expand Down

0 comments on commit f473a92

Please sign in to comment.