コード例 #1
0
  @After
  public void tearDown() throws Exception {
    template.stop();
    camelContext.stop();

    stopTestServer();
  }
コード例 #2
0
  @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
ファイル: OutboundHandler.java プロジェクト: rnc/components
 /** 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;
 }
コード例 #7
0
 @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();
   }
 }
コード例 #8
0
  @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();
  }
コード例 #9
0
  @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();
 }