[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lucene-dev
Subject:    [GitHub] lucene-solr pull request: Use JUnit rules instead of inheritance w...
From:       madrob <git () git ! apache ! org>
Date:       2014-12-31 16:46:04
Message-ID: 20141231164604.DFB90A3AF9B () tyr ! zones ! apache ! org
[Download RAW message or body]

Github user madrob commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/121#discussion_r22387405
  
    --- Diff: solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java \
---  @@ -861,23 +877,107 @@ protected void compareResponses(QueryResponse a, \
QueryResponse b) {  compareSolrResponses(a, b);
       }
     
    -  @Test
    -  public void testDistribSearch() throws Exception {
    -    if (fixShardCount) {
    -      createServers(shardCount);
    -      RandVal.uniqueValues = new HashSet(); //reset random values
    -      doTest();
    -      destroyServers();
    -    } else {
    -      for (int nServers = 1; nServers < shardCount; nServers++) {
    -        createServers(nServers);
    +  @Retention(RetentionPolicy.RUNTIME)
    +  @Target(ElementType.METHOD)
    +  public @interface ShardsRepeat {
    +    public abstract int min() default 1;
    +    public abstract int max() default DEFAULT_MAX_SHARD_COUNT;
    +  }
    +
    +  @Retention(RetentionPolicy.RUNTIME)
    +  @Target(ElementType.METHOD)
    +  public @interface ShardsFixed {
    +    public abstract int num();
    +  }
    +
    +  public class ShardsRepeatRule implements TestRule {
    +
    +    private abstract class ShardsStatement extends Statement {
    +      abstract protected void callStatement() throws Throwable;
    +
    +      @Override
    +      public void evaluate() throws Throwable {
    +        distribSetUp();
    --- End diff --
    
    Worth noting that if distribSetUp() fials for some reason then distribTearDown() \
will not be called. See \
https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/rules/ExternalResource.java \
for this same pattern.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic