summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
9e9188a)
Replace org.opendaylight.controller.config.util.ConfigTransactionJMXClient
destroyConfigBean with destroyModule in tests.
Test resource leaks in FixedThreadPoolConfigBeanTest.
Change-Id: If3847d3cb9211d9e830006400c258dad9e6ffb35
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
*/
package org.opendaylight.controller.config.yang.logback.config;
*/
package org.opendaylight.controller.config.yang.logback.config;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import javax.management.ObjectName;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
public class LogbackModuleTest extends AbstractConfigTest {
private static final String INSTANCE_NAME = "singleton";
public class LogbackModuleTest extends AbstractConfigTest {
private static final String INSTANCE_NAME = "singleton";
assertBeanCount(1, factory.getImplementationName());
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
assertBeanCount(1, factory.getImplementationName());
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- transaction.destroyConfigBean(factory.getImplementationName(), INSTANCE_NAME);
+ transaction.destroyModule(factory.getImplementationName(), INSTANCE_NAME);
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
*/
package org.opendaylight.controller.config.threadpool.fixed;
*/
package org.opendaylight.controller.config.threadpool.fixed;
+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 java.lang.management.ManagementFactory;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory;
import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean;
import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleFactory;
import org.opendaylight.controller.config.yang.threadpool.impl.fixed.FixedThreadPoolModuleMXBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {
private FixedThreadPoolModuleFactory factory;
public class FixedThreadPoolConfigBeanTest extends AbstractConfigTest {
private FixedThreadPoolModuleFactory factory;
@Test
public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,
InstanceNotFoundException {
@Test
public void testDestroy() throws InstanceAlreadyExistsException, ValidationException, ConflictingVersionException,
InstanceNotFoundException {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- createFixed(transaction, nameInstance, 1);
+ int numberOfThreads = 100;
+ int threadCount1 = ManagementFactory.getThreadMXBean().getThreadCount();
+ assertTrue("Expected less than " + numberOfThreads + " threads, got " + threadCount1, threadCount1 < numberOfThreads);
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ createFixed(transaction, nameInstance, numberOfThreads);
+ int threadCount2 = ManagementFactory.getThreadMXBean().getThreadCount();
+ assertTrue("Expected more than " + numberOfThreads + " threads, got " + threadCount2, threadCount2 > numberOfThreads);
transaction = configRegistryClient.createTransaction();
transaction = configRegistryClient.createTransaction();
- transaction.destroyConfigBean(factory.getImplementationName(), nameInstance);
+ transaction.destroyModule(factory.getImplementationName(), nameInstance);
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
assertStatus(status, 0, 0, 1);
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
assertStatus(status, 0, 0, 1);
+ int threadCount3 = ManagementFactory.getThreadMXBean().getThreadCount();
+ assertTrue("Expected less than " + numberOfThreads + " threads, got " + threadCount3, threadCount3 < numberOfThreads);
*/
package org.opendaylight.controller.config.threadpool.scheduled;
*/
package org.opendaylight.controller.config.threadpool.scheduled;
+import static org.junit.Assert.assertEquals;
+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.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;
import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleFactory;
import org.opendaylight.controller.config.yang.threadpool.impl.scheduled.ScheduledThreadPoolModuleMXBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
-import static org.junit.Assert.assertEquals;
-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;
-
public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {
private ScheduledThreadPoolModuleFactory factory;
public class ScheduledThreadPoolConfigBeanTest extends AbstractConfigTest {
private ScheduledThreadPoolModuleFactory factory;
transaction.commit();
transaction = configRegistryClient.createTransaction();
transaction.commit();
transaction = configRegistryClient.createTransaction();
- transaction.destroyConfigBean(factory.getImplementationName(), instanceName);
+ transaction.destroyModule(factory.getImplementationName(), instanceName);
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
CommitStatus status = transaction.commit();
assertBeanCount(0, factory.getImplementationName());
package org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig;
package org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
import com.google.common.collect.Sets;
import com.google.common.collect.Sets;
+import java.util.Map;
+import javax.management.Attribute;
+import javax.management.ObjectName;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
import org.opendaylight.controller.config.util.ConfigTransactionClient;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
-import javax.management.Attribute;
-import javax.management.ObjectName;
-import java.util.Map;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
public class ReplaceEditConfigStrategyTest {
@Mock
public class ReplaceEditConfigStrategyTest {
@Mock
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- doNothing().when(ta).destroyConfigBean(anyString(), anyString());
+ doNothing().when(ta).destroyModule(anyString(), anyString());
doReturn(mockON()).when(ta).lookupConfigBean(anyString(), anyString());
doNothing().when(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
}
doReturn(mockON()).when(ta).lookupConfigBean(anyString(), anyString());
doNothing().when(ta).setAttribute(any(ObjectName.class), anyString(), any(Attribute.class));
}