Search in sources :

Example 21 with ConfigTransactionJMXClient

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

the class TwoInterfacesExportTest method testWithAPSP_useIfcNameMismatch.

@Test
public void testWithAPSP_useIfcNameMismatch() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1");
    TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
    apspProxy.setThreadPool(ObjectNameUtil.createReadOnlyModuleON(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1));
    apspProxy.setSomeParam("someParam");
    transaction.validateConfig();
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Example 22 with ConfigTransactionJMXClient

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

the class TwoInterfacesExportTest method twoInterfaceNamesAfterCreatingConfigBean.

@Test
public void twoInterfaceNamesAfterCreatingConfigBean() throws Exception {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    // create using TestingThreadPoolIfc:
    ObjectName scheduled1name = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    ObjectName retrievedName = transaction.lookupConfigBean(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    assertEquals(scheduled1name, retrievedName);
    // getExistingConfigBean should resolve moduleName
    String moduleName = TestingScheduledThreadPoolModuleFactory.NAME;
    retrievedName = transaction.lookupConfigBean(moduleName, SCHEDULED1);
    ObjectName expected = ObjectNameUtil.createTransactionModuleON(transaction.getTransactionName(), moduleName, SCHEDULED1);
    assertEquals(expected, retrievedName);
    // commit
    transaction.commit();
    assertEquals(1, TestingScheduledThreadPoolImpl.ALLEXECUTORS.size());
    assertFalse(TestingScheduledThreadPoolImpl.ALLEXECUTORS.get(0).isTerminated());
    assertEquals(0, TestingScheduledThreadPoolImpl.getNumberOfCloseMethodCalls());
    assertExists(moduleName, SCHEDULED1);
    // destroy using ThreadPool ifc
    transaction = configRegistryClient.createTransaction();
    transaction.destroyModule(ObjectNameUtil.createTransactionModuleON(transaction.getTransactionName(), moduleName, SCHEDULED1));
    transaction.commit();
    assertEquals(1, TestingScheduledThreadPoolImpl.ALLEXECUTORS.size());
    assertTrue(TestingScheduledThreadPoolImpl.ALLEXECUTORS.get(0).isTerminated());
    assertEquals(1, TestingScheduledThreadPoolImpl.getNumberOfCloseMethodCalls());
    // should not be in platform:
    assertNotExists(moduleName, SCHEDULED1);
    transaction = configRegistryClient.createTransaction();
    // should not be in transaction
    assertNotExists(transaction, moduleName, SCHEDULED1);
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Example 23 with ConfigTransactionJMXClient

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

the class TwoInterfacesExportTest method testWithAPSP_useScheduledNames.

@Test
public void testWithAPSP_useScheduledNames() throws InstanceAlreadyExistsException, ValidationException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName scheduledName = transaction.createModule(TestingScheduledThreadPoolModuleFactory.NAME, SCHEDULED1);
    ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, "apsp1");
    TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
    apspProxy.setThreadPool(scheduledName);
    apspProxy.setSomeParam("someParam");
    transaction.validateConfig();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName) TestingParallelAPSPConfigMXBean(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean) Test(org.junit.Test)

Example 24 with ConfigTransactionJMXClient

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

the class ShutdownTest method setSecret.

private void setSecret(final String secret) throws InstanceNotFoundException, ValidationException, ConflictingVersionException {
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    ObjectName on = transaction.lookupConfigBean(NAME, NAME);
    ShutdownModuleMXBean proxy = transaction.newMXBeanProxy(on, ShutdownModuleMXBean.class);
    proxy.setSecret(secret);
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ObjectName(javax.management.ObjectName)

Example 25 with ConfigTransactionJMXClient

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

the class ShutdownTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    ModuleFactoriesResolver factoriesResolver = new HardcodedModuleFactoriesResolver(mockedContext, factory);
    super.initConfigTransactionManagerImpl(factoriesResolver);
    doReturn(mockedSysBundle).when(mockedContext).getBundle(0);
    mockedContext.getBundle(0);
    doNothing().when(mockedSysBundle).stop();
    doReturn(mockedContext).when(mockedSysBundle).getBundleContext();
    doReturn(new Bundle[] { mockedSysBundle }).when(mockedContext).getBundles();
    doReturn("system bundle").when(mockedSysBundle).getSymbolicName();
    ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
    // initialize default instance
    transaction.commit();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) Before(org.junit.Before)

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