Merge "Bug 499: Initial implementation of data tree modifications"
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / threadpool / test / SimpleConfigurationTest.java
index 13bb84040a10d7d7e4bc4aabfde2401408f11c5b..9852a45853b1fad9f0bbd9ab4e3011bb06f8d29b 100644 (file)
@@ -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;
@@ -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());
         }
@@ -325,26 +326,18 @@ 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){
         }
-        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<String> availableModuleFactoryQNames = configRegistryClient.getAvailableModuleFactoryQNames();
+        String expected = "(namespace?revision=revision)name";
+        assertEquals(Sets.newHashSet(expected), availableModuleFactoryQNames);
+    }
+
 }