예제 #1
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   helper.setUp();
   taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();
   StubMapper.fakeSetUp();
 }
 // Run this test twice to demonstrate we're not leaking state across tests.
 // If we _are_ leaking state across tests we'll get an exception on the
 // second test because there will already be a task with the given name.
 private void doTest() throws InterruptedException {
   QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withTaskName("task29"));
   // Give the task time to execute if tasks are actually enabled (which they
   // aren't, but that's part of the test).
   Thread.sleep(1000);
   LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
   QueueStateInfo qsi = ltq.getQueueStateInfo().get(QueueFactory.getDefaultQueue().getQueueName());
   assertEquals(1, qsi.getTaskInfo().size());
   assertEquals("task29", qsi.getTaskInfo().get(0).getTaskName());
 }
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/org/apache/camel/component/gae/task/context-combined.xml"})
@Ignore
public class GTaskCombinedRouteBuilderTest extends ServletTestSupport {

  private static Server server = GTaskTestUtils.createTestServer();

  private final LocalTaskQueueTestConfig config = new LocalTaskQueueTestConfig();
  private final LocalServiceTestHelper helper =
      newLocalServiceTestHelper(config.setDisableAutoTaskExecution(false));

  @Autowired private ProducerTemplate producerTemplate;

  @EndpointInject(uri = "mock:mock")
  private MockEndpoint mock;

  @BeforeClass
  public static void setUpClass() throws Exception {
    server.start();
  }

  @AfterClass
  public static void tearDownClass() throws Exception {
    server.stop();
  }

  @Before
  public void setUp() throws Exception {
    super.setUp();
    helper.setUp();
  }

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

  @Test
  public void testDefault() throws Exception {
    mock.expectedBodiesReceived("test1");
    mock.expectedHeaderReceived("test", "test2");
    producerTemplate.sendBodyAndHeader("direct:input", "test1", "test", "test2");
    mock.assertIsSatisfied();
    Message received = mock.getExchanges().get(0).getIn();
    assertEquals("default", received.getHeader(GTaskBinding.GTASK_QUEUE_NAME));
    assertEquals(0, received.getHeader(GTaskBinding.GTASK_RETRY_COUNT));
  }
}