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

    https://github.com/apache/brooklyn-server/pull/473#discussion_r90473445
  
    --- Diff: 
test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
 ---
    @@ -332,6 +343,56 @@ public void testFailFastIfNoSensor() throws Exception {
             assertStartFails(app, NullPointerException.class, 
Asserts.DEFAULT_LONG_TIMEOUT);
         }
     
    +    @Test
    +    public void testDoesNotLogStacktraceRepeatedly() throws Exception {
    +        final long time = System.currentTimeMillis();
    +        final String sensorValue = String.format("%s%s%s", 
Identifiers.makeRandomId(8), time, Identifiers.makeRandomId(8));
    +        
    +        // Test case will repeatedly fail until we have finished our 
logging assertions.
    +        // Then we'll let it complete by setting the sensor.
    +        TestSensor testCase = 
app.createAndManageChild(EntitySpec.create(TestSensor.class)
    +                .configure(TestSensor.TIMEOUT, 
Asserts.DEFAULT_LONG_TIMEOUT)
    +                .configure(TestSensor.TARGET_ENTITY, app)
    +                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
    +                .configure(TestSensor.ASSERTIONS, 
newListAssertion("matches", String.format(".*%s.*", time))));
    +
    +        String loggerName = Repeater.class.getName();
    +        ch.qos.logback.classic.Level logLevel = 
ch.qos.logback.classic.Level.DEBUG;
    +        Predicate<ILoggingEvent> repeatedFailureMsgMatcher = 
EventPredicates.containsMessage("repeated failure; excluding stacktrace");
    +        Predicate<ILoggingEvent> stacktraceMatcher = 
EventPredicates.containsExceptionStackLine(TestFrameworkAssertions.class, 
"checkActualAgainstAssertions");
    +        Predicate<ILoggingEvent> filter = 
Predicates.or(repeatedFailureMsgMatcher, stacktraceMatcher);
    +        LogWatcher watcher = new LogWatcher(loggerName, logLevel, filter);
    +
    +        Task<Void> task;
    --- End diff --
    
    Why is this declared outside the `try`/`catch` block? It doesn't seem to be 
used anywhere else?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to