Search in sources :

Example 1 with TestingThreadPoolConfigMXBean

use of org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolConfigMXBean in project controller by opendaylight.

the class TestingParallelAPSPModule method validate.

@Override
public void validate() {
    checkNotNull(threadPoolON, "Parameter 'threadPool' must be set");
    dependencyResolver.validateDependency(TestingThreadPoolServiceInterface.class, threadPoolON, threadPoolOnJMXAttribute);
    checkState(Strings.isNullOrEmpty(someParam) == false, "Parameter 'SomeParam' is blank");
    // check that calling resolveInstance fails
    try {
        dependencyResolver.resolveInstance(TestingThreadPoolIfc.class, threadPoolON, threadPoolOnJMXAttribute);
        throw new RuntimeException("fail");
    } catch (final IllegalStateException e) {
        checkState("Commit was not triggered".equals(e.getMessage()), e.getMessage());
    }
    // test retrieving dependent module's attribute
    int threadCount;
    try {
        threadCount = (Integer) dependencyResolver.getAttribute(threadPoolON, "ThreadCount");
    } catch (final ReflectionException | InstanceNotFoundException | AttributeNotFoundException | MBeanException e) {
        throw new IllegalStateException(e);
    }
    checkState(threadCount > 0);
    TestingThreadPoolConfigMXBean proxy = dependencyResolver.newMXBeanProxy(threadPoolON, TestingThreadPoolConfigMXBean.class);
    checkState(threadCount == proxy.getThreadCount());
}
Also used : ReflectionException(javax.management.ReflectionException) AttributeNotFoundException(javax.management.AttributeNotFoundException) TestingThreadPoolConfigMXBean(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolConfigMXBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanException(javax.management.MBeanException)

Aggregations

AttributeNotFoundException (javax.management.AttributeNotFoundException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanException (javax.management.MBeanException)1 ReflectionException (javax.management.ReflectionException)1 TestingThreadPoolConfigMXBean (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolConfigMXBean)1