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

Chris M. Hostetter commented on SOLR-15629:
-------------------------------------------

Thinking a little bit more about when/where/how 
{{SolrTestCaseJ4.ignoreException()}} is currently used, a TestRUle might not 
make that much sense – because it would be kind of coarse grained as far as 
when/where to expect the log messages to be generated.  We currently have 
difernet test methods in test classes (and different snippets of code in 
individual test methods) that want to ignore differnet log messages.

a "lambda wrapper" (similar to how {{expectException(...)}} works) would 
probably make more sense...
{code:java}
// mute & record any ERROR messages, then inspect them...
List<LogEvent> actualErrorLogs = LoggerIntercepter.muteError( () -> {
  // test logic that will cause some ERROR logging
});
// assert that the actualErrorLogs only contain what we expect

// mute and record ERROR messages matching a substring...
List<LogEvent> actualErrorLogs = LoggerIntercepter.muteError("ignoreMe", () -> {
  // test logic that will cause two ERROR log msgs matching the substring 
'ignoreMe' to occur
});
assert(2, actualErrorLogs.size());

// etc... {code}
 

...If we had something like that, it could do the heavy lifiting to implement 
TestRules like i described above (if we decide we wanted them)

> replace SolrException.ignorePatterns with a a new test-framework Rule 
> ----------------------------------------------------------------------
>
>                 Key: SOLR-15629
>                 URL: https://issues.apache.org/jira/browse/SOLR-15629
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>            Reporter: Chris M. Hostetter
>            Priority: Major
>
> We should deprecated & remove the following code:
>  * {{SolrException.log()}}
>  * {{SolrException.ignorePatterns}}
>  * {{SolrTestCaseJ4.ignoreException()}}
>  * {{SolrTestCaseJ4.unIgnoreException()}}
>  * {{SolrTestCaseJ4.resetExceptionIgnores()}}
> ...and replace with something along the lines of ... (from SOLR-15628) ...
> {quote}We should probably re-think the entire existence of 
> {{SolrException.log()}} and the API design of 
> {{SolrException.ignorePatterns}} – replacing all callers of 
> {{SolrException.log()}} with {{logger.error()}} and use a new test-only log4j 
> Filter/Appdener
> {quote}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to