aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/test/java/com/yahoo/log/RejectFilterTest.java
blob: 6f7a6d0ff0848c028e29c0de703fefb9ae83afeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.log;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * @author Ulf Lilleengen
 * @since 5.1
 */
@SuppressWarnings("removal")
public class RejectFilterTest {
    @Test
    public void testBasicPatternMatching() {
        RejectFilter rejectFilter = new RejectFilter();
        assertFalse(rejectFilter.shouldReject("This is a test"));
        rejectFilter.addRejectedMessage("This is a test");
        assertTrue(rejectFilter.shouldReject("This is a test"));
        rejectFilter.addRejectedMessage("This is not a test");
        assertTrue(rejectFilter.shouldReject("This is a test"));
        assertTrue(rejectFilter.shouldReject("This is not a test"));
        assertFalse(rejectFilter.shouldReject("This is not not a test"));
        assertFalse(rejectFilter.shouldReject(null));
    }

    @Test
    public void testDefaultRejectPattern() {
        RejectFilter filter = RejectFilter.createDefaultRejectFilter();
        assertTrue(filter.shouldReject("E 23-235018.067240 14650 23/10/2012 23:50:18 yjava_preload.so: [preload.c:350] Using FILTER_NONE:  This must be paranoid approved, and since you are using FILTER_NONE you must live with this error."));
    }
}