View Javadoc

1   package org.apache.log4j.chainsaw.receivers;
2   
3   import java.util.List;
4   
5   import junit.framework.TestCase;
6   
7   import org.apache.log4j.chainsaw.receivers.ReceiversHelper;
8   import org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver;
9   import org.apache.log4j.net.JMSReceiver;
10  import org.apache.log4j.net.MulticastReceiver;
11  import org.apache.log4j.net.SocketHubReceiver;
12  import org.apache.log4j.net.SocketReceiver;
13  import org.apache.log4j.net.UDPReceiver;
14  import org.apache.log4j.net.XMLSocketReceiver;
15  import org.apache.log4j.db.DBReceiver;
16  import org.apache.log4j.varia.LogFilePatternReceiver;
17  
18  
19  /***
20   * Test class to ensure that all the know receiver classes can be retrieved and are recognised as
21   * valid Classess
22   * 
23   * @author psmith
24   *
25   */
26  public class ReceiversHelperTest extends TestCase {
27  
28      /***
29       * @param arg0
30       */
31      public ReceiversHelperTest(String test) {
32          super(test);
33      }
34  
35      public void testKnownReceivers() {
36  
37          List list = ReceiversHelper.getInstance().getKnownReceiverClasses();
38  
39          Class[] expectedList =
40              new Class[] {
41                  MulticastReceiver.class, 
42                  SocketHubReceiver.class, 
43                  SocketReceiver.class,
44                  UDPReceiver.class, 
45                  XMLSocketReceiver.class,
46                  LogFilePatternReceiver.class,
47                  JMSReceiver.class,
48                  DBReceiver.class,
49                  VFSLogFilePatternReceiver.class,
50              };
51  
52          for (int i = 0; i < expectedList.length; i++) {
53  
54              Class c = expectedList[i];
55              assertTrue("Should have found class " + c.getName(),
56                  list.contains(c));
57          }
58      }
59  }