use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.
the class DynamicWritableWrapperTest method testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON.
/*
* Try to call setter with ObjectName containing transaction name. Verify that
* ObjectName without transaction name was actually passed on the config bean.
*/
@Test
public void testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON() throws Exception {
TestingParallelAPSPModuleFactory testingParallelAPSPConfigBeanFactory = new TestingParallelAPSPModuleFactory();
TestingParallelAPSPModule apspConfigBean = testingParallelAPSPConfigBeanFactory.createModule("", null, null);
ModuleIdentifier moduleIdentifier2 = new ModuleIdentifier("apsp", "parallel");
ObjectName dynON2 = ObjectNameUtil.createReadOnlyModuleON(moduleIdentifier2);
AbstractDynamicWrapper dyn = getDynamicWrapper(apspConfigBean, moduleIdentifier2);
platformMBeanServer.registerMBean(dyn, dynON2);
try {
TestingParallelAPSPConfigMXBean proxy = JMX.newMBeanProxy(platformMBeanServer, dynON2, TestingParallelAPSPConfigMXBean.class);
ObjectName withTransactionName = ObjectNameUtil.createTransactionModuleON("transaction1", "moduleName", "instanceName");
proxy.setThreadPool(withTransactionName);
ObjectName withoutTransactionName = ObjectNameUtil.withoutTransactionName(withTransactionName);
assertEquals(withoutTransactionName, proxy.getThreadPool());
} finally {
platformMBeanServer.unregisterMBean(dynON2);
}
}
use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean 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();
}
use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean 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();
}
use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.
the class AbstractParallelAPSPTest method createParallelAPSP.
protected ObjectName createParallelAPSP(final ConfigTransactionJMXClient transaction, final ObjectName threadPoolON) throws InstanceAlreadyExistsException {
ObjectName apspName = transaction.createModule(TestingParallelAPSPModuleFactory.NAME, apsp1);
TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction.newMXBeanProxy(apspName, TestingParallelAPSPConfigMXBean.class);
parallelAPSPConfigProxy.setSomeParam("ahoj");
parallelAPSPConfigProxy.setThreadPool(threadPoolON);
return apspName;
}
use of org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean in project controller by opendaylight.
the class DependentWiringTest method testDependencies.
@Test
public void testDependencies() throws Exception {
ObjectName apspON;
{
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
// create fixed1
ObjectName threadPoolTransactionON = createFixed1(transaction, TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
// create apsp-parallel
ObjectName apspNameTransactionON = createParallelAPSP(transaction, threadPoolTransactionON);
TestingParallelAPSPConfigMXBean parallelAPSPConfigProxy = transaction.newMXBeanProxy(apspNameTransactionON, TestingParallelAPSPConfigMXBean.class);
// trigger validation
parallelAPSPConfigProxy.setSomeParam("");
// failure
try {
transaction.validateConfig();
fail();
} catch (final ValidationException e) {
for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
assertThat(entry.getValue().getMessage(), containsString("Parameter 'SomeParam' is blank"));
}
}
}
// try committing (validation fails)
try {
transaction.commit();
fail();
} catch (final ValidationException e) {
for (Map.Entry<String, Map<String, ExceptionMessageWithStackTrace>> exception : e.getFailedValidations().entrySet()) {
for (Map.Entry<String, ExceptionMessageWithStackTrace> entry : exception.getValue().entrySet()) {
String err = entry.getValue().getMessage();
assertTrue("Unexpected error message: " + err, err.contains("Parameter 'SomeParam' is blank"));
}
}
}
// fix validation
parallelAPSPConfigProxy.setSomeParam("abc");
// failure
transaction.commit();
apspON = ObjectNameUtil.withoutTransactionName(apspNameTransactionON);
}
// test reported apsp number of threads
TestingParallelAPSPConfigMXBean parallelAPSPRuntimeProxy = configRegistryClient.newMXBeanProxy(apspON, TestingParallelAPSPConfigMXBean.class);
assertEquals((Integer) TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
// next transaction - recreate new thread pool
int newNumberOfThreads = TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS * 2;
{
// start new transaction
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName threadPoolNamesNewTx = transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
TestingFixedThreadPoolConfigMXBean fixedConfigTransactionProxy = transaction.newMXBeanProxy(threadPoolNamesNewTx, TestingFixedThreadPoolConfigMXBean.class);
fixedConfigTransactionProxy.setThreadCount(newNumberOfThreads);
transaction.commit();
}
// new reference should be copied to apsp-parallel
assertEquals((Integer) newNumberOfThreads, parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
}
Aggregations