View Javadoc
1   package org.apache.maven.surefire.junitcore;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.lang.annotation.Annotation;
23  import java.lang.reflect.Method;
24  import org.apache.maven.surefire.common.junit4.JUnit4Reflector;
25  import org.apache.maven.surefire.util.ReflectionUtils;
26  
27  import org.junit.Assert;
28  import org.junit.Ignore;
29  import org.junit.Test;
30  import org.junit.runner.Description;
31  
32  /**
33   * Reflector Test with junit 4.8.1
34   *
35   * @author Kristian Rosenvold
36   */
37  public class JUnit4Reflector481Test
38  {
39      private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
40  
41      @Test
42      public void testGetAnnotatedIgnore()
43      {
44          JUnit4Reflector reflector = new JUnit4Reflector();
45          final Method testSomething2 =
46              ReflectionUtils.getMethod( IgnoreWithDescription.class, "testSomething2", EMPTY_CLASS_ARRAY );
47          final Annotation[] annotations = testSomething2.getAnnotations();
48          Description desc =
49              Description.createTestDescription( IgnoreWithDescription.class, "testSomething2", annotations );
50          Ignore annotatedIgnore = reflector.getAnnotatedIgnore( desc );
51          Assert.assertEquals( reason, annotatedIgnore.value() );
52      }
53  
54      private static final String reason = "Ignorance is bliss";
55  
56      public static class IgnoreWithDescription
57      {
58  
59          @Test
60          @Ignore( reason )
61          public void testSomething2()
62          {
63          }
64      }
65  
66  
67  }