X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2FConsoleIOTestImpl.java;fp=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2FConsoleIOTestImpl.java;h=0000000000000000000000000000000000000000;hb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;hp=368e942c972481dc5e051d46b1240e5af7554242;hpb=071a641d7c12c0e6112d5ce0afe806b54f116ed2;p=controller.git diff --git a/opendaylight/netconf/netconf-cli/src/test/java/org/opendaylight/controller/netconf/cli/ConsoleIOTestImpl.java b/opendaylight/netconf/netconf-cli/src/test/java/org/opendaylight/controller/netconf/cli/ConsoleIOTestImpl.java deleted file mode 100644 index 368e942c97..0000000000 --- a/opendaylight/netconf/netconf-cli/src/test/java/org/opendaylight/controller/netconf/cli/ConsoleIOTestImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.netconf.cli; - -import java.io.IOException; -import java.util.Deque; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.opendaylight.controller.netconf.cli.io.ConsoleIOImpl; - -public class ConsoleIOTestImpl extends ConsoleIOImpl { - - Map> inputValues = new HashMap<>(); - String lastMessage; - private final List valuesForMessages; - - public ConsoleIOTestImpl(final Map> inputValues, final List valuesForMessages) - throws IOException { - super(); - this.inputValues = inputValues; - this.valuesForMessages = valuesForMessages; - } - - StringBuilder output = new StringBuilder(); - - @Override - public String read() throws IOException { - final String prompt = buildPrompt(); - output.append(prompt); - System.console().writer().print(prompt); - - String value = inputValues.get(prompt).pollFirst(); - if (value == null) { - value = getValueForLastMessage(); - } - - value = value != null ? value : "****NO VALUE****"; - - output.append(value + "\n"); - System.console().writer().println(value + "\n"); - return value; - } - - private String getValueForLastMessage() { - for (final ValueForMessage valueForMessage : valuesForMessages) { - if (containsLastMessageKeyWords(valueForMessage.getKeyWords())) { - return valueForMessage.getValue(); - } - } - return null; - } - - private boolean containsLastMessageKeyWords(final List keyWords) { - for (final String keyWord : keyWords) { - if (!lastMessage.contains(keyWord)) { - return false; - } - } - return true; - } - - @Override - public void write(final CharSequence data) throws IOException { - output.append(data); - lastMessage = (String) data; - System.console().writer().print(data); - } - - @Override - public void writeLn(final CharSequence data) throws IOException { - write(data); - output.append("\n"); - System.console().writer().print("\n"); - } - - public String getConsoleOutput() { - return output.toString(); - } -}