Update thread namings.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
d32ea6b4b0
commit
0ebcd7b210
@ -73,7 +73,8 @@ public final class PipedConsoleInput
|
|||||||
innerManager = new StreamConsoleInput(outPrint, in,
|
innerManager = new StreamConsoleInput(outPrint, in,
|
||||||
StandardCharsets.UTF_8);
|
StandardCharsets.UTF_8);
|
||||||
writing = new WritingRunnable(commandInput, 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();
|
th.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public final class PipedConsoleOutput
|
|||||||
outPrint = new PrintStream(out, true, UTF_8);
|
outPrint = new PrintStream(out, true, UTF_8);
|
||||||
innerManager = new StreamConsoleOutput(outPrint);
|
innerManager = new StreamConsoleOutput(outPrint);
|
||||||
reading = new ReadingRunnable(commandBuffOutput);
|
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.setDaemon(true);
|
||||||
th.start();
|
th.start();
|
||||||
}
|
}
|
||||||
|
@ -430,13 +430,19 @@ public class ParametrizedCommandTest {
|
|||||||
// ok
|
// ok
|
||||||
}
|
}
|
||||||
// TODO Test of interactive not providing and providing all needed
|
// TODO Test of interactive not providing and providing all needed
|
||||||
try (PipedConsoleOutput out = new PipedConsoleOutput();
|
}
|
||||||
PipedOutputStream pout = new PipedOutputStream();
|
|
||||||
PipedInputStream pis = new PipedInputStream(pout);
|
@Test
|
||||||
BufferedReader buf = new BufferedReader(
|
public void testExecuteInteractive() throws IOException,
|
||||||
new InputStreamReader(pis, StandardCharsets.UTF_8));
|
CommandRunException,
|
||||||
PipedConsoleInput in = new PipedConsoleInput(
|
InterruptedException {
|
||||||
new PrintStream(pout))) {
|
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) {
|
cmd = new ParametrizedCommand("name", false) {
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -453,8 +459,11 @@ public class ParametrizedCommandTest {
|
|||||||
@Override
|
@Override
|
||||||
protected void doExecute(final ConsoleOutput out,
|
protected void doExecute(final ConsoleOutput out,
|
||||||
final ConsoleInput in,
|
final ConsoleInput in,
|
||||||
final CommandParameters parameters) {
|
final CommandParameters parameters) throws CommandRunException {
|
||||||
assertEquals(str2, parameters.get(str1));
|
if (!str2.equals(parameters.get(str1))) {
|
||||||
|
throw new CommandRunException("Expected other argument",
|
||||||
|
this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -467,19 +476,25 @@ public class ParametrizedCommandTest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
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))) {
|
||||||
cmd.execute(out, in, "-" + str1, str2);
|
cmd.execute(out, in, "-" + str1, str2);
|
||||||
cmd.execute(out, in, "-" + str1, str2, "-" + bool1);
|
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);
|
cmd.execute(out, in, "-" + str1, str2, "-" + addParam);
|
||||||
cmd.execute(out, in, "-" + str1, str2, "-" + addParam, addParam);
|
cmd.execute(out, in, "-" + str1, str2, "-" + addParam, addParam);
|
||||||
|
|
||||||
Thread th = new Thread(new Runnable() {
|
final Thread th = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assertEquals("value of " + str1 + "? ",
|
assertEquals("value of " + str1 + "? ", buf.readLine());
|
||||||
buf.readLine());
|
|
||||||
in.type("");
|
in.type("");
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"value of " + str1 + "? (cannot be empty) ",
|
"value of " + str1 + "? (cannot be empty) ",
|
||||||
@ -499,14 +514,21 @@ public class ParametrizedCommandTest {
|
|||||||
cmd.execute(out, in);
|
cmd.execute(out, in);
|
||||||
|
|
||||||
th.join();
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assertEquals("value of " + str1 + "? ",
|
assertEquals("value of " + str1 + "? ", buf.readLine());
|
||||||
buf.readLine());
|
|
||||||
in.type(str2);
|
in.type(str2);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
assertNull(e);
|
assertNull(e);
|
||||||
@ -522,36 +544,6 @@ public class ParametrizedCommandTest {
|
|||||||
try {
|
try {
|
||||||
final PipedConsoleOutput out = new PipedConsoleOutput();
|
final PipedConsoleOutput out = new PipedConsoleOutput();
|
||||||
final PipedConsoleInput test = new PipedConsoleInput(null);
|
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();
|
test.close();
|
||||||
out.close();
|
out.close();
|
||||||
cmd.execute(out, test, "-" + str1, str2);
|
cmd.execute(out, test, "-" + str1, str2);
|
||||||
@ -560,7 +552,6 @@ public class ParametrizedCommandTest {
|
|||||||
} catch (final CommandRunException e) {
|
} catch (final CommandRunException e) {
|
||||||
// ok
|
// ok
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for
|
/** Test method for
|
||||||
|
Loading…
Reference in New Issue
Block a user