View Javadoc

1   package org.apache.maven.surefire.common.junit48;
2   
3   import org.junit.Test;
4   import org.junit.experimental.runners.Enclosed;
5   import org.junit.runner.RunWith;
6   import org.junit.runners.Parameterized;
7   
8   import static org.junit.Assert.assertFalse;
9   import static org.junit.Assert.assertTrue;
10  
11  /*
12   * Licensed to the Apache Software Foundation (ASF) under one
13   * or more contributor license agreements.  See the NOTICE file
14   * distributed with this work for additional information
15   * regarding copyright ownership.  The ASF licenses this file
16   * to you under the Apache License, Version 2.0 (the
17   * "License"); you may not use this file except in compliance
18   * with the License.  You may obtain a copy of the License at
19   *
20   *     http://www.apache.org/licenses/LICENSE-2.0
21   *
22   * Unless required by applicable law or agreed to in writing,
23   * software distributed under the License is distributed on an
24   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25   * KIND, either express or implied.  See the License for the
26   * specific language governing permissions and limitations
27   * under the License.
28   */
29  
30  /**
31   * @author Kristian Rosenvold
32   */
33  public class JUnit48TestCheckerTest
34  {
35      @Test
36      public void valid48Class()
37          throws Exception
38      {
39          JUnit48TestChecker tc = new JUnit48TestChecker( this.getClass().getClassLoader() );
40          assertTrue( tc.accept( BasicTest.class ) );
41      }
42  
43      @Test
44      public void notValid48Class()
45          throws Exception
46      {
47          JUnit48TestChecker tc = new JUnit48TestChecker( this.getClass().getClassLoader() );
48          assertFalse( tc.accept( BasicTest2.class ) );
49      }
50  
51  
52      @RunWith( Enclosed.class )
53      public abstract static class BasicTest
54      {
55          public static class InnerTest
56          {
57              @Test
58              public void testSomething()
59              {
60              }
61          }
62      }
63  
64      @RunWith( Parameterized.class )
65      public abstract static class BasicTest2
66      {
67          public static class InnerTest
68          {
69              @Test
70              public void testSomething()
71              {
72              }
73          }
74      }
75  }