1   /*
2    * Copyright (C) The MetaClass Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.metaclass.tools.compiler;
9   
10  import com.thoughtworks.qdox.model.JavaClass;
11  import com.thoughtworks.qdox.model.JavaSource;
12  import junit.framework.TestCase;
13  
14  /***
15   * @author Peter Donald
16   * @version $Revision: 1.3 $ $Date: 2003/11/28 11:14:54 $
17   */
18  public class MulticastJavaClassFilterTestCase
19      extends TestCase
20  {
21      public void testBasicFiltering()
22          throws Exception
23      {
24          final MulticastJavaClassFilter baseFilter =
25              new MulticastJavaClassFilter( new JavaClassFilter[ 0 ] );
26          final MulticastJavaClassFilter filter =
27              new MulticastJavaClassFilter( new JavaClassFilter[]{baseFilter} );
28          final JavaClass result1 = filter.filterClass( null );
29          final JavaClass javaClass = new JavaClass( new JavaSource() );
30          final JavaClass result2 = filter.filterClass( javaClass );
31          assertEquals( "filter(null)", null, result1 );
32          assertEquals( "filter(javaClass)", javaClass, result2 );
33      }
34  
35      public void testCtorWithNullArg()
36          throws Exception
37      {
38          try
39          {
40              new MulticastJavaClassFilter( null );
41          }
42          catch( NullPointerException npe )
43          {
44              assertEquals( "npe.message", "filters", npe.getMessage() );
45              return;
46          }
47          fail( "Expected to fail with NullPOinter in ctor" );
48      }
49  
50      public void testCtorWithNullContainedInArg()
51          throws Exception
52      {
53          try
54          {
55              new MulticastJavaClassFilter( new JavaClassFilter[]{null} );
56          }
57          catch( NullPointerException npe )
58          {
59              assertEquals( "npe.message", "filters[0]", npe.getMessage() );
60              return;
61          }
62          fail( "Expected to fail with NullPOinter in ctor" );
63      }
64  }