Java Code Examples for org.apache.camel.component.properties.PropertiesComponent#setInitialProperties()

The following examples show how to use org.apache.camel.component.properties.PropertiesComponent#setInitialProperties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyndesisContextCustomizerTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testSyndesisHeaderStrategy() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();

    Properties properties = new Properties();
    properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "syndesis");

    PropertiesComponent pc  = new PropertiesComponent();
    pc.setInitialProperties(properties);
    context.setPropertiesComponent(pc);

    RuntimeSupport.configureContextCustomizers(context);

    context.start();

    assertThat(context.getRegistry().findByType(HeaderFilterStrategy.class)).hasSize(1);
    assertThat(context.getRegistry().lookupByName("syndesisHeaderStrategy")).isInstanceOf(SyndesisHeaderStrategy.class);

    context.stop();
}
 
Example 2
Source File: CamelContextMetadataMBeanTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuilder() throws Exception {
    CamelContext context = new DefaultCamelContext();

    Properties properties = new Properties();
    properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "metadata");

    PropertiesComponent pc  = new PropertiesComponent();
    pc.setInitialProperties(properties);
    context.setPropertiesComponent(pc);

    RuntimeSupport.configureContextCustomizers(context);

    context.start();

    final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    final Set<ObjectInstance> mBeans = mBeanServer.queryMBeans(ObjectName.getInstance("io.syndesis.camel:*"), null);
    assertThat(mBeans).hasSize(1);

    final ObjectName objectName = mBeans.iterator().next().getObjectName();
    final AttributeList attributes = mBeanServer.getAttributes(objectName, ATTRIBUTES);
    assertThat(attributes.asList()).hasSize(ATTRIBUTES.length);

    context.stop();
}
 
Example 3
Source File: IntegrationLoggingEnabledTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testContextConfiguration() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();

    Properties properties = new Properties();
    properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "logging");

    PropertiesComponent pc = new PropertiesComponent();
    pc.setInitialProperties(properties);
    context.setPropertiesComponent(pc);

    RuntimeSupport.configureContextCustomizers(context);
    context.start();

    assertThat(context.getLogListeners()).hasAtLeastOneElementOfType(IntegrationLoggingListener.class);
    assertThat(context.getUuidGenerator()).isNotInstanceOf(DefaultUuidGenerator.class);
    assertThat(context.getRegistry().lookupByNameAndType("activityTracker", ActivityTracker.class)).isNotNull().isExactlyInstanceOf(ActivityTracker.SysOut.class);

    context.stop();
}
 
Example 4
Source File: IntegrationLoggingDisabledTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void testDisabledContextConfiguration() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();

    Properties properties = new Properties();

    PropertiesComponent pc = new PropertiesComponent();
    pc.setInitialProperties(properties);
    context.setPropertiesComponent(pc);

    RuntimeSupport.configureContextCustomizers(context);

    context.start();

    assertThat(context.getLogListeners()).have(new Condition<LogListener>() {
        @Override
        public boolean matches(LogListener value) {
            return !(value instanceof IntegrationLoggingListener);
        }
    });

    assertThat(context.getUuidGenerator()).isInstanceOf(DefaultUuidGenerator.class);

    context.stop();
}