X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-test%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Ftest%2Fimpl%2FNetconfTestImplModuleTest.java;h=680fe5048a8a23568a91df18571f7b84bada52cd;hp=41ceab0e55dee4da29a004d73f92eaa53354af9e;hb=e631dc96f0461b2270377dc072b9f969a875667a;hpb=0ae12c54560ef14cb8c08beef4553f7523d41578 diff --git a/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java b/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java index 41ceab0e55..680fe5048a 100644 --- a/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java +++ b/opendaylight/config/yang-test/src/test/java/org/opendaylight/controller/config/yang/test/impl/NetconfTestImplModuleTest.java @@ -1,25 +1,35 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.config.yang.test.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doReturn; + import com.google.common.collect.Lists; -import junit.framework.Assert; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.management.InstanceAlreadyExistsException; +import javax.management.ObjectName; import org.junit.Before; import org.junit.Test; +import org.opendaylight.controller.config.api.IdentityAttributeRef; import org.opendaylight.controller.config.api.jmx.CommitStatus; import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; import org.opendaylight.controller.config.manager.impl.AbstractConfigTest; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.ObjectName; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2; +import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext; public class NetconfTestImplModuleTest extends AbstractConfigTest { @@ -31,8 +41,29 @@ public class NetconfTestImplModuleTest extends AbstractConfigTest { public void setUp() { factory = new NetconfTestImplModuleFactory(); - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory, - new DepTestImplModuleFactory())); + super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory, + new DepTestImplModuleFactory(), new IdentityTestModuleFactory())); + } + + @Override + protected BindingRuntimeContext getBindingRuntimeContext() { + final BindingRuntimeContext ret = super.getBindingRuntimeContext(); + doReturn(TestIdentity1.class).when(ret).getIdentityClass(TestIdentity1.QNAME); + doReturn(TestIdentity2.class).when(ret).getIdentityClass(TestIdentity2.QNAME); + return ret; + } + + @Test + public void testIdentities() throws Exception { + ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); + + ObjectName nameCreated = transaction.createModule(IdentityTestModuleFactory.NAME, instanceName); + IdentityTestModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, IdentityTestModuleMXBean.class); + + final IdentitiesContainer c = new IdentitiesContainer(); + c.setAfi(new IdentityAttributeRef(TestIdentity2.QNAME.toString())); + mxBean.setIdentitiesContainer(c); + transaction.commit(); } @Test @@ -55,7 +86,7 @@ public class NetconfTestImplModuleTest extends AbstractConfigTest { List testingDeps = proxy.getTestingDeps(); ObjectName testingDep = proxy.getTestingDep(); - Assert.assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep)); + assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep)); assertTestingDeps(testingDeps, 4); transaction.abortConfig(); @@ -94,11 +125,11 @@ public class NetconfTestImplModuleTest extends AbstractConfigTest { } private void assertTestingDeps(List testingDeps, int i) { - Assert.assertEquals(i, testingDeps.size()); + assertEquals(i, testingDeps.size()); int c = 1; for (ObjectName testingDep : testingDeps) { - Assert.assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep)); + assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep)); } }