[
https://issues.apache.org/jira/browse/CAMEL-8667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14505733#comment-14505733
]
Chris Love edited comment on CAMEL-8667 at 4/21/15 8:52 PM:
------------------------------------------------------------
[~hekonsek] I am uncertain if it is Spring Boot, but I am trying to use a pure
annotation driven unit test inside of a spring boot project. Only want to load
a camel context and spring context ... Not all of Spring Boot, because then I
get all of the routes that spring boot sees ... I am probably just trying to
create a mess :P
So if I am doing this oddly, please give me more docs on how to do it
'correctly' ... but I am pretty sure that I found a NPE as well.
Guys ... APPRECIATED ... love me some camel coding ;)
As I mentioned, the unit test runs when using:
{code}
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = WeatherApplication.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
{code}
And refering to the Bindy unit test:
https://github.com/apache/camel/blob/master/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java
I externalized the following route builder into a '@Service' that is in another
class in /src/test/java
{code}
public static class ContextConfig extends RouteBuilder {
BindyFixedLengthDataFormat camelDataFormat = new
BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield");
public void configure() {
from(URI_DIRECT_START).unmarshal(camelDataFormat).to(URI_MOCK_RESULT);
}
}
{code}
was (Author: chrislovecnm):
[~hekonsek] I am uncertain if it is Spring Boot, but I am trying to use a pure
annotation driven unit test inside of a spring boot project. Only want to load
a camel context and spring context ... Not all of Spring Boot, because then I
get all of the routes that spring boot sees ... I am probably just trying to
create a mess :P
So if I am doing this oddly, please give me more docs on how to do it
'correctly' ... but I am pretty sure that I found a NPE as well.
Guys ... APPRECIATED ... love me some camel coding ;)
As I mentioned, the unit test runs when using:
<code>
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = WeatherApplication.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
<code>
And refering to the Bindy unit test:
https://github.com/apache/camel/blob/master/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java
I externalized the following route builder into a '@Service' that is in another
class in /src/test/java
<code>
public static class ContextConfig extends RouteBuilder {
BindyFixedLengthDataFormat camelDataFormat = new
BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield");
public void configure() {
from(URI_DIRECT_START).unmarshal(camelDataFormat).to(URI_MOCK_RESULT);
}
}
<code>
> 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.14.3, 2.15.2, 2.16.0
>
> 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)