X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-eos%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fentityownership%2Fselectionstrategy%2FEntityOwnerSelectionStrategyConfigReaderTest.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-eos%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fentityownership%2Fselectionstrategy%2FEntityOwnerSelectionStrategyConfigReaderTest.java;h=0000000000000000000000000000000000000000;hb=118c8b39d7bece6c3dc4adb8e27401a325b69692;hp=b83f85e16700c15036931c399f4be70076ffb70e;hpb=d8deaa4381251e0900a6ba50d1f16bab47ab8491;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfigReaderTest.java b/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfigReaderTest.java deleted file mode 100644 index b83f85e167..0000000000 --- a/opendaylight/md-sal/sal-distributed-eos/src/test/java/org/opendaylight/controller/cluster/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfigReaderTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.cluster.entityownership.selectionstrategy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; - -public class EntityOwnerSelectionStrategyConfigReaderTest { - - @Test - public void testReadStrategies() { - final Map props = new java.util.HashMap<>(); - props.put("entity.type.test", - "org.opendaylight.controller.cluster.entityownership.selectionstrategy.LastCandidateSelectionStrategy,100"); - - - final EntityOwnerSelectionStrategyConfig config = EntityOwnerSelectionStrategyConfigReader - .loadStrategyWithConfig(props); - - assertTrue(config.isStrategyConfigured("test")); - - final EntityOwnerSelectionStrategy strategy = config.createStrategy("test", - Collections.emptyMap()); - assertTrue(strategy.toString(), strategy instanceof LastCandidateSelectionStrategy); - assertEquals(100L, strategy.getSelectionDelayInMillis()); - - final EntityOwnerSelectionStrategy strategy1 = config.createStrategy("test", Collections.emptyMap()); - assertEquals(strategy, strategy1); - - config.clearStrategies(); - - final EntityOwnerSelectionStrategy strategy2 = config.createStrategy("test", Collections.emptyMap()); - assertNotEquals(strategy1, strategy2); - } - - @Test - public void testReadStrategiesWithEmptyConfiguration() { - - final Map props = new HashMap<>(); - final EntityOwnerSelectionStrategyConfig config = EntityOwnerSelectionStrategyConfigReader - .loadStrategyWithConfig(props); - - assertFalse(config.isStrategyConfigured("test")); - } - - @Test - public void testReadStrategiesWithNullConfiguration() { - final EntityOwnerSelectionStrategyConfig config = EntityOwnerSelectionStrategyConfigReader - .loadStrategyWithConfig(null); - assertFalse(config.isStrategyConfigured("test")); - } - - @Test(expected = IllegalArgumentException.class) - public void testReadStrategiesInvalidDelay() { - final Map props = new HashMap<>(); - props.put("entity.type.test", - "org.opendaylight.controller.cluster.entityownership.selectionstrategy.LastCandidateSelectionStrategy,foo"); - EntityOwnerSelectionStrategyConfigReader.loadStrategyWithConfig(props); - } - - @Test(expected = IllegalArgumentException.class) - public void testReadStrategiesInvalidClassType() { - final Map props = new HashMap<>(); - props.put("entity.type.test", "String,100"); - EntityOwnerSelectionStrategyConfigReader.loadStrategyWithConfig(props); - } - - @Test - public void testReadStrategiesMissingDelay() { - final Map props = new HashMap<>(); - props.put("entity.type.test", - "org.opendaylight.controller.cluster.entityownership.selectionstrategy.LastCandidateSelectionStrategy,100"); - props.put("entity.type.test1", - "org.opendaylight.controller.cluster.entityownership.selectionstrategy.LastCandidateSelectionStrategy"); - - - final EntityOwnerSelectionStrategyConfig config = EntityOwnerSelectionStrategyConfigReader - .loadStrategyWithConfig(props); - - assertEquals(100, config.createStrategy("test", Collections.emptyMap()).getSelectionDelayInMillis()); - assertEquals(0, config.createStrategy("test2", Collections.emptyMap()).getSelectionDelayInMillis()); - } -}