title: testing applicationContext: org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes
body: <p>So I have this helper class for getting the application context:</p>
  
  <pre><code>public class ApplicationContextProvider implements ApplicationContextAware{
      private static ApplicationContext context;
      public static ApplicationContext getApplicationContext() {
          return context;
      }
      public void setApplicationContext(ApplicationContext context) throws BeansException {
          this.context = context;
      }
  }
  </code></pre>
  
  <p>and its unit test:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration()
  public class ApplicationContextProviderTest {
  
      @Test
      public void getApplicationContextInstance(){
          assertNotNull(ApplicationContextProvider.getApplicationContext());
      }
  }
  </code></pre>
  
  <p>with the following resource file (same package with test class):
  <em>ApplicationContextProviderTest-context.xml</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/util
      http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
      &lt;util:map id="contextProperties" /&gt;
  
      &lt;bean id="applicationContextProvider"
            class="com.ideyatech.morphlynx.application.ApplicationContextProvider" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>When I run the test, I get this error:</p>
  
  <pre><code>java.lang.IllegalStateException: Failed to introspect annotations: class com.ideyatech.morphlynx.application.listener.ApplicationContextProviderTest
      at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:169)
      at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:93)
      at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:87)
      at org.springframework.test.context.MetaAnnotationUtils$AnnotationDescriptor.&lt;init&gt;(MetaAnnotationUtils.java:305)
      at org.springframework.test.context.MetaAnnotationUtils$UntypedAnnotationDescriptor.&lt;init&gt;(MetaAnnotationUtils.java:367)
      at org.springframework.test.context.MetaAnnotationUtils$UntypedAnnotationDescriptor.&lt;init&gt;(MetaAnnotationUtils.java:362)
      at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:207)
      at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptorForTypes(MetaAnnotationUtils.java:180)
      at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:622)
      at org.springframework.test.context.DefaultTestContext.&lt;init&gt;(DefaultTestContext.java:93)
      at org.springframework.test.context.TestContextManager.&lt;init&gt;(TestContextManager.java:122)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:118)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.&lt;init&gt;(SpringJUnit4ClassRunner.java:107)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:41)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  Caused by: java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(Ljava/lang/annotation/Annotation;ZZ)Lorg/springframework/core/annotation/AnnotationAttributes;
      at org.springframework.core.annotation.AnnotatedElementUtils$4.process(AnnotatedElementUtils.java:96)
      at org.springframework.core.annotation.AnnotatedElementUtils$4.process(AnnotatedElementUtils.java:93)
      at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:198)
      at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:165)
      ... 30 more
  </code></pre>
  
  <ul>
  <li>How can I fix this? <em>I'm guessing that this is caused by wrong versioning of spring core</em></li>
  <li>Any better way to test <strong>ApplicationContextProvider</strong>?</li>
  </ul>
  
  <p>Thanks!</p>