@Test
  public void testShutdownCompleteCurrentTaskOnly() throws Exception {
    MockEndpoint bar = getMockEndpoint("mock:bar");
    bar.expectedMinimumMessageCount(1);
    bar.setResultWaitTime(3000);

    assertMockEndpointsSatisfied();

    // shutdown during processing
    context.stop();

    // should NOT route all 8
    assertTrue(
        "Should NOT complete all messages, was: " + bar.getReceivedCounter(),
        bar.getReceivedCounter() < 8);
  }
  public void testShutdownCompleteCurrentTaskOnly() throws Exception {
    // give it 20 seconds to shutdown
    context.getShutdownStrategy().setTimeout(20);

    MockEndpoint bar = getMockEndpoint("mock:bar");
    bar.expectedMinimumMessageCount(1);

    assertMockEndpointsSatisfied();

    // shutdown during processing
    context.stop();

    // should NOT route all 5
    assertTrue(
        "Should NOT complete all messages, was: " + bar.getReceivedCounter(),
        bar.getReceivedCounter() < 5);
  }
  @Test
  public void testLevelDBAggregateTimeoutCompletionRestart() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:aggregated");
    mock.expectedMessageCount(0);

    template.sendBodyAndHeader("direct:start", "A", "id", 123);
    template.sendBodyAndHeader("direct:start", "B", "id", 123);
    template.sendBodyAndHeader("direct:start", "C", "id", 123);

    // stop Camel
    context.stop();
    assertEquals(0, mock.getReceivedCounter());

    // start Camel again, and the timeout should trigger a completion
    context.start();

    mock = getMockEndpoint("mock:aggregated");
    mock.expectedBodiesReceived("ABC");

    assertMockEndpointsSatisfied();
    assertEquals(1, mock.getReceivedCounter());
  }