+++ /dev/null
-/*
- * Copyright (c) 2014, 2017 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.manager.impl.osgi;
-
-import static org.mockito.Matchers.any;
-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 java.util.Dictionary;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider;
-import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
-import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry;
-import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class RefreshingSCPModuleInfoRegistryTest {
-
- @Mock
- SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testConstructor() throws Exception {
- final ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
- final SchemaContextProvider prov = mock(SchemaContextProvider.class);
- doReturn("string").when(prov).toString();
- final BundleContext ctxt = mock(BundleContext.class);
- final ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
- doReturn(servReg).when(ctxt).registerService(any(Class.class), any(SchemaContextProvider.class),
- any(Dictionary.class));
- doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), any(Object.class), any(Dictionary.class));
- doNothing().when(servReg).setProperties(any(Dictionary.class));
-
- final ClassLoadingStrategy classLoadingStrat = mock(ClassLoadingStrategy.class);
- final BindingContextProvider codecRegistryProvider = mock(BindingContextProvider.class);
- doNothing().when(codecRegistryProvider).update(classLoadingStrat, prov);
- final BindingRuntimeContext bindingRuntimeContext = mock(BindingRuntimeContext.class);
- doReturn("B-runtime-context").when(bindingRuntimeContext).toString();
- doReturn(bindingRuntimeContext).when(codecRegistryProvider).getBindingContext();
-
- final RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, classLoadingStrat,
- this.sourceProvider, codecRegistryProvider, ctxt);
-
- doNothing().when(servReg).unregister();
-
- final YangModuleInfo modInfo = mock(YangModuleInfo.class);
- doReturn("").when(modInfo).toString();
- final ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
- doReturn(ymi).when(reg).registerModuleInfo(modInfo);
-
- scpreg.registerModuleInfo(modInfo);
- scpreg.updateService();
-
- verify(codecRegistryProvider).update(classLoadingStrat, prov);
-
- scpreg.close();
-
- Mockito.verify(servReg, Mockito.times(1)).setProperties(any(Dictionary.class));
- Mockito.verify(servReg, Mockito.times(1)).unregister();
- }
-}
<module>config-manager-facade-xml</module>
<module>yang-jmx-generator</module>
<module>yang-jmx-generator-plugin</module>
- <module>yang-test</module>
<module>threadpool-config-api</module>
<module>netty-config-api</module>
<module>threadpool-config-impl</module>
+++ /dev/null
-Test code generator, namely generating abstract classes to target/generated-sources/config folder.
-Currently files generated to src are modified - getInstance() method must be implemented, so the body is replaced
-manually with following snippet:
- return new AutoCloseable() {
- @Override
- public void close() throws Exception {
- }
- };
-TODO: clean src/main/java directory and replace generated body during build.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-plugin-parent</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <relativePath>../config-plugin-parent</relativePath>
- </parent>
-
- <artifactId>yang-test</artifactId>
- <packaging>bundle</packaging>
- <name>${project.artifactId}</name>
- <description>Artifact that contains only generated code from yang files. Suitable for testing.</description>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-manager</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>config-manager</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-util</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-test-plugin</artifactId>
- <versionRange>[0.2.3,)</versionRange>
- <goals>
- <goal>delete-sources</goal>
- <goal>process-sources</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>check-license</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <excludes>
- org/opendaylight/yang/gen/**,
- **/config/yang/test/**
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-test-plugin</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>delete-sources</goal>
- <goal>process-sources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-*.java
-!CheckedAutoCloseable.java
+++ /dev/null
-
-
-
-package org.opendaylight.controller.config.yang.test.impl;
-
-import com.google.common.base.Preconditions;
-
-public class CheckedAutoCloseable implements AutoCloseable {
- private boolean closed = false;
-
- @Override
- public synchronized void close() throws Exception {
- Preconditions.checkState(closed == false);
- this.closed = true;
- }
-
- public synchronized boolean isClosed() {
- return this.closed;
- }
-}
+++ /dev/null
- return new org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable();
+++ /dev/null
- org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass());
- logger.info("Afi: {}", getAfi());
- logger.info("Afi class: {}", getAfiIdentity());
-
- for (Identities identities : getIdentities()) {
- logger.info("Identities Afi class: {}", identities.resolveAfi());
- logger.info("Identities Safi class: {}", identities.resolveSafi());
-
- }
- logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi());
-
- return new org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable();
+++ /dev/null
- return new org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable() {
- @Override
- public synchronized void close() throws Exception {
- if(getSingleDependency() != null && getSingleDependency().isClosed() == true) {
- // Simulate a cleanup on dependencies that should not be closed yet
- throw new java.lang.Error("Dependency was closed first");
- }
- for (org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable autoCloseable : getTestingDepsDependency()) {
- if(autoCloseable.isClosed() == true) {
- // Simulate a cleanup on dependencies that should not be closed yet
- throw new java.lang.Error("Dependency was closed first");
- }
- }
- super.close();
- }
- };
\ No newline at end of file
+++ /dev/null
- final AutoCloseable runtime = org.opendaylight.controller.config.yang.test.util.NetconfTestImplModuleUtil.registerRuntimeBeans(this);
- return new org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable() {
- @Override
- public synchronized void close() throws Exception {
- runtime.close();
- }
- };
\ No newline at end of file
+++ /dev/null
- return new org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable();
\ No newline at end of file
+++ /dev/null
-/*
- * 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.util;
-
-import com.google.common.collect.Lists;
-import java.math.BigInteger;
-import java.util.List;
-import org.opendaylight.controller.config.yang.test.impl.Asdf;
-import org.opendaylight.controller.config.yang.test.impl.Deep2;
-import org.opendaylight.controller.config.yang.test.impl.Deep3;
-import org.opendaylight.controller.config.yang.test.impl.Deep4;
-import org.opendaylight.controller.config.yang.test.impl.InnerInnerRunningDataRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataAdditionalRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeRegistration;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModule;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeMXBean;
-import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistration;
-import org.opendaylight.controller.config.yang.test.impl.NotStateBean;
-import org.opendaylight.controller.config.yang.test.impl.RetValContainer;
-import org.opendaylight.controller.config.yang.test.impl.RetValList;
-
-public class NetconfTestImplModuleUtil {
- public static NetconfTestImplRuntimeRegistration registerRuntimeBeans(final NetconfTestImplModule module) {
- NetconfTestImplRuntimeRegistration reg = module.getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
-
- @Override
- public Long getCreatedSessions() {
- return module.getSimpleLong();
- }
-
- @Override
- public Asdf getAsdf() {
- final Asdf asdf = new Asdf();
- asdf.setSimpleString("asdf");
- return asdf;
- }
-
- @Override
- public BigInteger getCommonStat() {
- return new BigInteger("54");
- }
-
- @Override
- public String noArg(final String arg1) {
- return arg1.toUpperCase();
- }
-
- @Override
- public Long commonRpcTwo() {
- return 1L;
- }
-
- @Override
- public String commonRpcThree() {
- return "true";
- }
-
- @Override
- public Boolean commonRpc() {
- return true;
- }
-
- @Override
- public void netconfImplRpcFromGrouping() {
- // rpc from grouping within same yang module
- }
-
- });
-
- for (int i = 0; i < module.getSimpleShort(); i++) {
- final int finalI = i;
-
- reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return module.getSimpleTest();
- }
-
- @Override
- public Deep4 getDeep4() {
- final Deep4 d = new Deep4();
- d.setBoool(false);
- return d;
- }
-
- @Override
- public String getSimpleString() {
- return Integer.toString(finalI);
- }
-
- @Override
- public void noArgInner() {
- }
- });
-
- InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return finalI;
- }
-
- @Override
- public Deep2 getDeep2() {
- return new Deep2();
- }
- });
-
- for (int j = 0; j < module.getSimpleShort(); j++) {
- final int finalJ = j;
- innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
- @Override
- public List<NotStateBean> getNotStateBean() {
- NotStateBean b1 = new NotStateBean();
- b1.setElement("not state");
- return Lists.newArrayList(b1);
- }
-
- @Override
- public Integer getSimpleInt3() {
- return finalJ;
- }
-
- @Override
- public Deep3 getDeep3() {
- return new Deep3();
- }
-
- @Override
- public List<String> getListOfStrings() {
- return Lists.newArrayList("l1", "l2");
- }
-
- @Override
- public List<RetValList> listOutput() {
- return Lists.newArrayList(new RetValList());
- }
-
- @Override
- public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
- return aBoolean;
- }
-
- @Override
- public RetValContainer containerOutput() {
- return new RetValContainer();
- }
-
- @Override
- public List<String> leafListOutput() {
- return Lists.newArrayList("1", "2");
- }
- });
- }
- }
-
- return reg;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127;
-
-
-/**
-**/
-public class UnionTestBuilder {
-
- public static UnionTest getDefaultInstance(String defaultValue) {
- try {
- int i = Integer.valueOf(defaultValue);
- return new UnionTest(new ExtendTwice(i));
- } catch (NumberFormatException e) {
- return new UnionTest(defaultValue);
- }
- }
-
-}
+++ /dev/null
-module config-test-impl {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:test:impl";
- prefix "it-impl";
-
- import config-test { prefix test; revision-date 2013-06-13;}
- import config { prefix config; revision-date 2013-04-05; }
- import ietf-inet-types { prefix inet; revision-date 2013-07-15;}
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
- import test-types { prefix tt; revision-date 2013-11-27; }
- import test-groups { prefix tg; revision-date 2014-12-08; }
-
- description
- "Testing IMPL";
-
- revision "2013-04-03" {
- description
- "Initial revision";
- }
-
- identity impl {
- base config:module-type;
- config:provided-service test:testing;
- config:java-name-prefix TestImpl;
- }
-
- identity impl-dep {
- base config:module-type;
- config:provided-service test:testing;
- config:java-name-prefix DepTestImpl;
- }
-
- identity impl-netconf {
- base config:module-type;
- config:provided-service test:testing;
- config:java-name-prefix NetconfTestImpl;
- }
-
- identity impl-identity-test {
- base config:module-type;
- config:provided-service test:testing;
- config:java-name-prefix IdentityTest;
- }
-
- identity multiple-dependencies {
- base config:module-type;
- config:provided-service test:testing;
- config:java-name-prefix MultipleDependencies;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case impl-identity-test {
- when "/config:modules/config:module/config:type = 'impl-identity-test'";
-
- leaf afi {
- type identityref {
- base tt:test-identity1;
- }
- }
-
- container identities-container {
- leaf afi {
- type identityref {
- base tt:test-identity1;
- }
- }
- }
-
- list identities {
- leaf afi {
- type identityref {
- base tt:test-identity1;
- }
- }
- leaf safi {
- type identityref {
- base tt:test-identity1;
- }
- }
-
- container identities-inner {
- leaf afi {
- type identityref {
- base tt:test-identity1;
- }
- }
- }
- }
-
- }
- }
-
- augment "/config:modules/config:module/config:state" {
- case impl-identity-test {
- when "/config:modules/config:module/config:type = 'impl-identity-test'";
-
- }
- }
-
-
- augment "/config:modules/config:module/config:configuration" {
- case impl {
- when "/config:modules/config:module/config:type = 'impl'";
-
- leaf-list allow-user {
- type string;
- description "A list of user name patterns to allow";
- }
-
- container dto-a {
- leaf simple-arg {
- type uint32;
- default 1;
- }
-
- leaf port {
- type inet:port-number;
- default 8080;
- }
-
- leaf ip4 {
- type inet:ipv4-address;
- default 127.0.0.1;
- }
-
- }
-
- leaf as-number {
- type inet:as-number;
- default 44;
- }
-
-
- leaf simpleInt {
- type uint32;
- default 99;
- }
-
- container dto_b {
- leaf simple-int1 {
- type uint32;
- default 32;
- }
-
- leaf simple-int2 {
- type uint32;
- }
- }
-
- }
- }
-
- augment "/config:modules/config:module/config:state" {
- case impl {
- when "/config:modules/config:module/config:type = 'impl'";
- // root runtime bean
- leaf created-sessions {
- type uint32;
- }
- }
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case impl-dep {
- when "/config:modules/config:module/config:type = 'impl-dep'";
- }
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case impl-netconf {
- when "/config:modules/config:module/config:type = 'impl-netconf'";
-
- container impl-netconf {
-
- uses tg:config-grouping;
-
- leaf binaryLeaf {
- type binary;
- default ZGVmYXVsdEJpbg==;
- }
-
- leaf type {
- type string;
- default "default-string";
- }
-
- leaf extended {
- type tt:extend-once;
- default 1;
- }
-
- leaf extended-twice {
- type tt:extend-twice;
- default 2;
- }
-
- leaf extended-enum {
- type tt:extend-enum;
- default one;
- }
-
- leaf ip {
- type inet:ip-address;
- default 0:0:0:0:0:0:0:1;
- }
-
- leaf union-test-attr {
- type tt:unionTest;
- default 456;
- }
-
- leaf sleep-factor {
- type decimal64 {
- fraction-digits 2;
- }
- default 2.00;
- }
-
- container dto-c {
- leaf simple-arg {
- type uint32;
- }
-
- container dto-a-inner {
- leaf simple-arg {
- type uint32;
- }
-
- container dto-a-inner-inner {
- leaf simple-arg {
- type uint32;
- }
- }
- }
- }
-
- leaf simpleInt {
- type uint32;
- }
-
- leaf simpleBoolean {
- type boolean;
- default false;
- }
-
- leaf simple-long {
- type int64;
- default -45;
- }
-
- leaf simple-long-2 {
- type uint32;
- default 445;
- }
-
- leaf simple-BigInteger {
- type uint64;
- default 545454;
- }
-
- leaf simple-byte {
- type int8;
- default -4;
- }
-
- leaf simple-short {
- type uint8;
- default 45;
- }
-
- leaf simple-test {
- type uint16;
- default 99;
- }
-
- leaf-list simple-list {
- type uint16;
- }
-
- container dto_d {
- leaf simple-int1 {
- type uint32;
- }
-
- leaf simple-int2 {
- type uint32;
- }
-
- leaf simple-int3 {
- type uint16;
- }
-
- leaf-list simple-list {
- type uint16;
- }
-
- list complex-dto-bInner {
- leaf-list simple-list {
- type uint16;
- }
- leaf simple-int3 {
- type uint16;
- }
-
- container deep {
- leaf simple-int3 {
- type uint16;
- default 0;
- }
- }
- }
- }
-
- list complex-list {
- list simple-list {
- leaf simple-int3 {
- type uint16;
- }
- }
- }
-
- list peers {
- leaf port {
- type string;
- }
- leaf core-size {
- type uint32;
- }
- leaf simple-int3 {
- type uint16;
- }
- }
-
- container testing-dep {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity test:testing;
- }
- }
- }
-
- list testing-deps {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity test:testing;
- }
- }
- }
- }
- }
- }
-
- grouping netconf-impl-rpc {
- rpcx:rpc-context-instance netconf-impl-rpc-ctx;
- }
-
- identity netconf-impl-rpc-ctx;
-
- rpc netconf-impl-rpc-from-grouping {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance "netconf-impl-rpc-ctx";
- }
- }
- }
- }
-
- augment "/config:modules/config:module/config:state" {
- case impl-netconf {
- when "/config:modules/config:module/config:type = 'impl-netconf'";
- container impl-netconf {
- // rpc
- rpcx:rpc-context-instance "test-rpc";
-
- // add some stats + rpc from groupings outside this module
- uses tt:common-operational;
- uses tg:common-operational-rpc;
- uses netconf-impl-rpc;
-
- // root runtime bean
- leaf created-sessions {
- type uint32;
- }
-
- container asdf {
- leaf simpleInt {
- type uint16;
- }
-
- leaf simpleString {
- type string;
- }
- }
-
-
- list inner-running-data-additional {
- config:inner-state-bean;
-
- // rpc
- rpcx:rpc-context-instance "inner-test-rpc";
-
- key "simpleString";
-
- leaf simple-int3 {
- type uint16;
- }
-
- leaf simpleString {
- type string;
- }
-
- container deep4 {
- leaf boool {
- type boolean;
- }
- }
- }
-
- list inner-running-data {
- config:inner-state-bean;
-
- key "simple-int3";
-
- leaf simple-int3 {
- type uint16;
- }
-
- container deep2 {
- leaf boool {
- type boolean;
- }
- }
-
- list inner-inner-running-data {
- config:inner-state-bean;
-
- rpcx:rpc-context-instance "inner-inner-test-rpc";
- rpcx:rpc-context-instance "complex-output-rpc";
-
- key "simple-int3";
-
- leaf simple-int3 {
- type uint16;
- }
-
- leaf-list list-of-strings {
- type string;
- }
-
- list not-state-bean {
- leaf element {
- type string;
- }
-
- list not-state-bean-internal {
- // This should be ignored
- config:inner-state-bean;
-
- leaf element2 {
- type string;
- }
- }
- }
-
- container deep3 {
- leaf boool {
- type boolean;
- }
- }
- }
- }
-
- }
-
- }
- }
-
-
- augment "/config:modules/config:module/config:configuration" {
- case multiple-dependencies {
- when "/config:modules/config:module/config:type = 'multiple-dependencies'";
- container multiple-dependencies {
- list testing-deps {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity test:testing;
- }
- }
- }
- container single {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity test:testing;
- }
- }
- }
-
- leaf simple {
- type boolean;
- default false;
- }
- }
- }
- }
-
-
- identity test-rpc;
- identity inner-test-rpc;
- identity inner-inner-test-rpc;
-
- identity complex-output-rpc;
-
- rpc no-arg {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance test-rpc;
- }
- }
- leaf arg1 {
- type string;
- }
- }
-
- output {
- leaf result {
- type string;
- }
- }
- }
-
- rpc container-output {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance complex-output-rpc;
- }
- }
- }
-
- output {
- container retValContainer {
- leaf v1 {
- type string;
- default "from rpc";
- }
-
- leaf v2 {
- type uint32;
- }
- }
- }
- }
-
- rpc leaf-list-output {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance complex-output-rpc;
- }
- }
- }
-
- output {
- leaf-list result {
- type string;
- }
- }
- }
-
- rpc list-output {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance complex-output-rpc;
- }
- }
- }
-
- output {
- list ret-val-list {
- leaf v2 {
- type uint32;
- }
-
- leaf v1 {
- type boolean;
- }
- }
- }
- }
-
- rpc noArgInner {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance inner-test-rpc;
- }
- }
- }
- }
-
- rpc noArgInnerInner {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance inner-inner-test-rpc;
- }
- }
-
- leaf arg1 {
- type uint16;
- }
-
- leaf arg2 {
- type boolean;
- }
- }
- output {
- leaf result {
- type boolean;
- }
- }
- }
-}
+++ /dev/null
-module config-test {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:test";
- prefix "test";
-
- import config { prefix config; revision-date 2013-04-05; }
-
- description
- "Testing API";
-
- revision "2013-06-13" {
- description
- "Initial revision";
- }
-
- identity testing {
- description
- "Test api";
-
- base "config:service-type";
- config:java-class "org.opendaylight.controller.config.yang.test.impl.CheckedAutoCloseable";
- }
-}
+++ /dev/null
-module test-groups {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:config:test:groups";
- prefix "tg";
-
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
- description
- "Groupings generated for testing";
-
- revision "2014-12-08";
-
- grouping common-operational-rpc {
- rpcx:rpc-context-instance common-rpc-ctx;
- rpcx:rpc-context-instance common-rpc-ctx-two;
- }
-
- typedef version {
- type enumeration {
- enum version1 {
- value 1;
- }
- enum version2 {
- value 2;
- }
- enum version3 {
- value 3;
- }
- enum version4 {
- value 4;
- }
- }
- }
-
- grouping config-grouping {
-
- container from-grouping {
- leaf enum-in-grouping {
- type version;
- }
- }
- }
-
-
- identity common-rpc-ctx;
- identity common-rpc-ctx-two;
-
- rpc common-rpc {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance "common-rpc-ctx";
- }
- }
- }
-
- output {
- leaf output {
- type boolean;
- }
- }
- }
-
- rpc common-rpc-two {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance "common-rpc-ctx-two";
- }
- }
- }
-
- output {
- leaf output {
- type uint32;
- }
- }
- }
-}
+++ /dev/null
-module test-types {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:controller:config:test:types";
- prefix "tt";
-
- import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
- description
- "Types generated for testing";
-
- revision "2013-11-27";
-
- typedef extend-once {
- type uint16;
- }
-
- typedef extend-twice {
- type extend-once;
- }
-
- typedef extend-enum {
- type enumeration {
- enum "one";
- enum "two";
- }
- }
-
- typedef unionTest {
- type union {
- type string;
- type uint32;
- type extend-twice;
- }
- }
-
-
-
- identity test-identity1 {
-
- }
-
- identity test-identity2 {
- base test-identity1;
- }
-
- grouping common-operational {
- leaf common-stat {
- type uint64;
- }
- // This would not work, since it clashes with identity common-rpc-ctx from test-groups
- // Both grouping add the same unknown node "rpcx:rpc-context-instance common-rpc-ctx-three;"
- // and we cannot match the unknown node to the grouping that added it
- //rpcx:rpc-context-instance common-rpc-ctx-three;
- rpcx:rpc-context-instance common-rpc-ctx-three;
- }
-
- //identity common-rpc-ctx;
- identity common-rpc-ctx-three;
-
- rpc common-rpc-three {
- input {
- uses rpcx:rpc-context-ref {
- refine context-instance {
- rpcx:rpc-context-instance "common-rpc-ctx-three";
- }
- }
- }
-
- output {
- leaf output {
- type string;
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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 java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.getInstanceName;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.getTransactionName;
-
-import java.util.List;
-import javax.management.ObjectName;
-import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-
-public class MultipleDependenciesModuleTest extends AbstractConfigTest {
- private static final MultipleDependenciesModuleFactory factory = new MultipleDependenciesModuleFactory();
-
- @Before
- public void setUp() throws Exception {
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory));
- }
-
- @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();
- }
-
- @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();
- }
-
- @Test
- public void testDestroyModuleDependency() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
- ObjectName r1 = transaction.createModule(factory.getImplementationName(), "root1");
- ObjectName m1 = transaction.createModule(factory.getImplementationName(), "middle1");
-
- MultipleDependenciesModuleMXBean r1Proxy = transaction.newMXBeanProxy(r1, MultipleDependenciesModuleMXBean.class);
- r1Proxy.setSingle(m1);
- transaction.commit();
-
- transaction = configRegistryClient.createTransaction();
- transaction.destroyModule(factory.getImplementationName(), "middle1");
- try {
- transaction.commit();
- fail("Validation exception expected");
- } catch (ValidationException e) {
- assertThat(e.getFailedValidations().keySet(), CoreMatchers.hasItem("multiple-dependencies"));
- }
- }
-}
+++ /dev/null
-/*
- * 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.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import com.google.common.collect.Lists;
-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 org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
-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;
-
-public class NetconfTestImplModuleTest extends AbstractConfigTest {
-
- public static final String TESTING_DEP_PREFIX = "testing-dep";
- private NetconfTestImplModuleFactory factory;
- private final String instanceName = "n1";
-
- @Before
- public void setUp() {
-
- this.factory = new NetconfTestImplModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext,this.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 {
- 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();
- }
-
- @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);
-
- }
-
- @Test
- public void testNullCheckInListOfDependencies() throws Exception {
- final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-
- final ObjectName on = createInstance(transaction, this.instanceName, 4);
- final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
- proxy.setTestingDeps(null);
- assertTrue(proxy.getTestingDeps().isEmpty());
- proxy.setTestingDeps(Collections.<ObjectName>emptyList());
- }
-
- private void assertTestingDeps(final List<ObjectName> testingDeps, final int i) {
- assertEquals(i, testingDeps.size());
-
- int c = 1;
- for (final ObjectName testingDep : testingDeps) {
- assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep));
- }
- }
-
-
- private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String instanceName, final int depsCount)
- throws InstanceAlreadyExistsException {
- final ObjectName nameCreated = transaction.createModule(this.factory.getImplementationName(), instanceName);
- final NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NetconfTestImplModuleMXBean.class);
-
- ObjectName dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX);
- mxBean.setTestingDep(dep);
-
- final ArrayList<ObjectName> testingDeps = Lists.newArrayList();
- for (int i = 0; i < depsCount; i++) {
- dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX + Integer.toString(i + 1));
- testingDeps.add(dep);
- }
- mxBean.setTestingDeps(testingDeps);
-
- return nameCreated;
- }
-
-}