X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-test%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Ftest%2Fimpl%2FNetconfTestImplModuleTest.java;h=13a31f59766c7e4ecb1936aa8ca64c3d7c8b85ee;hb=f3714846c0eedf09fe83844c0dc30889f790fbc2;hp=41ceab0e55dee4da29a004d73f92eaa53354af9e;hpb=54bed4dd6dfbada9a8e2ddf70ca84952aec3f55a;p=controller.git 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..13a31f5976 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,17 +1,32 @@ +/* + * 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 com.google.common.collect.Lists; + import junit.framework.Assert; + 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 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.yang.data.impl.codec.CodecRegistry; +import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec; import javax.management.InstanceAlreadyExistsException; import javax.management.ObjectName; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -20,6 +35,8 @@ 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 static org.mockito.Mockito.mock; public class NetconfTestImplModuleTest extends AbstractConfigTest { @@ -31,8 +48,32 @@ 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 CodecRegistry getCodecRegistry() { + final IdentityCodec codec = mock(IdentityCodec.class); + doReturn(TestIdentity1.class).when(codec).deserialize(TestIdentity1.QNAME); + doReturn(TestIdentity2.class).when(codec).deserialize(TestIdentity2.QNAME); + + final CodecRegistry ret = super.getCodecRegistry(); + doReturn(codec).when(ret).getIdentityCodec(); + 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