Search in sources :

Example 41 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class SimpleConfigurationTest method testCreateAndDestroyBeanInSameTransaction.

@Test
public void testCreateAndDestroyBeanInSameTransaction() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName fixed1names = createFixedThreadPool(transaction);
    transaction.destroyModule(fixed1names);
    CommitStatus commitStatus = transaction.commit();
    assertStatus(commitStatus, 0, 0, 0);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) ObjectName(javax.management.ObjectName) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Example 42 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class SimpleConfigurationTest method testAbort.

@Test
public void testAbort() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    assertEquals(1, configRegistryClient.getOpenConfigs().size());
    transaction.abortConfig();
    assertEquals(0, configRegistryClient.getOpenConfigs().size());
    try {
        platformMBeanServer.getMBeanInfo(transaction.getObjectName());
        fail();
    } catch (final InstanceNotFoundException e) {
        assertEquals("org.opendaylight.controller:TransactionName=ConfigTransaction-0-1,type=ConfigTransaction", e.getMessage());
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) InstanceNotFoundException(javax.management.InstanceNotFoundException) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Example 43 with ConfigTransactionJMXClient

use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.

the class SimpleConfigurationTest method testOptimisticLock_ConfigTransactionClient.

@Test
public void testOptimisticLock_ConfigTransactionClient() throws Exception {
    ConfigTransactionJMXClient transaction1 = configRegistryClient.createTransaction();
    ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();
    transaction2.assertVersion(0, 2);
    transaction2.commit();
    try {
        transaction1.commit();
        fail();
    } catch (final ConflictingVersionException e) {
        assertEquals("Optimistic lock failed. Expected parent version 2, was 0", e.getMessage());
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ConflictingVersionException(org.opendaylight.controller.config.api.ConflictingVersionException) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest) Test(org.junit.Test)

Aggregations

ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)43 Test (org.junit.Test)38 AbstractConfigTest (org.opendaylight.controller.config.manager.impl.AbstractConfigTest)26 ObjectName (javax.management.ObjectName)22 CommitStatus (org.opendaylight.controller.config.api.jmx.CommitStatus)15 TestingFixedThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 TestingParallelAPSPConfigMXBean (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean)3 Map (java.util.Map)2 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ConflictingVersionException (org.opendaylight.controller.config.api.ConflictingVersionException)2 ValidationException (org.opendaylight.controller.config.api.ValidationException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Attribute (javax.management.Attribute)1 IntrospectionException (javax.management.IntrospectionException)1 ReflectionException (javax.management.ReflectionException)1 Before (org.junit.Before)1 IdentityAttributeRef (org.opendaylight.controller.config.api.IdentityAttributeRef)1 ExceptionMessageWithStackTrace (org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace)1