Search in sources :

Example 1 with JdkProxyStaticConfigurationFactory

use of com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory in project open-kilda by telstra.

the class SwitchManagerTest method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
    config = factory.createConfiguration(SwitchManagerConfig.class, new MapConfigurationSource(emptyMap()));
    ofSwitchService = createMock(IOFSwitchService.class);
    restApiService = createMock(IRestApiService.class);
    featureDetectorService = createMock(FeatureDetectorService.class);
    switchFlowFactory = new SwitchFlowFactory();
    iofSwitch = createMock(IOFSwitch.class);
    switchDescription = createMock(SwitchDescription.class);
    dpid = DatapathId.of(SWITCH_ID.toLong());
    PathVerificationServiceConfig config = EasyMock.createMock(PathVerificationServiceConfig.class);
    expect(config.getVerificationBcastPacketDst()).andReturn("00:26:E1:FF:FF:FF").anyTimes();
    replay(config);
    PathVerificationService pathVerificationService = EasyMock.createMock(PathVerificationService.class);
    expect(pathVerificationService.getConfig()).andReturn(config).anyTimes();
    replay(pathVerificationService);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(context, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    EasyMock.replay(kildaCore);
    context.addService(KildaCore.class, kildaCore);
    SwitchTrackingService switchTracking = createMock(SwitchTrackingService.class);
    switchTracking.setup(context);
    replay(switchTracking);
    context.addService(SwitchTrackingService.class, switchTracking);
    IFloodlightProviderService floodlightProvider = createMock(IFloodlightProviderService.class);
    floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.ERROR), EasyMock.anyObject(SwitchManager.class));
    replay(floodlightProvider);
    context.addService(IFloodlightProviderService.class, floodlightProvider);
    context.addService(IRestApiService.class, restApiService);
    context.addService(IOFSwitchService.class, ofSwitchService);
    context.addService(FeatureDetectorService.class, featureDetectorService);
    context.addService(SwitchFlowFactory.class, switchFlowFactory);
    context.addService(IPathVerificationService.class, pathVerificationService);
    switchManager = new SwitchManager();
    context.addService(ISwitchManager.class, switchManager);
    switchManager.init(context);
    switchManager.startUp(context);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) PathVerificationServiceConfig(org.openkilda.floodlight.pathverification.PathVerificationServiceConfig) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) KildaCore(org.openkilda.floodlight.KildaCore) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) MapConfigurationSource(com.sabre.oss.conf4j.source.MapConfigurationSource) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) Before(org.junit.Before)

Example 2 with JdkProxyStaticConfigurationFactory

use of com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory in project open-kilda by telstra.

the class MappingConfigurationValueProcessorTest method setupFactoryWithMappingStrategy.

@Before
public void setupFactoryWithMappingStrategy() {
    factory = new JdkProxyStaticConfigurationFactory();
    // Define mapping for TEST_MAPPING_TARGET.
    mappingStrategy = mock(MappingStrategy.class);
    when(mappingStrategy.isApplicable(eq(TEST_MAPPING_TARGET))).thenReturn(true);
    when(mappingStrategy.apply(eq(TEST_MAPPING_TARGET), any())).thenReturn("mapped_value");
    factory.setConfigurationValueProcessors(singletonList(new MappingConfigurationValueProcessor(mappingStrategy)));
}
Also used : JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Before(org.junit.Before)

Example 3 with JdkProxyStaticConfigurationFactory

use of com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory in project open-kilda by telstra.

the class ValidatingConfigurationProviderTest method shouldPassValidationForValidConfig.

@Test
public void shouldPassValidationForValidConfig() {
    // given
    Properties source = new Properties();
    source.setProperty(TEST_KEY, String.valueOf(VALID_TEST_VALUE));
    ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider(new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory());
    // when
    TestConfig config = provider.getConfiguration(TestConfig.class);
    // then
    assertEquals(VALID_TEST_VALUE, config.getTestProperty());
}
Also used : PropertiesConfigurationSource(com.sabre.oss.conf4j.source.PropertiesConfigurationSource) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with JdkProxyStaticConfigurationFactory

use of com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory in project open-kilda by telstra.

the class ValidatingConfigurationProviderTest method shouldFailValidationForInvalidConfig.

@Test
public void shouldFailValidationForInvalidConfig() {
    // given
    Properties source = new Properties();
    source.setProperty(TEST_KEY, String.valueOf(INVALID_TEST_VALUE));
    ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider(new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory());
    // when
    expectedException.expect(ConfigurationException.class);
    provider.getConfiguration(TestConfig.class);
// then ConfigurationException is thrown
}
Also used : PropertiesConfigurationSource(com.sabre.oss.conf4j.source.PropertiesConfigurationSource) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with JdkProxyStaticConfigurationFactory

use of com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory in project open-kilda by telstra.

the class KafkaNamingForConfigurationValueProcessorTest method setupFactoryWithNamingStrategy.

@Before
public void setupFactoryWithNamingStrategy() {
    factory = new JdkProxyStaticConfigurationFactory();
    KafkaNamingStrategy namingStrategy = new KafkaNamingStrategy(TEST_PREFIX);
    factory.setConfigurationValueProcessors(singletonList(new KafkaNamingForConfigurationValueProcessor(namingStrategy)));
}
Also used : JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Before(org.junit.Before)

Aggregations

JdkProxyStaticConfigurationFactory (com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory)5 Before (org.junit.Before)3 PropertiesConfigurationSource (com.sabre.oss.conf4j.source.PropertiesConfigurationSource)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 MapConfigurationSource (com.sabre.oss.conf4j.source.MapConfigurationSource)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)1 IRestApiService (net.floodlightcontroller.restserver.IRestApiService)1 KildaCore (org.openkilda.floodlight.KildaCore)1 KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)1 FloodlightModuleConfigurationProvider (org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider)1 IPathVerificationService (org.openkilda.floodlight.pathverification.IPathVerificationService)1 PathVerificationService (org.openkilda.floodlight.pathverification.PathVerificationService)1 PathVerificationServiceConfig (org.openkilda.floodlight.pathverification.PathVerificationServiceConfig)1 FeatureDetectorService (org.openkilda.floodlight.service.FeatureDetectorService)1 SwitchFlowFactory (org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory)1