blob: a562aa1cb0112603d2970e3cd2fb795355bc535c (
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
|
// Copyright 2016 Yahoo Inc. 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 lulf
* @since 5.1
*/
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."));
}
}
|