use of com.sabre.oss.conf4j.source.MapConfigurationSource 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);
}
use of com.sabre.oss.conf4j.source.MapConfigurationSource in project open-kilda by telstra.
the class DefaultConfigurationTest method shouldBeNullIfKeyAbsent.
@Test
public void shouldBeNullIfKeyAbsent() {
// given
MapConfigurationSource source = new MapConfigurationSource(emptyMap());
// when
TestConfig testConfig = factory.createConfiguration(TestConfig.class, source);
// then
assertNull(testConfig.getTestProperty());
}
use of com.sabre.oss.conf4j.source.MapConfigurationSource in project open-kilda by telstra.
the class MappingConfigurationValueProcessorTest method shouldPerformMappingForDefaultValue.
@Test
public void shouldPerformMappingForDefaultValue() {
// given
MapConfigurationSource source = new MapConfigurationSource(emptyMap());
// when
factory.createConfiguration(TestConfig.class, source);
// then
verify(mappingStrategy).apply(eq(TEST_MAPPING_TARGET), eq(TEST_DEFAULT_VALUE));
}
use of com.sabre.oss.conf4j.source.MapConfigurationSource in project open-kilda by telstra.
the class KafkaNamingForConfigurationValueProcessorTest method shouldApplyNamingToProvidedValue.
@Test
public void shouldApplyNamingToProvidedValue() {
// given
MapConfigurationSource source = new MapConfigurationSource(ImmutableMap.of("kafka.topic.ctrl", TEST_VALUE));
// when
KafkaTopicsConfig kafkaTopicsConfig = factory.createConfiguration(KafkaTopicsConfig.class, source);
// then
assertEquals(TEST_PREFIX + "_" + TEST_VALUE, kafkaTopicsConfig.getCtrlTopic());
}
use of com.sabre.oss.conf4j.source.MapConfigurationSource in project open-kilda by telstra.
the class SecondsToMilisConverterTest method shouldConvertToMillis.
@Test
public void shouldConvertToMillis() {
// given
MapConfigurationSource source = new MapConfigurationSource(ImmutableMap.of("test_key", "10"));
// when
TestConfig config = factory.createConfiguration(TestConfig.class, source);
// then
assertEquals(10000, config.getTestProperty());
}
Aggregations