View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.core.joran.spi;
15  
16  import org.junit.jupiter.api.Test;
17  
18  import java.lang.annotation.ElementType;
19  import java.lang.annotation.Retention;
20  import java.lang.annotation.RetentionPolicy;
21  import java.lang.annotation.Target;
22  
23  import static org.junit.jupiter.api.Assertions.assertFalse;
24  import static org.junit.jupiter.api.Assertions.assertTrue;
25  
26  public class NoAutoStartUtilTest {
27  
28      @Test
29      public void commonObject() {
30          Object o = new Object();
31          assertTrue(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
32      }
33  
34      @Test
35      public void markedWithNoAutoStart() {
36          DoNotAutoStart o = new DoNotAutoStart();
37          assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
38      }
39      
40  
41      
42      /*
43       * Annotation declared on implemented interface
44       */
45      @Test
46      public void noAutoStartOnInterface() {
47      	ComponentWithNoAutoStartOnInterface o = new ComponentWithNoAutoStartOnInterface();
48          assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
49      }
50  
51      @NoAutoStart
52      public interface NoAutoStartInterface {
53      }
54      
55      private static class ComponentWithNoAutoStartOnInterface implements NoAutoStartInterface {
56      }
57  
58      
59      
60      /*
61       * Annotation declared on ancestor
62       */
63      @Test
64      public void noAutoStartOnAncestor() {
65      	ComponentWithNoAutoStartOnAncestor o = new ComponentWithNoAutoStartOnAncestor();
66          assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
67      }
68      
69      private static class ComponentWithNoAutoStartOnAncestor extends DoNotAutoStart {	
70      }
71  
72      
73      
74      /*
75       * Annotation declared on interface implemented by an ancestor
76       */
77      @Test
78      public void noAutoStartOnInterfaceImplementedByAncestor() {
79      	ComponentWithAncestorImplementingInterfaceWithNoAutoStart o = new ComponentWithAncestorImplementingInterfaceWithNoAutoStart();
80          assertFalse(NoAutoStartUtil.notMarkedWithNoAutoStart(o));
81      }
82      
83      private static class ComponentWithAncestorImplementingInterfaceWithNoAutoStart extends ComponentWithNoAutoStartOnInterface {	
84      }
85  
86  }