X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Ftestingservices%2Fthreadpool%2Ftest%2FSimpleConfigurationTest.java;h=97d1c63ed2770da0ceb4fb504a4795a775b12c89;hp=13bb84040a10d7d7e4bc4aabfde2401408f11c5b;hb=e159106bc148e76fc1e3e3c780bdd740d99e74ed;hpb=3c23bcbd856bec57ceecbbda3f84bebd4994b0b6 diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java index 13bb84040a..97d1c63ed2 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.config.manager.testingservices.threadpool.test; +import com.google.common.collect.Sets; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,11 +30,11 @@ import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.ObjectName; import javax.management.ReflectionException; -import javax.management.RuntimeMBeanException; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ThreadPoolExecutor; import static org.junit.Assert.assertEquals; @@ -55,7 +56,7 @@ import static org.junit.Assert.fail; * dependencies. */ public class SimpleConfigurationTest extends AbstractConfigTest { - private final int numberOfThreads = 5; + private static final int numberOfThreads = 5; private final int numberOfThreads2 = 10; private static final String fixed1 = "fixed1"; private static final List emptyONs = Collections @@ -67,7 +68,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { @Before public void setUp() { - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver( + super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new TestingFixedThreadPoolModuleFactory())); } @@ -95,7 +96,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { return fixed1names; } - private ObjectName createFixedThreadPool( + static ObjectName createFixedThreadPool( ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException, InstanceNotFoundException { transaction.assertVersion(0, 1); @@ -133,7 +134,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { private void testValidation(ConfigTransactionClient transaction) throws InstanceAlreadyExistsException, ReflectionException, - InstanceNotFoundException, MBeanException { + InstanceNotFoundException, MBeanException, ConflictingVersionException { ObjectName fixed1names = transaction.createModule( TestingFixedThreadPoolModuleFactory.NAME, fixed1); // call validate on config bean @@ -141,8 +142,8 @@ public class SimpleConfigurationTest extends AbstractConfigTest { platformMBeanServer.invoke(fixed1names, "validate", new Object[0], new String[0]); fail(); - } catch (RuntimeMBeanException e) { - RuntimeException targetException = e.getTargetException(); + } catch (MBeanException e) { + Exception targetException = e.getTargetException(); assertNotNull(targetException); assertEquals(ValidationException.class, targetException.getClass()); } @@ -245,8 +246,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { // 4, check assertEquals(2, configRegistryClient.getVersion()); - assertEquals(1, TestingFixedThreadPool.allExecutors.size()); - assertTrue(TestingFixedThreadPool.allExecutors.get(0).isShutdown()); + assertEquals(0, TestingFixedThreadPool.allExecutors.size()); // dynamic config should be removed from platform try { @@ -277,7 +277,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { // commit transaction.commit(); // check that first threadpool is closed - checkThreadPools(2, numberOfThreads2); + checkThreadPools(1, numberOfThreads2); } private void checkThreadPools(int expectedTotalNumberOfExecutors, @@ -307,7 +307,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest { // commit CommitStatus commitStatus = transaction.commit(); // check that new threadpool is created and old one is closed - checkThreadPools(2, numberOfThreads); + checkThreadPools(1, numberOfThreads); CommitStatus expected = new CommitStatus(emptyONs, emptyONs, fixed1List); assertEquals(expected, commitStatus); } @@ -325,26 +325,19 @@ public class SimpleConfigurationTest extends AbstractConfigTest { } @Test - public void testAbort() { + public void testAbort() throws Exception { ConfigTransactionJMXClient transaction = configRegistryClient .createTransaction(); assertEquals(1, configRegistryClient.getOpenConfigs().size()); transaction.abortConfig(); + assertEquals(0, configRegistryClient.getOpenConfigs().size()); try { - transaction.createModule(TestingFixedThreadPoolModuleFactory.NAME, - fixed1); + platformMBeanServer.getMBeanInfo(transaction.getObjectName()); fail(); - } catch (Exception e) { - assertTrue(e.getCause() instanceof InstanceNotFoundException); + }catch(InstanceNotFoundException e){ + assertEquals("org.opendaylight.controller:TransactionName=ConfigTransaction-0-1,type=ConfigTransaction", e.getMessage()); } - try { - transaction.validateConfig(); - fail(); - } catch (Exception e) { - assertTrue(e.getCause() instanceof InstanceNotFoundException); - } - assertEquals(0, configRegistryClient.getOpenConfigs().size()); } @Test @@ -384,4 +377,11 @@ public class SimpleConfigurationTest extends AbstractConfigTest { } + @Test + public void testQNames() { + Set availableModuleFactoryQNames = configRegistryClient.getAvailableModuleFactoryQNames(); + String expected = "(namespace?revision=revision)name"; + assertEquals(Sets.newHashSet(expected), availableModuleFactoryQNames); + } + }