-
Notifications
You must be signed in to change notification settings - Fork 15.2k
KAFKA-3607: Close KStreamTestDriver upon completing #1258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a06107
db56ece
ca069b1
956f55d
a396de8
79f9359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,15 +95,8 @@ object TestUtils extends Logging { | |
| def tempRelativeDir(parent: String): File = { | ||
| val parentFile = new File(parent) | ||
| parentFile.mkdirs() | ||
| val f = Files.createTempDirectory(parentFile.toPath, "kafka-").toFile | ||
| f.deleteOnExit() | ||
|
|
||
| Runtime.getRuntime().addShutdownHook(new Thread() { | ||
| override def run() = { | ||
| Utils.delete(f) | ||
| } | ||
| }) | ||
| f | ||
| org.apache.kafka.test.TestUtils.tempDirectory(parentFile.toPath, "kafka-"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it not be better to use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack. Changing |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,23 @@ | |
| import org.apache.kafka.streams.errors.TopologyBuilderException; | ||
| import org.apache.kafka.test.KStreamTestDriver; | ||
| import org.apache.kafka.test.MockProcessorSupplier; | ||
| import org.junit.After; | ||
| import org.junit.Test; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| public class KStreamBuilderTest { | ||
|
|
||
| private KStreamTestDriver driver = null; | ||
|
|
||
| @After | ||
| public void cleanup() { | ||
| if (driver != null) { | ||
| driver.close(); | ||
| } | ||
| driver = null; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code seems to be repeated in a lot of tests. Is there a reason why we don't introduce a superclass for initialisation and clean-up of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also make
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ExternalResource: +1 (assuming it'll work that way)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit: Ah, I think you mean that we need to pass
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps @dguy has an idea whether it's possible to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is possible, but you'd need to make a few changes to |
||
|
|
||
| @Test(expected = TopologyBuilderException.class) | ||
| public void testFrom() { | ||
| final KStreamBuilder builder = new KStreamBuilder(); | ||
|
|
@@ -66,7 +77,7 @@ public void testMerge() { | |
| MockProcessorSupplier<String, String> processorSupplier = new MockProcessorSupplier<>(); | ||
| merged.process(processorSupplier); | ||
|
|
||
| KStreamTestDriver driver = new KStreamTestDriver(builder); | ||
| driver = new KStreamTestDriver(builder); | ||
| driver.setTime(0L); | ||
|
|
||
| driver.process(topic1, "A", "aa"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the Scala
TestUtilsto call this method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.