use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class MultipleDependenciesModuleTest method testCloseOrdering.
@Test
public void testCloseOrdering() throws Exception {
// Tests whether close is called in correct order on the module instances on following graph
// Each module tests whether its dependencies were closed before it (to simulate resource clean up failure)
// R1
// | \
// M1 M2
// |
// L1
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1");
ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1");
ObjectName m2 = transaction.createModule(factory.getImplementationName(), "middle2");
ObjectName l1 = transaction.createModule(factory.getImplementationName(), "leaf1");
MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class);
MultipleDependenciesModuleMXBean i1Proxy = transaction.newMXBeanProxy(m1, MultipleDependenciesModuleMXBean.class);
r1Proxy.setSingle(m1);
i1Proxy.setSingle(l1);
r1Proxy.setTestingDeps(asList(m2));
transaction.commit();
configRegistryClient.createTransaction().commit();
transaction = configRegistryClient.createTransaction();
MultipleDependenciesModuleMXBean l1Proxy = transaction.newMXBeanProxy(l1, MultipleDependenciesModuleMXBean.class);
l1Proxy.setSimple(true);
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class MultipleDependenciesModuleTest method testMultipleDependencies.
@Test
public void testMultipleDependencies() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
ObjectName d1 = transaction.createModule(factory.getImplementationName(), "d1");
ObjectName d2 = transaction.createModule(factory.getImplementationName(), "d2");
assertEquals(transaction.getTransactionName(), getTransactionName(d1));
ObjectName parent = transaction.createModule(factory.getImplementationName(), "parent");
MultipleDependenciesModuleMXBean multipleDependenciesModuleMXBean = transaction.newMXBeanProxy(parent, MultipleDependenciesModuleMXBean.class);
multipleDependenciesModuleMXBean.setTestingDeps(asList(d1, d2));
List<ObjectName> found = multipleDependenciesModuleMXBean.getTestingDeps();
ObjectName d1WithoutTxName = found.get(0);
assertEquals(getInstanceName(d1), getInstanceName(d1WithoutTxName));
// check that transaction name gets stripped automatically from attribute.
// d1,2 contained tx name, found doesn't
assertNull(getTransactionName(d1WithoutTxName));
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class NetconfTestImplModuleTest method testIdentities.
@Test
public void testIdentities() throws Exception {
final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
final ObjectName nameCreated = transaction.createModule(IdentityTestModuleFactory.NAME, this.instanceName);
final IdentityTestModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, IdentityTestModuleMXBean.class);
final IdentitiesContainer c = new IdentitiesContainer();
c.setAfi(new IdentityAttributeRef(TestIdentity2.QNAME.toString()));
mxBean.setIdentitiesContainer(c);
transaction.commit();
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class NetconfTestImplModuleTest method testDependencyList.
@Test
public void testDependencyList() throws Exception {
ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
final ObjectName on = createInstance(transaction, this.instanceName, 4);
transaction.validateConfig();
final CommitStatus status1 = transaction.commit();
assertBeanCount(1, this.factory.getImplementationName());
assertBeanCount(4 + 1, DepTestImplModuleFactory.NAME);
assertStatus(status1, 1 + 4 + 1, 0, 0);
transaction = this.configRegistryClient.createTransaction();
final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(ObjectNameUtil.withoutTransactionName(on), NetconfTestImplModuleMXBean.class);
proxy.getComplexList();
final List<ObjectName> testingDeps = proxy.getTestingDeps();
final ObjectName testingDep = proxy.getTestingDep();
assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep));
assertTestingDeps(testingDeps, 4);
transaction.abortConfig();
// check that reuse logic works - equals on list of dependencies.
transaction = this.configRegistryClient.createTransaction();
final CommitStatus status2 = transaction.commit();
assertStatus(status2, 0, 0, 6);
// replace single dependency
transaction = this.configRegistryClient.createTransaction();
final String instanceName1 = TESTING_DEP_PREFIX + 1;
transaction.destroyModule(DepTestImplModuleFactory.NAME, instanceName1);
transaction.createModule(DepTestImplModuleFactory.NAME, instanceName1);
final CommitStatus status3 = transaction.commit();
assertStatus(status3, 1, 1, 4);
}
use of org.opendaylight.controller.config.util.ConfigTransactionJMXClient in project controller by opendaylight.
the class ShutdownTest method testSingleton_invalidName.
@Test
public void testSingleton_invalidName() throws Exception {
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
try {
transaction.createModule(NAME, "foo");
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Singleton enforcement failed. Expected instance name shutdown", e.getMessage());
}
}
Aggregations