예제 #1
0
  @After
  public void tearDown() throws Exception {
    template.stop();
    camelContext.stop();

    stopTestServer();
  }
  @Test
  public void testBlueprintProperties() throws Exception {
    // start bundle
    getInstalledBundle(name).start();

    // must use the camel context from osgi
    CamelContext ctx =
        getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")", 10000);

    ProducerTemplate myTemplate = ctx.createProducerTemplate();
    myTemplate.start();

    // do our testing
    MockEndpoint foo = ctx.getEndpoint("mock:foo", MockEndpoint.class);
    foo.expectedMessageCount(1);
    MockEndpoint result = ctx.getEndpoint("mock:result", MockEndpoint.class);
    result.expectedMessageCount(1);

    myTemplate.sendBody("direct:start", "Hello World");

    foo.assertIsSatisfied();
    result.assertIsSatisfied();

    myTemplate.stop();
  }
예제 #3
0
 public void sendBody(String endpointUri, Object body) throws Exception {
   ProducerTemplate template = context.createProducerTemplate();
   try {
     template.sendBody(endpointUri, body);
   } finally {
     template.stop();
   }
 }
예제 #4
0
 /** Stops the {@link ProducerTemplate}. */
 @Override
 public void stop() {
   try {
     _producerTemplate.stop();
     _logger.debug("Stopped producer template for " + _uri);
   } catch (Exception ex) {
     throw new SwitchYardException("Failed to stop Camel producer template for " + _uri, ex);
   }
 }
예제 #5
0
 public void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers)
     throws Exception {
   ProducerTemplate template = context.createProducerTemplate();
   try {
     template.sendBodyAndHeaders(endpointUri, body, headers);
   } finally {
     template.stop();
   }
 }
예제 #6
0
 public Object requestBody(String endpointUri, Object body) throws Exception {
   ProducerTemplate template = context.createProducerTemplate();
   Object answer = null;
   try {
     answer = template.requestBody(endpointUri, body);
   } finally {
     template.stop();
   }
   return answer;
 }
 @Deactivate
 public void deactivate(Map<?, ?> properties) throws Exception {
   LOG.info("Deactivating: " + COMPONENT_LABEL);
   try {
     rwl.writeLock().lock();
     producer.stop();
     producer = null;
   } finally {
     rwl.writeLock().unlock();
   }
 }
  @After
  public void tearDown() throws Exception {
    log.info("Testing done: " + this);

    log.debug("tearDown test");
    if (consumer != null) {
      consumer.stop();
    }
    if (template != null) {
      template.stop();
    }
    stopCamelContext();
  }
  @Test
  public void testProducerAndConsumer() throws Exception {
    getInstalledBundle("CamelBlueprintJcloudsTestBundle").start();
    CamelContext ctx =
        getOsgiService(
            CamelContext.class,
            "(camel.context.symbolicname=CamelBlueprintJcloudsTestBundle)",
            20000);

    MockEndpoint mock = ctx.getEndpoint("mock:results", MockEndpoint.class);
    ProducerTemplate template = ctx.createProducerTemplate();
    mock.expectedMessageCount(2);

    template.sendBodyAndHeader("direct:start", "Test 1", JcloudsConstants.BLOB_NAME, "blob1");
    template.sendBodyAndHeader("direct:start", "Test 2", JcloudsConstants.BLOB_NAME, "blob2");

    assertMockEndpointsSatisfied();

    template.stop();
  }
예제 #10
0
  @Test
  public void testQuartz2Scheduler() throws Exception {
    // start bundle
    getInstalledBundle(NAME).start();

    // must use the camel context from osgi
    CamelContext ctx =
        getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + NAME + ")", 10000);

    MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(2);

    ProducerTemplate myTemplate = ctx.createProducerTemplate();
    myTemplate.start();

    myTemplate.sendBodyAndHeader("file:target/foo", "Hello World", Exchange.FILE_NAME, "hello.txt");
    myTemplate.sendBodyAndHeader("file:target/foo", "Bye World", Exchange.FILE_NAME, "bye.txt");

    mock.assertIsSatisfied();

    myTemplate.stop();
  }
예제 #11
0
 public void close() throws Exception {
   producerTemplate.stop();
   context.stop();
 }
예제 #12
0
 protected void tearDown() throws Exception {
   template.stop();
   context.stop();
 }