You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by owain <ow...@integration.technology> on 2016/11/23 12:58:59 UTC

CamelBluePrintTestSupport 2.17.0 getRouteDefinition null pointer exception

I am getting a similar issue to this old issue on 2.14.0

http://camel.465427.n5.nabble.com/getRouteDefinition-throws-NullPointerException-in-CamelSpringTestSupport-before-context-is-started-td5759499.html

My unit tests pass ok on IntelliJ IDEA but fail intermittently on mvn when I
run the tests all together.  Occasionally it passes.  Sometimes one or two
of the tests in the TestClass fail.

I suspect that the context is not "ready" when I run the tests.  Is there
some sort of race condition occuring and any suggestions on how to avoid
this.  

Here is the general structure:

public class PublishOrderTest extends CamelBlueprintTestSupport {

  @After
  public void tearDown() throws Exception {
    super.tearDown();
  }

  @Override
  protected String getBlueprintDescriptor() {

    return "OSGI-INF/blueprint/order-publish-context.xml," +
            "blueprint/order-publish-test-properties.xml";
  }

  @Override
  public boolean isUseAdviceWith() {
    return true;
  }

  @Test
  public void testMessageReceived() throws Exception {

    ModelCamelContext modelCamelContext = context;

   
modelCamelContext.getRouteDefinition("my-route-id").adviceWith(modelCamelContext,
new AdviceWithRouteBuilder() {
      @Override
      public void configure() throws Exception {
        replaceFromWith("direct:in");
        weaveById("publishedMessage").after().to("mock:out");
      }
    });

    modelCamelContext.start();

    Policy policy = initPolicy();
 
    MockEndpoint mockOut = getMockEndpoint("mock:out");
    mockOut.setExpectedMessageCount(1);

    template.sendBody("direct:in", policy);

    assertMockEndpointsSatisfied();

    modelCamelContext.stop();

  }

Has anyone any ideas?

Thanks,

O.




--
View this message in context: http://camel.465427.n5.nabble.com/CamelBluePrintTestSupport-2-17-0-getRouteDefinition-null-pointer-exception-tp5790419.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CamelBluePrintTestSupport 2.17.0 getRouteDefinition null pointer exception

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello,

There were race conditions fixed (see
http://ggrzybek.blogspot.com/2015/12/camel-blueprint-test-support.html).
What exactly is your NPE?

Please increase logging for "org.apache.camel.test.blueprint" and
"org.apache.camel.blueprint" loggers to see if all the bundles were
included (and maybe you have some duplicates).

regards
Grzegorz Grzybek

2016-11-23 13:58 GMT+01:00 owain <ow...@integration.technology>:

>
> I am getting a similar issue to this old issue on 2.14.0
>
> http://camel.465427.n5.nabble.com/getRouteDefinition-throws-
> NullPointerException-in-CamelSpringTestSupport-before-
> context-is-started-td5759499.html
>
> My unit tests pass ok on IntelliJ IDEA but fail intermittently on mvn when
> I
> run the tests all together.  Occasionally it passes.  Sometimes one or two
> of the tests in the TestClass fail.
>
> I suspect that the context is not "ready" when I run the tests.  Is there
> some sort of race condition occuring and any suggestions on how to avoid
> this.
>
> Here is the general structure:
>
> public class PublishOrderTest extends CamelBlueprintTestSupport {
>
>   @After
>   public void tearDown() throws Exception {
>     super.tearDown();
>   }
>
>   @Override
>   protected String getBlueprintDescriptor() {
>
>     return "OSGI-INF/blueprint/order-publish-context.xml," +
>             "blueprint/order-publish-test-properties.xml";
>   }
>
>   @Override
>   public boolean isUseAdviceWith() {
>     return true;
>   }
>
>   @Test
>   public void testMessageReceived() throws Exception {
>
>     ModelCamelContext modelCamelContext = context;
>
>
> modelCamelContext.getRouteDefinition("my-route-id").adviceWith(
> modelCamelContext,
> new AdviceWithRouteBuilder() {
>       @Override
>       public void configure() throws Exception {
>         replaceFromWith("direct:in");
>         weaveById("publishedMessage").after().to("mock:out");
>       }
>     });
>
>     modelCamelContext.start();
>
>     Policy policy = initPolicy();
>
>     MockEndpoint mockOut = getMockEndpoint("mock:out");
>     mockOut.setExpectedMessageCount(1);
>
>     template.sendBody("direct:in", policy);
>
>     assertMockEndpointsSatisfied();
>
>     modelCamelContext.stop();
>
>   }
>
> Has anyone any ideas?
>
> Thanks,
>
> O.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/CamelBluePrintTestSupport-2-17-0-getRouteDefinition-
> null-pointer-exception-tp5790419.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>