View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.logging;
8   
9   import java.util.Arrays;
10  import java.util.Collection;
11  
12  import org.junit.Before;
13  import org.junit.runner.RunWith;
14  import org.junit.runners.Parameterized;
15  
16  @RunWith(Parameterized.class)
17  public class AbstractLogHandlerThreadTestCase
18  {
19  
20      protected static boolean createdLoggerReferenceHandler;
21  
22      protected final LoggerFactoryFactory loggerFactory;
23      protected final String logHandlerThreadName;
24  
25      public AbstractLogHandlerThreadTestCase(LoggerFactoryFactory loggerFactory, String logHandlerThreadName)
26      {
27          this.logHandlerThreadName = logHandlerThreadName;
28          this.loggerFactory = loggerFactory;
29      }
30  
31      @Parameterized.Parameters
32      public static Collection<Object[]> parameters()
33      {
34          return Arrays.asList(new Object[][] {
35                  {new MuleLoggerFactoryFactory(), MuleLoggerFactory.LOG_HANDLER_THREAD_NAME},
36                  {new MuleLogFactoryFactory(), MuleLogFactory.LOG_HANDLER_THREAD_NAME}
37          });
38      }
39  
40      @Before
41      public void setUp() throws Exception
42      {
43          createdLoggerReferenceHandler = false;
44      }
45  
46      public static interface LoggerFactoryFactory
47      {
48  
49          Object create();
50      }
51  
52      public static class MuleLoggerFactoryFactory implements LoggerFactoryFactory
53      {
54  
55          public Object create()
56          {
57              return new MuleLoggerFactory()
58              {
59  
60                  @Override
61                  protected void createLoggerReferenceHandler()
62                  {
63                      createdLoggerReferenceHandler = true;
64                  }
65              };
66          }
67      }
68  
69      public static class MuleLogFactoryFactory implements LoggerFactoryFactory
70      {
71  
72          public Object create()
73          {
74              return new MuleLogFactory()
75              {
76                  @Override
77                  protected void createLoggerReferenceHandler()
78                  {
79                      createdLoggerReferenceHandler = true;
80                  }
81              };
82          }
83      }
84  }