lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barrotsteindev <...@git.apache.org>
Subject [GitHub] lucene-solr pull request #464: WIP SOLR-12555: refactor tests in package org...
Date Mon, 22 Oct 2018 19:31:41 GMT
Github user barrotsteindev commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/464#discussion_r227038483
  
    --- Diff: solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java ---
    @@ -414,56 +391,44 @@ public void testOptimisticLocking() throws Exception {
         version2 = addAndGetVersion(sdoc("id","1", "_version_", Long.toString(version)),
null);
         assertTrue(version2 > version);
     
    -    try {
    -      // overwriting the previous version should now fail
    -      version2 = addAndGetVersion(sdoc("id","1"), params("_version_", Long.toString(version)));
    -      fail();
    -    } catch (SolrException se) {
    -      assertEquals(409, se.code());
    -    }
    +    // overwriting the previous version should now fail
    +    se = expectThrows(SolrException.class, "overwriting previous version should fail",
    +        () -> addAndGetVersion(sdoc("id","1"), params("_version_", Long.toString(version))));
    +    assertEquals(409, se.code());
     
    -    try {
    -      // deleting the previous version should now fail
    -      version2 = deleteAndGetVersion("1", params("_version_", Long.toString(version)));
    -      fail();
    -    } catch (SolrException se) {
    -      assertEquals(409, se.code());
    -    }
    +    // deleting the previous version should now fail
    +    se = expectThrows(SolrException.class, "deleting the previous version should now
fail",
    +        () -> deleteAndGetVersion("1", params("_version_", Long.toString(version))));
    +    assertEquals(409, se.code());
     
    -    version = version2;
    +    final long prevVersion = version2;
    --- End diff --
    
    The only problem is that if the variables are not final, they can not be used inside the
lambda that is passed to expectThrows.
    Should I just revert these changes?


---

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


Mime
View raw message