Remove old Hydrogen CLI 19/21719/1
authorLorand Jakab <lojakab@cisco.com>
Wed, 3 Jun 2015 06:22:00 +0000 (09:22 +0300)
committerLorand Jakab <lojakab@cisco.com>
Wed, 3 Jun 2015 07:08:41 +0000 (10:08 +0300)
Change-Id: I99c2abf7468f9c4aaf67ce03b42dde9cdd5fd686
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
commons/unittest_tools/src/main/java/org/opendaylight/lispflowmapping/tools/junit/MockCommandInterpreter.java [deleted file]
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/LispMappingServiceCliTest.java [deleted file]
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java

diff --git a/commons/unittest_tools/src/main/java/org/opendaylight/lispflowmapping/tools/junit/MockCommandInterpreter.java b/commons/unittest_tools/src/main/java/org/opendaylight/lispflowmapping/tools/junit/MockCommandInterpreter.java
deleted file mode 100644 (file)
index 4ebd9fb..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014 Contextream, 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.lispflowmapping.tools.junit;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.osgi.framework.Bundle;
-
-public class MockCommandInterpreter implements CommandInterpreter {
-    private StringBuilder prints = new StringBuilder();
-    private List<String> arguments = new ArrayList<String>();
-    private Iterator<String> argIterator;
-
-    public StringBuilder getPrints() {
-        return prints;
-    }
-
-    public void addArgument(String arg) {
-        arguments.add(arg);
-    }
-
-    public String nextArgument() {
-        if (argIterator == null) {
-            argIterator = arguments.iterator();
-        }
-
-        return argIterator.next();
-    }
-
-    public Object execute(String cmd) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public void print(Object o) {
-        prints.append(o);
-    }
-
-    public void println() {
-        prints.append("\n");
-    }
-
-    public void println(Object o) {
-        prints.append(o).append("\n");
-    }
-
-    public void printStackTrace(Throwable t) {
-        // TODO Auto-generated method stub
-
-    }
-
-    @SuppressWarnings("rawtypes")
-    public void printDictionary(Dictionary dic, String title) {
-        // TODO Auto-generated method stub
-
-    }
-
-    public void printBundleResource(Bundle bundle, String resource) {
-        // TODO Auto-generated method stub
-
-    }
-}
index 5ffe7acee697fdd36188766af50b698671c6137c..1e58e7a981a18e98e7ad151ffca4fbdb317b8da5 100644 (file)
@@ -12,8 +12,6 @@ import java.util.List;
 
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
@@ -24,7 +22,6 @@ import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
 import org.opendaylight.lispflowmapping.implementation.dao.HashMapDb;
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKey;
-import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKeyUtil;
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceNoMaskKey;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapResolver;
 import org.opendaylight.lispflowmapping.implementation.lisp.MapServer;
@@ -67,12 +64,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yangtools.yang.binding.Notification;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class LispMappingService implements CommandProvider, IFlowMapping, IFlowMappingShell, BindingAwareProvider,
+public class LispMappingService implements IFlowMapping, IFlowMappingShell, BindingAwareProvider,
         IMapRequestResultHandler, IMapNotifyHandler, AutoCloseable {
     protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
 
@@ -124,7 +119,6 @@ public class LispMappingService implements CommandProvider, IFlowMapping, IFlowM
         lfmDbRpc = rpcRegistry.addRpcImplementation(LfmMappingDatabaseService.class, mappingDbProviderRpc);
 
         setLispDao(new HashMapDb());
-        registerWithOSGIConsole();
     }
 
     @Override
@@ -172,15 +166,6 @@ public class LispMappingService implements CommandProvider, IFlowMapping, IFlowM
         lispDao = null;
     }
 
-    private void registerWithOSGIConsole() {
-        try {
-            BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-            bundleContext.registerService(CommandProvider.class.getName(), this, null);
-        } catch (Exception e) {
-            LOG.error(e.getStackTrace().toString());
-        }
-    }
-
     public void destroy() {
         LOG.info("LISP (RFC6830) Mapping Service is destroyed!");
         mapResolver = null;
@@ -188,15 +173,6 @@ public class LispMappingService implements CommandProvider, IFlowMapping, IFlowM
         closeDataListeners();
     }
 
-    public void _removeEid(final CommandInterpreter ci) {
-        LispAddressContainer eid = LispAFIConvertor.getIPContainer(ci.nextArgument());
-        lispDao.remove(MappingServiceKeyUtil.generateMappingServiceKey(eid));
-    }
-
-    public void _dumpAll(final CommandInterpreter ci) {
-        ci.print(printMappings());
-    }
-
     public String printMappings() {
         final StringBuffer sb = new StringBuffer();
         sb.append("EID\tRLOCs\n");
@@ -216,36 +192,12 @@ public class LispMappingService implements CommandProvider, IFlowMapping, IFlowM
         return sb.toString();
     }
 
-    public void _setShouldOverwriteRlocs(final CommandInterpreter ci) {
-        try {
-            boolean shouldOverwriteRloc = Boolean.parseBoolean(ci.nextArgument());
-            setOverwrite(shouldOverwriteRloc);
-        } catch (Exception e) {
-            ci.println("Bad Usage!!");
-        }
-
-    }
-
-    public void _addDefaultPassword(final CommandInterpreter ci) {
-        addDefaultKeyIPv4();
-    }
-
     public void addDefaultKeyIPv4() {
         LispAddressContainer address = LispAFIConvertor.toContainer(
                 new Ipv4AddressBuilder().setIpv4Address(new Ipv4Address("0.0.0.0")).build());
         addAuthenticationKey(address, 0, "password");
     }
 
