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

    https://github.com/apache/lucene-solr/pull/464#discussion_r227025974
  
    --- Diff: 
solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java ---
    @@ -656,45 +656,38 @@ public void testAliasingBoost() throws Exception {
       public void testCyclicAliasing() throws Exception {
         try {
           ignoreException(".*Field aliases lead to a cycle.*");
    -      try {
    -        h.query(req("defType","edismax", "q","blarg", "qf","who", 
"f.who.qf","name","f.name.qf","who"));
    -        fail("Simple cyclic alising not detected");
    -      } catch (SolrException e) {
    -        assertTrue(e.getCause().getMessage().contains("Field aliases lead 
to a cycle"));
    -      }
    -      
    -      try {
    -        h.query(req("defType","edismax", "q","blarg", "qf","who", 
"f.who.qf","name","f.name.qf","myalias", "f.myalias.qf","who"));
    -        fail("Cyclic alising not detected");
    -      } catch (SolrException e) {
    -        assertTrue(e.getCause().getMessage().contains("Field aliases lead 
to a cycle"));
    -      }
    -      
    +
    +      SolrException e = expectThrows(SolrException.class, "Simple cyclic 
alising not detected",
    +          () -> h.query(req("defType","edismax", "q","blarg", "qf","who", 
"f.who.qf","name","f.name.qf","who")));
    +      assertCyclicDetectionErrorMessage(e);
    +
    +      e = expectThrows(SolrException.class, "Cyclic alising not detected",
    +          () -> h.query(req("defType","edismax", "q","blarg", "qf","who", 
"f.who.qf","name","f.name.qf","myalias", "f.myalias.qf","who")));
    +      assertCyclicDetectionErrorMessage(e);
    +
           try {
             h.query(req("defType","edismax", "q","blarg", "qf","field1", 
"f.field1.qf","field2 field3","f.field2.qf","field4 field5", 
"f.field4.qf","field5", "f.field5.qf","field6", "f.field3.qf","field6"));
    -      } catch (SolrException e) {
    -        assertFalse("This is not cyclic alising", 
e.getCause().getMessage().contains("Field aliases lead to a cycle"));
    -        assertTrue(e.getCause().getMessage().contains("not a valid field 
name"));
    -      }
    -      
    -      try {
    -        h.query(req("defType","edismax", "q","blarg", "qf","field1", 
"f.field1.qf","field2 field3", "f.field2.qf","field4 field5", 
"f.field4.qf","field5", "f.field5.qf","field4"));
    -        fail("Cyclic alising not detected");
    -      } catch (SolrException e) {
    -        assertTrue(e.getCause().getMessage().contains("Field aliases lead 
to a cycle"));
    -      }
    -      
    -      try {
    -        h.query(req("defType","edismax", "q","who:(Zapp Pig)", 
"qf","text", "f.who.qf","name","f.name.qf","myalias", "f.myalias.qf","who"));
    -        fail("Cyclic alising not detected");
    -      } catch (SolrException e) {
    -        assertTrue(e.getCause().getMessage().contains("Field aliases lead 
to a cycle"));
    +      } catch (SolrException ex) {
    --- End diff --
    
    [Q] Is there a reason that this example also couldn't be changed into an 
`expectThrows`?


---

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

Reply via email to