X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Futil%2FTestingConfigTransactionController.java;h=b1826e028af5e70c6eec5bb56a80b76c9bc7b77e;hp=1c522f17b03803cf758829d5fd9a37472732b25d;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=5e0aafd8aa4830a4d4df0f4768e6c85245875958 diff --git a/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/TestingConfigTransactionController.java b/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/TestingConfigTransactionController.java index 1c522f17b0..b1826e028a 100644 --- a/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/TestingConfigTransactionController.java +++ b/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/TestingConfigTransactionController.java @@ -7,23 +7,26 @@ */ package org.opendaylight.controller.config.util; +import com.google.common.collect.Sets; +import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; - import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.ObjectName; - import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean; import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; -import com.google.common.collect.Sets; - public class TestingConfigTransactionController implements ConfigTransactionControllerMXBean { public final ObjectName conf1, conf2, conf3; + public ObjectName conf4; + public String check; + Map mapSub; + Map> map; public static final String moduleName1 = "moduleA"; public static final String moduleName2 = "moduleB"; @@ -42,17 +45,33 @@ public class TestingConfigTransactionController implements + ":type=Module," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + moduleName2 + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + instName2); + conf4 = ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + + ":type=Module," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + + "=" + moduleName2 + "," + ObjectNameUtil.INSTANCE_NAME_KEY + + "=" + instName2); + mapSub = new HashMap<>(); + map = new HashMap<>(); } @Override - public ObjectName createModule(String moduleName, String instanceName) + public ObjectName createModule(final String moduleName, final String instanceName) throws InstanceAlreadyExistsException { - return null; + //return null; + return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + + ":type=Module," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + + "=" + moduleName); + } + + @Override + public void reCreateModule(final ObjectName objectName) { } @Override - public void destroyModule(ObjectName objectName) + public void destroyModule(final ObjectName objectName) throws InstanceNotFoundException { + if(objectName != null){ + conf4 = null; + } } @Override @@ -65,7 +84,8 @@ public class TestingConfigTransactionController implements @Override public String getTransactionName() { - return null; + //return null; + return "transactionName"; } @Override @@ -79,7 +99,7 @@ public class TestingConfigTransactionController implements } @Override - public Set lookupConfigBeans(String moduleName) { + public Set lookupConfigBeans(final String moduleName) { if (moduleName.equals(moduleName1)) { return Sets.newHashSet(conf1, conf2); } else if (moduleName.equals(moduleName2)) { @@ -90,7 +110,7 @@ public class TestingConfigTransactionController implements } @Override - public ObjectName lookupConfigBean(String moduleName, String instanceName) + public ObjectName lookupConfigBean(final String moduleName, final String instanceName) throws InstanceNotFoundException { if (moduleName.equals(InstanceNotFoundException.class.getSimpleName())) { throw new InstanceNotFoundException(); @@ -99,8 +119,8 @@ public class TestingConfigTransactionController implements } @Override - public Set lookupConfigBeans(String moduleName, - String instanceName) { + public Set lookupConfigBeans(final String moduleName, + final String instanceName) { if (moduleName.equals(moduleName1) && instanceName.equals(instName1)) { return Sets.newHashSet(conf2); } else if (moduleName.equals(moduleName2) @@ -112,52 +132,80 @@ public class TestingConfigTransactionController implements } @Override - public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException { - throw new UnsupportedOperationException(); + public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException { + check = "configBeanExists"; } @Override - public void saveServiceReference(String serviceInterfaceName, String refName, ObjectName objectName) throws InstanceNotFoundException { - throw new UnsupportedOperationException(); + public ObjectName saveServiceReference(final String serviceInterfaceName, final String refName, final ObjectName moduleON) throws InstanceNotFoundException { + return moduleON; } @Override - public boolean removeServiceReference(String serviceInterfaceName, String refName) { - throw new UnsupportedOperationException(); + public void removeServiceReference(final String serviceInterfaceName, final String refName) { + check = refName; } @Override public void removeAllServiceReferences() { - throw new UnsupportedOperationException(); + check = null; } @Override - public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceName, String refName) { - throw new UnsupportedOperationException(); + public ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) { + return conf3; } @Override public Map> getServiceMapping() { - throw new UnsupportedOperationException(); + mapSub.put("A",conf2); + map.put("AA", mapSub); + return map; } @Override - public Map lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceName) { - throw new UnsupportedOperationException(); + public Map lookupServiceReferencesByServiceInterfaceName(final String serviceInterfaceQName) { + mapSub.put("A",conf2); + return mapSub; } @Override - public Set lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException { - throw new UnsupportedOperationException(); + public Set lookupServiceInterfaceNames(final ObjectName objectName) throws InstanceNotFoundException { + return Sets.newHashSet("setA"); } @Override - public String getServiceInterfaceName(String namespace, String localName) { - throw new UnsupportedOperationException(); + public String getServiceInterfaceName(final String namespace, final String localName) { + return check=namespace+localName; + } + + @Override + public boolean removeServiceReferences(final ObjectName objectName) throws InstanceNotFoundException { + return true; + } + + @Override + public Set getAvailableModuleFactoryQNames() { + return Sets.newHashSet("availableModuleFactoryQNames"); + } + + @Override + public Set lookupRuntimeBeans() { + return Collections.emptySet(); + } + + @Override + public Set lookupRuntimeBeans(final String moduleName, final String instanceName) { + return Collections.emptySet(); + } + + @Override + public ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException { + return conf3; } @Override - public boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException { - throw new UnsupportedOperationException(); + public void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException { + check = "referenceExist"; } }