You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Chris Nauroth (JIRA)" <ji...@apache.org> on 2016/02/04 20:01:40 UTC

[jira] [Commented] (ZOOKEEPER-2361) Revisit 'VisibleForTesting' phrase used to indicate a member or method visible for testing

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

Chris Nauroth commented on ZOOKEEPER-2361:
------------------------------------------

I assume this pattern was inspired by the Guava [{{VisibleForTesting}}|http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/annotations/VisibleForTesting.html] annotation used in other projects like Hadoop.  I don't think there is anything wrong with the current pattern of using a {{// VisibleForTesting}} comment in the ZooKeeper code.  I don't have a better suggestion, so I'd be comfortable closing this as Won't Fix.  Maybe others have something else in mind?

Also, I recommend against introducing a Guava dependency, especially if it's just for this annotation.  Hadoop is currently stuck on an old version of Guava for backwards-compatibility reasons.  It has been a source of frustration for users that try to use a newer version of Guava in their Hadoop-based applications.  On the whole, the benefits of using the code in Guava have not out-weighed the dependency management problems.

> Revisit 'VisibleForTesting' phrase used to indicate a member or method visible for testing
> ------------------------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-2361
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2361
>             Project: ZooKeeper
>          Issue Type: Improvement
>            Reporter: Rakesh R
>            Assignee: Rakesh R
>            Priority: Minor
>
> ZooKeeper uses {{// VisibleForTesting}} comment to indicate a member or method which is visible for unit testing. The idea of this jira is to discuss better ways to convey the message more clear and implement the same. One idea could use annotations, needs to introduce {{@VisibleForTesting}}
> For example, 
> [ContainerManager.java#L134|https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/server/ContainerManager.java#L134], [PurgeTxnLog.java#L78|https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/server/PurgeTxnLog.java#L78], [ZooKeeper.java#L1011|https://github.com/apache/zookeeper/blob/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java#L1011] etc.
> {code}
> ZooKeeper.java
>     // VisibleForTesting
>     public Testable getTestable() {
>         return new ZooKeeperTestable(this, cnxn);
>     }
> {code}
> {code}
> PurgeTxnLog.java
>     // VisibleForTesting
>     static void retainNRecentSnapshots(FileTxnSnapLog txnLog, List<File> snaps) {
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)