protected CamelContext createPropertiesPlaceholderAwareContext(Properties supplementalProperties)
      throws IOException {
    Properties properties = new Properties(supplementalProperties);
    properties.load(AbstractJsseParametersTest.class.getResourceAsStream("test.properties"));

    if (supplementalProperties != null) {
      Properties mergedProps = new Properties();

      Set<String> keys = new HashSet<String>();
      keys.addAll(properties.stringPropertyNames());
      keys.addAll(supplementalProperties.stringPropertyNames());

      for (String key : keys) {
        mergedProps.setProperty(key, properties.getProperty(key));
      }

      properties = mergedProps;
    }

    properties.store(
        new FileOutputStream("./target/jsse-test.properties"),
        "Generated by " + AbstractJsseParametersTest.class.getName());

    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation("file:./target/jsse-test.properties");

    CamelContext context = new DefaultCamelContext();
    context.addComponent("properties", pc);

    return context;
  }
  @Override
  protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setLocation("ref:myProp");

    return context;
  }
  @Override
  protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    PropertiesComponent pc = new PropertiesComponent();
    pc.setCamelContext(context);
    pc.setLocation("classpath:org/apache/camel/component/properties/cheese.properties");
    context.addComponent("properties", pc);

    return context;
  }
  @Override
  protected CamelContext createCamelContext() throws Exception {
    CamelContext context = super.createCamelContext();

    PropertiesComponent pc = new PropertiesComponent();
    pc.setCamelContext(context);
    pc.setLocations(new String[] {"ref:myCoolProperties"});
    context.addComponent("properties", pc);

    return context;
  }
Example #5
0
  protected RouteBuilder createRouteBuilder() {
    // create the jasypt properties parser
    JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
    // and set the master password
    jasypt.setPassword("secret");

    // configure the properties component
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setLocation("classpath:org/apache/camel/itest/osgi/jasypt/myproperties.properties");
    // and use the jasypt properties parser so we can decrypt values
    pc.setPropertiesParser(jasypt);

    return new RouteBuilder() {
      public void configure() {
        from("direct:start").to("{{cool.result}}");
      }
    };
  }