c3c8d98530a6902fb896bbb0a22e31739dfb8d39
1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.remote
.core
.tests
.shell
;
15 import static org
.junit
.Assert
.assertEquals
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Arrays
;
19 import java
.util
.List
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
22 import org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
;
23 import org
.eclipse
.tracecompass
.internal
.tmf
.remote
.core
.shell
.CommandInput
;
24 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.shell
.ICommandInput
;
25 import org
.junit
.Test
;
28 * Test suite for the {@link CommandInput} class
30 public class CommandInputTest
{
32 private static final @NonNull String COMMAND
= "my-command";
33 private static final String
@NonNull [] CMD_INPUT
= { "This", "are", "the", "params" };
36 * Test suite for the {@link CommandInput#add(String)} and {@link CommandInput#addAll(List)}
39 public void testConstructorAndAdd() {
40 ICommandInput iunput
= new CommandInput();
42 List
<String
> params
= Arrays
.asList(CMD_INPUT
);
43 iunput
.addAll(NonNullUtils
.checkNotNull(params
));
45 List
<String
> expectedList
= new ArrayList
<>();
46 expectedList
.add(COMMAND
);
47 expectedList
.addAll(params
);
48 assertEquals(expectedList
, iunput
.getInput());
49 String expected
= expectedInputString();
50 assertEquals(expected
, iunput
.toString());
54 * Test suite to test null segment for {@link CommandInput#add(String)}
57 public void testNullSegment() {
58 ICommandInput input
= new CommandInput();
60 assertEquals(0, input
.getInput().size());
63 private static String
expectedInputString() {
64 StringBuilder builder
= new StringBuilder();
65 builder
.append(COMMAND
).append((' '));
66 for (String segment
: CMD_INPUT
) {
67 builder
.append(segment
).append(' ');
69 return builder
.toString().trim();
This page took 0.03702 seconds and 4 git commands to generate.