View Javadoc
1   /*
2    * Copyright 2019 SPF4J.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.spf4j.test.log;
17  
18  import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19  import org.junit.Test;
20  import org.slf4j.Logger;
21  import org.slf4j.LoggerFactory;
22  
23  /**
24   *
25   * @author Zoltan Farkas
26   */
27  @SuppressFBWarnings("LO_SUSPECT_LOG_CLASS") // in this case we are testing.
28  public class TestGlobalErrorIgnore {
29  
30    private static final Logger LOG = LoggerFactory.getLogger(TestGlobalErrorIgnore.class);
31  
32    private static final Logger LOG2 = LoggerFactory.getLogger("a.b");
33  
34    static {
35      java.util.logging.Logger.getLogger(TestGlobalErrorIgnore.class.getName())
36              .severe("This will not fail due to surefirre setup to ignore 0");
37       LOG.error("This will not fail due to surefire setup to ignore 1");
38       LOG2.error("l2");
39    }
40  
41  
42    @Test
43    @SuppressFBWarnings("UTAO_JUNIT_ASSERTION_ODDITIES_NO_ASSERT")
44    // no need for assert, asserting that this test passes while logging an error.
45    public void testSomeHandler() {
46      LOG.error("This will not fail due to surefirre setup to ignore 2");
47      java.util.logging.Logger.getLogger(TestGlobalErrorIgnore.class.getName())
48              .severe("This will not fail due to surefirre setup to ignore 3");
49      LOG2.error("l2");
50    }
51  }