-    public String getHelp() {
-        StringBuffer help = new StringBuffer();
-        help.append("---LISP Mapping Service---\n");
-        help.append("\t dumpAll                               - Dump all current EID -> RLOC mappings\n");
-        help.append("\t removeEid <EID>                       - Remove a single EID (/32 or /128)\n");
-        help.append("\t setShouldOverwriteRlocs <true|false>  - Set the map server's behavior regarding existing RLOCs\n");
-        help.append("\t addDefaultPassword                    - Add \"password\" as default password for IPv4 EIDs");
-        return help.toString();
-    }
-
     public MapReply handleMapRequest(MapRequest request) {
         return handleMapRequest(request, smr);
     }
diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/LispMappingServiceCliTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/LispMappingServiceCliTest.java
deleted file mode 100644 (file)
index 3002b75..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014 Contextream, 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.lispflowmapping.implementation;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import junitx.framework.StringAssert;
-
-import org.jmock.api.Invocation;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKeyUtil;
-import org.opendaylight.lispflowmapping.implementation.util.LispAFIConvertor;
-import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
-import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
-import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
-import org.opendaylight.lispflowmapping.tools.junit.MockCommandInterpreter;
-
-public class LispMappingServiceCliTest extends BaseTestCase {
-    private LispMappingService testedLispMappingService;
-    private ILispDAO dao;
-    private Map<Object, Object> visitorExecutions;
-    private MockCommandInterpreter mockCommandInterpreter;
-
-    @Override
-    @Before
-    public void before() throws Exception {
-        super.before();
-
-        testedLispMappingService = new LispMappingService();
-        dao = context.mock(ILispDAO.class);
-        inject(testedLispMappingService, "lispDao", dao);
-        mockCommandInterpreter = new MockCommandInterpreter();
-
-        visitorExecutions = new HashMap<Object, Object>();
-        allowing(dao).getAll(wany(IRowVisitor.class));
-        will(new SimpleAction() {
-            @Override
-            public Object invoke(Invocation invocation) throws Throwable {
-                IRowVisitor visitor = (IRowVisitor) invocation.getParameter(0);
-                for (Entry<Object, Object> entry : visitorExecutions.entrySet()) {
-                    visitor.visitRow(entry.getKey(), "IP", entry.getValue());
-                }
-                return null;
-            }
-        });
-    }
-
-    @Test
-    public void remove__Basic() throws Exception {
-        mockCommandInterpreter.addArgument("1.2.3.4");
-        oneOf(dao).remove(MappingServiceKeyUtil.generateMappingServiceKey(LispAFIConvertor.getIPContainer("1.2.3.4")));
-        testedLispMappingService._removeEid(mockCommandInterpreter);
-    }
-
-    @Test
-    public void oneEntryInDb() throws Exception {
-        prepareVisitorResult("1.2.3.4", "9.8.7.6");
-
-        testedLispMappingService._dumpAll(mockCommandInterpreter);
-
-        String console = mockCommandInterpreter.getPrints().toString();
-        StringAssert.assertStartsWith("EID\tRLOCs\n", console);
-        StringAssert.assertContains("Ipv4", console);
-    }
-
-    @Test
-    public void twoEntriesInDb() throws Exception {
-        prepareVisitorResult("7.2.3.4", "9.8.7.6");
-        prepareVisitorResult("1.2.3.4", "9.8.7.6");
-        testedLispMappingService._dumpAll(mockCommandInterpreter);
-
-        String console = mockCommandInterpreter.getPrints().toString();
-        StringAssert.assertStartsWith("EID\tRLOCs\n", console);
-        StringAssert.assertContains("Ipv4", console);
-        StringAssert.assertContains("Ipv4", console);
-    }
-
-    private void prepareVisitorResult(final String key, final String value) {
-        visitorExecutions.put(LispAFIConvertor.asIPAfiAddress(key), LispAFIConvertor.asIPAfiAddress(value));
-    }
-}
index add75441cb9dfe6d26cfe5f86a685a96ea86f159..4adde9f59465e08fd48ecf6de7ccdc148adc24ed 100644 (file)
@@ -17,7 +17,6 @@ import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 
-import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
@@ -30,14 +29,12 @@ import org.opendaylight.lispflowmapping.southbound.lisp.LispXtrSouthboundService
 import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.LfmControlPlaneService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.transportaddress.TransportAddress;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.net.InetAddresses;
 
-public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, CommandProvider, AutoCloseable, BindingAwareProvider {
+public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCloseable, BindingAwareProvider {
     protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundPlugin.class);
 
     private static Object startLock = new Object();
@@ -65,7 +62,6 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, Comman
         synchronized (startLock) {
             lispSouthboundService = new LispSouthboundService();
             lispXtrSouthboundService = new LispXtrSouthboundService();
-            registerWithOSGIConsole();
             lispSouthboundService.setNotificationProvider(this.notificationService);
             lispXtrSouthboundService.setNotificationProvider(this.notificationService);
             LOG.trace("Provider Session initialized");
@@ -88,12 +84,6 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, Comman
         this.broker = broker;
     }
 
-    private void registerWithOSGIConsole() {
-        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-        bundleContext.registerService(CommandProvider.class.getName(), this, null);
-        bundleContext.registerService(IConfigLispSouthboundPlugin.class.getName(), this, null);
-    }
-
     private void unloadActions() {
         if (lispThread != null) {
             lispThread.stopRunning();