You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/07/27 22:21:03 UTC

[jira] [Commented] (KAFKA-3623) Make KStreamTestDriver extending from ExternalResource

    [ https://issues.apache.org/jira/browse/KAFKA-3623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16104009#comment-16104009 ] 

ASF GitHub Bot commented on KAFKA-3623:
---------------------------------------

GitHub user johnma14 opened a pull request:

    https://github.com/apache/kafka/pull/3589

    KAFKA-3623: KStreamTestDriver extends ExternalResource

    In the streams project, there are a number of unit tests that has duplicate
    code with respect to the tearDown() method, in which it tries to close the
    KStreamTestDriver connection. The goal of this changeset is to eliminate
    this duplication by converting the KStreamTestDriver class to an ExternalResource
    class which is the base class of JUnit Rule.
    
    In every unit tests that calls KStreamTestDriver, we annotate the KStreamTestDriver
    using @Rule annotation. In the KStreamTestDriver class, we override the after()
    method. This after() method in turn calls the close() method which was previously
    called in the tearDown() method in the unit tests. By annotating the KStreamTestDriver
    as a @Rule, the after() method will be called automatically after every testcase.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/johnma14/kafka bug/KAFKA-3623

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/3589.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3589
    
----
commit 3fb1cd54f507ac35cb0fb64677c9ad386ad89b3e
Author: johnma14 <ma...@us.ibm.com>
Date:   2017-07-15T08:42:23Z

    KAFKA-3623: KStreamTestDriver extends ExternalResource
    
    In the streams project, there are a number of unit tests that has duplicate
    code with respect to the tearDown() method, in which it tries to close the
    KStreamTestDriver connection. The goal of this changeset is to eliminate
    this duplication by converting the KStreamTestDriver class to an ExternalResource
    class which is the base class of JUnit Rule.
    
    In every unit tests that calls KStreamTestDriver, we annotate the KStreamTestDriver
    using @Rule annotation. In the KStreamTestDriver class, we override the after()
    method. This after() method in turn calls the close() method which was previously
    called in the tearDown() method in the unit tests. By annotating the KStreamTestDriver
    as a @Rule, the after() method will be called automatically after every testcase.

----


> Make KStreamTestDriver extending from ExternalResource
> ------------------------------------------------------
>
>                 Key: KAFKA-3623
>                 URL: https://issues.apache.org/jira/browse/KAFKA-3623
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Guozhang Wang
>            Assignee: Mariam John
>              Labels: newbie, test
>
> In unit test we have lots of duplicate code for closing KStreamTestDriver upon completing the test:
> {code}
>     @After
>     public void tearDown() {
>         if (driver != null) {
>             driver.close();
>         }
>         driver = null;
>     }
> {code}
> One way to remove this duplicate code is to make KStreamTestDriver extending from ExternalResource. By doing this we need to move the constructor logic into a setup / init function and leave the construction empty.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)