*/
package org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.test;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
import javax.annotation.Nullable;
-import javax.management.DynamicMBean;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
import javax.management.ObjectName;
-
+import javax.management.ReflectionException;
import org.junit.Test;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolImpl;
-import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool
- .TestingScheduledThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
public class TwoInterfacesExportTest extends AbstractScheduledTest {
- private void assertExists(String moduleName, String instanceName)
+ private void assertExists(final String moduleName, final String instanceName)
throws Exception {
assertExists(null, moduleName, instanceName);
}
- private void assertExists(@Nullable ConfigTransactionJMXClient transaction,
- String moduleName, String instanceName)
- throws InstanceNotFoundException {
+ private void assertExists(@Nullable final ConfigTransactionJMXClient transaction,
+ final String moduleName, final String instanceName)
+ throws InstanceNotFoundException, IntrospectionException, ReflectionException {
if (transaction != null) {
transaction.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createTransactionModuleON(
- transaction.getTransactionName(), moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createTransactionModuleON(
+ transaction.getTransactionName(), moduleName, instanceName));
} else {
configRegistryClient.lookupConfigBean(moduleName, instanceName);
// make a dummy call
- configRegistryClient.newMBeanProxy(
- ObjectNameUtil.createReadOnlyModuleON(moduleName,
- instanceName), DynamicMBean.class).getMBeanInfo();
+ platformMBeanServer.getMBeanInfo(ObjectNameUtil.createReadOnlyModuleON(moduleName,
+ instanceName));
}
}
- private void assertNotExists(String moduleName, String instanceName) {
+ private void assertNotExists(final String moduleName, final String instanceName) {
assertNotExists(null, moduleName, instanceName);
}
private void assertNotExists(
- @Nullable ConfigTransactionJMXClient transaction,
- String moduleName, String instanceName) {
+ @Nullable final ConfigTransactionJMXClient transaction,
+ final String moduleName, final String instanceName) {
if (transaction != null) {
try {
transaction.lookupConfigBean(moduleName, instanceName);
fail();
- } catch (InstanceNotFoundException e) {
+ } catch (final InstanceNotFoundException e) {
}
} else {
try {
configRegistryClient.lookupConfigBean(moduleName, instanceName);
fail();
- } catch (InstanceNotFoundException e) {
+ } catch (final InstanceNotFoundException e) {
}
}
transaction.createModule(
TestingScheduledThreadPoolModuleFactory.NAME, scheduled1);
fail();
- } catch (InstanceAlreadyExistsException e) {
+ } catch (final InstanceAlreadyExistsException e) {
assertThat(
e.getMessage(),
containsString("There is an instance registered with name ModuleIdentifier{factoryName='scheduled', instanceName='scheduled1'}"));
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(scheduledName);
apspProxy.setSomeParam("someParam");
ObjectName apspName = transaction.createModule(
TestingParallelAPSPModuleFactory.NAME, "apsp1");
- TestingParallelAPSPConfigMXBean apspProxy = transaction.newMBeanProxy(
+ TestingParallelAPSPConfigMXBean apspProxy = transaction.newMXBeanProxy(
apspName, TestingParallelAPSPConfigMXBean.class);
apspProxy.setThreadPool(ObjectNameUtil.createReadOnlyModuleON(
TestingScheduledThreadPoolModuleFactory.NAME, scheduled1));