Update thread namings.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
d32ea6b4b0
commit
0ebcd7b210
@ -64,7 +64,7 @@ public final class PipedConsoleInput
|
||||
private final WritingRunnable writing;
|
||||
|
||||
/** Create a manager that will write and read through piped stream.
|
||||
*
|
||||
*
|
||||
* @param outPrint the stream to write the prompting messages to
|
||||
* @throws IOException if the piping failed for streams */
|
||||
public PipedConsoleInput(final PrintStream outPrint) throws IOException {
|
||||
@ -73,7 +73,8 @@ public final class PipedConsoleInput
|
||||
innerManager = new StreamConsoleInput(outPrint, in,
|
||||
StandardCharsets.UTF_8);
|
||||
writing = new WritingRunnable(commandInput, StandardCharsets.UTF_8);
|
||||
final Thread th = new Thread(writing, "write"); //$NON-NLS-1$
|
||||
final Thread th = new Thread(writing,
|
||||
"GCLC console piped input stream"); //$NON-NLS-1$
|
||||
th.start();
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public final class PipedConsoleOutput
|
||||
outPrint = new PrintStream(out, true, UTF_8);
|
||||
innerManager = new StreamConsoleOutput(outPrint);
|
||||
reading = new ReadingRunnable(commandBuffOutput);
|
||||
final Thread th = new Thread(reading, "read"); //$NON-NLS-1$
|
||||
final Thread th = new Thread(reading, "GCLC console output forward"); //$NON-NLS-1$
|
||||
th.setDaemon(true);
|
||||
th.start();
|
||||
}
|
||||
|
@ -430,6 +430,52 @@ public class ParametrizedCommandTest {
|
||||
// ok
|
||||
}
|
||||
// TODO Test of interactive not providing and providing all needed
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecuteInteractive() throws IOException,
|
||||
CommandRunException,
|
||||
InterruptedException {
|
||||
ParametrizedCommand cmd;
|
||||
final String addParam = "additional";
|
||||
final String str1 = "str1";
|
||||
final String str2 = "str2";
|
||||
final String bool1 = "bool1";
|
||||
final String bool2 = "bool2";
|
||||
|
||||
cmd = new ParametrizedCommand("name", false) {
|
||||
{
|
||||
try {
|
||||
addStringParameter(str1, true);
|
||||
addStringParameter(str2, false);
|
||||
addBooleanParameter(bool1);
|
||||
addBooleanParameter(bool2);
|
||||
} catch (final InvalidParameterException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(final ConsoleOutput out,
|
||||
final ConsoleInput in,
|
||||
final CommandParameters parameters) throws CommandRunException {
|
||||
if (!str2.equals(parameters.get(str1))) {
|
||||
throw new CommandRunException("Expected other argument",
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tip() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String usageDetail() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
try (PipedConsoleOutput out = new PipedConsoleOutput();
|
||||
PipedOutputStream pout = new PipedOutputStream();
|
||||
PipedInputStream pis = new PipedInputStream(pout);
|
||||
@ -437,49 +483,18 @@ public class ParametrizedCommandTest {
|
||||
new InputStreamReader(pis, StandardCharsets.UTF_8));
|
||||
PipedConsoleInput in = new PipedConsoleInput(
|
||||
new PrintStream(pout))) {
|
||||
cmd = new ParametrizedCommand("name", false) {
|
||||
{
|
||||
try {
|
||||
addStringParameter(str1, true);
|
||||
addStringParameter(str2, false);
|
||||
addBooleanParameter(bool1);
|
||||
addBooleanParameter(bool2);
|
||||
} catch (final InvalidParameterException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(final ConsoleOutput out,
|
||||
final ConsoleInput in,
|
||||
final CommandParameters parameters) {
|
||||
assertEquals(str2, parameters.get(str1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tip() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String usageDetail() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
cmd.execute(out, in, "-" + str1, str2);
|
||||
cmd.execute(out, in, "-" + str1, str2, "-" + bool1);
|
||||
cmd.execute(out, in, "-" + str1, str2, addParam);
|
||||
cmd.execute(out, in, "-" + str1, str2, "-" + addParam);
|
||||
cmd.execute(out, in, "-" + str1, str2, "-" + addParam, addParam);
|
||||
|
||||
Thread th = new Thread(new Runnable() {
|
||||
final Thread th = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertEquals("value of " + str1 + "? ",
|
||||
buf.readLine());
|
||||
assertEquals("value of " + str1 + "? ", buf.readLine());
|
||||
in.type("");
|
||||
assertEquals(
|
||||
"value of " + str1 + "? (cannot be empty) ",
|
||||
@ -499,14 +514,21 @@ public class ParametrizedCommandTest {
|
||||
cmd.execute(out, in);
|
||||
|
||||
th.join();
|
||||
}
|
||||
try (PipedConsoleOutput out = new PipedConsoleOutput();
|
||||
PipedOutputStream pout = new PipedOutputStream();
|
||||
PipedInputStream pis = new PipedInputStream(pout);
|
||||
BufferedReader buf = new BufferedReader(
|
||||
new InputStreamReader(pis, StandardCharsets.UTF_8));
|
||||
PipedConsoleInput in = new PipedConsoleInput(
|
||||
new PrintStream(pout))) {
|
||||
|
||||
th = new Thread(new Runnable() {
|
||||
final Thread th = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
assertEquals("value of " + str1 + "? ",
|
||||
buf.readLine());
|
||||
assertEquals("value of " + str1 + "? ", buf.readLine());
|
||||
in.type(str2);
|
||||
} catch (final IOException e) {
|
||||
assertNull(e);
|
||||
@ -522,36 +544,6 @@ public class ParametrizedCommandTest {
|
||||
try {
|
||||
final PipedConsoleOutput out = new PipedConsoleOutput();
|
||||
final PipedConsoleInput test = new PipedConsoleInput(null);
|
||||
cmd = new ParametrizedCommand("name") {
|
||||
{
|
||||
try {
|
||||
addStringParameter(str1, true);
|
||||
addStringParameter(str2, false);
|
||||
addBooleanParameter(bool1);
|
||||
addBooleanParameter(bool2);
|
||||
} catch (final InvalidParameterException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(final ConsoleOutput out,
|
||||
final ConsoleInput in,
|
||||
final CommandParameters parameters) {
|
||||
assertEquals(str2, parameters.get(str1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tip() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String usageDetail() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
test.close();
|
||||
out.close();
|
||||
cmd.execute(out, test, "-" + str1, str2);
|
||||
@ -560,7 +552,6 @@ public class ParametrizedCommandTest {
|
||||
} catch (final CommandRunException e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Test method for
|
||||
|
Loading…
Reference in New Issue
Block a user