You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jordan Armstrong (JIRA)" <ji...@apache.org> on 2015/07/08 21:26:07 UTC

[jira] [Commented] (CAMEL-8667) java.lang.NullPointerException CamelSpringTestContextLoader.java:174

    [ https://issues.apache.org/jira/browse/CAMEL-8667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14619212#comment-14619212 ] 

Jordan Armstrong commented on CAMEL-8667:
-----------------------------------------

I just ran into this issue and found this via google. The issue is with the documentation. The documentation at [Spring Testing|http://camel.apache.org/spring-testing.html] says to use {{@RunWith(SpringJUnit4ClassRunner.class)}}, but it should be {{@RunWith(CamelSpringJUnit4ClassRunner.class)}}. When using {{SpringJUnit4ClassRunner}} the method {{CamelSpringTestHelper.setTestClass}} never gets called.

For a working example see [CamelSpringDelegatingTestContextLoaderTest|https://github.com/apache/camel/blob/master/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java]. It's not using the {{@Bootstrap}} annotation, instead using the loader param for {{@ContextConfiguration}}, but the effect is the same.


> java.lang.NullPointerException CamelSpringTestContextLoader.java:174
> --------------------------------------------------------------------
>
>                 Key: CAMEL-8667
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8667
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring
>    Affects Versions: 2.15.1
>            Reporter: Chris Love
>            Assignee: Henryk Konsek
>             Fix For: 2.16.0, 2.15.3, 2.14.4
>
>         Attachments: DailyWeatherDataBeanUnmarshallTest.java
>
>
> I am getting a NPE with camel spring unit testing.  I am trying to convert 
> https://github.com/apache/camel/blob/master/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java 
> to pure annotations ... and I am getting a NPE ... 
> I am using:
> {code:java}
> @ContextConfiguration()
> @RunWith(SpringJUnit4ClassRunner.class)
> @BoostrapWith(CamelTestContextBootstrapper.class)
> {code}
> Here is my stack trace.
> {code:java}
> Caused by: java.lang.NullPointerException: null 
> at org.apache.camel.test.spring.CamelSpringTestContextLoader.cleanup(CamelSpringTestContextLoader.java:174)
> at org.apache.camel.test.spring.CamelSpringTestContextLoader.loadContext(CamelSpringTestContextLoader.java:86) 
> at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:68)
> at org.springframework.test.context.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:86)
> at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:72)
> {code}
> The unit test is attached.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)