Search in sources :

Example 31 with ConfigTransactionJMXClient

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

the class NettyThreadgroupModuleTest method testReusingOldInstance.

@Test
public void testReusingOldInstance() throws InstanceAlreadyExistsException, ConflictingVersionException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    createInstance(transaction, instanceName, null);
    transaction.commit();
    transaction = configRegistryClient.createTransaction();
    assertBeanCount(1, factory.getImplementationName());
    CommitStatus status = transaction.commit();
    assertBeanCount(1, factory.getImplementationName());
    assertStatus(status, 0, 0, 1);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 32 with ConfigTransactionJMXClient

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

the class MultipleDependenciesModuleTest method testDestroyModuleDependency.

@Test
public void testDestroyModuleDependency() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1");
    ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1");
    MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class);
    r1Proxy.setSingle(m1);
    transaction.commit();
    transaction = configRegistryClient.createTransaction();
    transaction.destroyModule(factory.getImplementationName(), "middle1");
    try {
        transaction.commit();
        fail("Validation exception expected");
    } catch (ValidationException e) {
        assertThat(e.getFailedValidations().keySet(), CoreMatchers.hasItem("multiple-dependencies"));
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ValidationException(org.opendaylight.controller.config.api.ValidationException) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 33 with ConfigTransactionJMXClient

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

the class NetconfTestImplModuleTest method testNullCheckInListOfDependencies.

@Test
public void testNullCheckInListOfDependencies() throws Exception {
    final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
    final ObjectName on = createInstance(transaction, this.instanceName, 4);
    final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
    proxy.setTestingDeps(null);
    assertTrue(proxy.getTestingDeps().isEmpty());
    proxy.setTestingDeps(Collections.<ObjectName>emptyList());
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) Test(org.junit.Test) AbstractConfigTest(org.opendaylight.controller.config.manager.impl.AbstractConfigTest)

Example 34 with ConfigTransactionJMXClient

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

the class RuntimeBeanTest method testRecreate.

@Test
public void testRecreate() throws Exception {
    ObjectName createdConfigBean = createScheduled();
    // empty transaction
    ConfigTransactionJMXClient configTransaction = configRegistryClient.createTransaction();
    ObjectName scheduledWritableON = configTransaction.lookupConfigBean(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    TestingScheduledThreadPoolConfigBeanMXBean scheduledWritableProxy = configTransaction.newMXBeanProxy(scheduledWritableON, TestingScheduledThreadPoolConfigBeanMXBean.class);
    scheduledWritableProxy.setRecreate(true);
    CommitStatus commitInfo = configTransaction.commit();
    // check that it was recreated
    ObjectName readableConfigBean = ObjectNameUtil.withoutTransactionName(createdConfigBean);
    List<ObjectName> newInstances = Collections.<ObjectName>emptyList();
    List<ObjectName> reusedInstances = Collections.<ObjectName>emptyList();
    List<ObjectName> recreatedInstaces = Lists.newArrayList(readableConfigBean);
    assertEquals(new CommitStatus(newInstances, reusedInstances, recreatedInstaces), commitInfo);
    checkRuntimeBeans();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CommitStatus(org.opendaylight.controller.config.api.jmx.CommitStatus) TestingScheduledThreadPoolConfigBeanMXBean(org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolConfigBeanMXBean) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 35 with ConfigTransactionJMXClient

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

the class RuntimeBeanTest method testDestroy_shouldUnregisterRuntimeBeans.

@Test
public void testDestroy_shouldUnregisterRuntimeBeans() throws Exception {
    ObjectName createdConfigBean = createScheduled();
    ConfigTransactionJMXClient configTransaction = configRegistryClient.createTransaction();
    configTransaction.destroyModule(ObjectNameUtil.createTransactionModuleON(configTransaction.getTransactionName(), createdConfigBean));
    configTransaction.commit();
    for (ObjectName on : allObjectNames) {
        checkRuntimeBeanDoesNotExist(on);
    }
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) 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