Compare commits

...

124 Commits

Author SHA1 Message Date
1f8de26c2d [Jenkins] Dependency Updates 2025-01-09 12:19:03 +01:00
2e041f5585 [Jenkins] Dependency Updates 2025-01-09 04:38:09 +01:00
d3f633d2e4 [Jenkins] Dependency Updates 2024-10-17 12:19:03 +02:00
aad8c04a4f [Jenkins] Dependency Updates 2024-10-17 04:38:16 +02:00
69dd4ed41e [Jenkins] Dependency Updates 2024-10-03 12:19:11 +02:00
ab7fe1759c [Jenkins] Dependency Updates 2024-10-03 04:38:15 +02:00
69d9a052bc [Jenkins] Dependency Updates 2024-09-05 12:19:08 +02:00
219c21ebcb [Jenkins] Dependency Updates 2024-09-05 04:38:12 +02:00
85f53c9da9 [Jenkins] Dependency Updates 2024-05-16 12:19:02 +02:00
79a9a50174 [Jenkins] Dependency Updates 2024-05-16 04:38:08 +02:00
de9523cc82 [Jenkins] Dependency Updates 2024-04-14 08:36:03 +02:00
4b169cfdf5 [Jenkins] Dependency Updates 2024-04-11 12:19:02 +02:00
ca66c652cd [Jenkins] Dependency Updates 2024-04-10 05:36:02 +02:00
Emmanuel Bigeon
1f642ec91d [update] Update to junit 5 2024-04-04 14:41:50 +02:00
8b0efef54f [Jenkins] Dependency Updates 2024-03-07 12:19:11 +01:00
905c499c01 [Jenkins] Dependency Updates 2024-03-07 04:38:16 +01:00
05a353d5a5 [Jenkins] Dependency Updates 2024-02-01 12:19:03 +01:00
c7f2db9814 [Jenkins] Dependency Updates 2024-02-01 04:38:08 +01:00
5e47a68169 [Jenkins] Dependency Updates 2024-01-18 12:19:03 +01:00
14c4382560 [Jenkins] Dependency Updates 2024-01-18 04:38:08 +01:00
e930f60d0e [Jenkins] Dependency Updates 2023-12-07 12:19:03 +01:00
93dba8bea8 [Jenkins] Dependency Updates 2023-12-07 04:38:10 +01:00
12370856e9 [Jenkins] Dependency Updates 2023-11-09 12:19:03 +01:00
1c5f87aee1 [Jenkins] Dependency Updates 2023-11-09 04:38:10 +01:00
57177d30c1 [Jenkins] Dependency Updates 2023-10-12 12:19:02 +02:00
bdd1bec9ce [Jenkins] Dependency Updates 2023-10-12 04:38:09 +02:00
cebb30965d [Jenkins] Dependency Updates 2023-08-24 12:19:02 +02:00
63d21acb4f [Jenkins] Dependency Updates 2023-08-24 04:38:09 +02:00
0c76ac826b [Jenkins] Dependency Updates 2023-07-02 08:36:03 +02:00
4ba4cee1cf [Jenkins] Dependency Updates 2023-06-29 12:19:03 +02:00
84176998a2 [Jenkins] Dependency Updates 2023-06-28 05:36:02 +02:00
5e1dba6244 [Jenkins] Dependency Updates 2023-06-22 12:19:03 +02:00
2a1c8393ba [Jenkins] Dependency Updates 2023-06-22 04:38:06 +02:00
09635365a5 [Jenkins] Dependency Updates 2023-04-27 12:19:03 +02:00
b7d86da484 [Jenkins] Dependency Updates 2023-04-27 04:38:07 +02:00
021193b640 [Jenkins] Dependency Updates 2023-04-13 12:19:03 +02:00
6a0f321e16 [Jenkins] Dependency Updates 2023-04-13 04:38:06 +02:00
662ea7ddc0 [Jenkins] Dependency Updates 2023-04-06 12:19:03 +02:00
c8a0897cbb [Jenkins] Dependency Updates 2023-04-05 05:36:02 +02:00
9fa3bc7d10 [Jenkins] Dependency Updates 2023-04-02 08:36:03 +02:00
992b3b9f09 [Jenkins] Dependency Updates 2023-03-16 12:19:03 +01:00
3434210d0a [Jenkins] Dependency Updates 2023-03-16 04:38:07 +01:00
bd33923aa7 [Jenkins] Dependency Updates 2023-02-02 12:19:02 +01:00
e7f26bcb8c [Jenkins] Dependency Updates 2023-02-02 04:38:06 +01:00
cbf0f79d91 [Jenkins] Dependency Updates 2023-01-19 12:19:02 +01:00
82a3d260b9 [Jenkins] Dependency Updates 2023-01-19 04:38:06 +01:00
5147c19bd2 [Jenkins] Dependency Updates 2023-01-05 12:19:02 +01:00
e4260f591d [Jenkins] Dependency Updates 2023-01-05 04:38:06 +01:00
a352538dbb [Jenkins] Dependency Updates 2022-12-22 12:19:02 +01:00
c0fbcf44a3 [Jenkins] Dependency Updates 2022-12-22 04:38:06 +01:00
7b88a2e4b4 [Jenkins] Dependency Updates 2022-11-17 12:19:02 +01:00
62f637d73e [Jenkins] Dependency Updates 2022-11-17 04:38:06 +01:00
3300344819 [Jenkins] Dependency Updates 2022-10-27 12:19:02 +02:00
61da33e7fe [Jenkins] Dependency Updates 2022-10-27 04:38:07 +02:00
5d3d5ce795 [Jenkins] Dependency Updates 2022-09-15 12:19:03 +02:00
285d94460e [Jenkins] Dependency Updates 2022-09-15 04:38:49 +02:00
2f76312c60 [maven-release-plugin] prepare for next development iteration 2022-09-10 12:58:34 +02:00
48d4db4086 [maven-release-plugin] prepare release swt-1.2.1 2022-09-10 12:58:31 +02:00
6a7d1f4636 [fix] Fix runnable superclass location
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2022-09-10 12:56:50 +02:00
9748b14872 [Jenkins] Dependency Updates 2022-08-18 12:19:03 +02:00
3219729b92 [Jenkins] Dependency Updates 2022-08-18 04:38:06 +02:00
e8eb56287e [Jenkins] Dependency Updates 2022-06-09 12:19:03 +02:00
6bc567d3b9 [Jenkins] Dependency Updates 2022-06-09 04:38:08 +02:00
cf2a90d2b7 [Jenkins] Dependency Updates 2022-06-02 12:19:03 +02:00
0dee4837ed [Jenkins] Dependency Updates 2022-04-28 12:19:02 +02:00
d605ed7aa1 [Jenkins] Dependency Updates 2022-04-28 04:38:08 +02:00
e570680ef8 [Jenkins] Dependency Updates 2022-04-21 12:19:02 +02:00
8da0a10616 [Jenkins] Dependency Updates 2022-04-21 04:38:06 +02:00
0839487620 [Jenkins] Dependency Updates 2022-03-19 08:47:06 +01:00
e37e84019a [Jenkins] Dependency Updates 2022-03-10 12:19:02 +01:00
bf593d4989 [Jenkins] Dependency Updates 2022-03-10 04:38:08 +01:00
0f120f7330 [Jenkins] Dependency Updates 2022-02-27 13:51:27 +01:00
52c76b4633 [Jenkins] Dependency Updates 2022-02-10 12:19:02 +01:00
3393294ddc [Jenkins] Dependency Updates 2022-02-10 04:38:07 +01:00
990b89848d [Jenkins] Dependency Updates 2022-02-09 05:36:03 +01:00
a74a909011 [maven-release-plugin] prepare for next development iteration 2022-02-05 10:53:58 +01:00
999c97dbf8 [maven-release-plugin] prepare release gclc-2.1.5 2022-02-05 10:53:55 +01:00
a9916eacab [chore] Update pom scm. Skip gclc-2.1.4
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2022-02-05 10:51:39 +01:00
fe942533cd [maven-release-plugin] prepare release gclc-2.1.4 2022-02-05 10:47:50 +01:00
a31c13ef1b [chore] Pom update scm. skip gclc 2.1.3 release.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2022-02-05 10:45:42 +01:00
c7c53d15c5 [maven-release-plugin] prepare release gclc-2.1.3 2022-02-05 10:42:37 +01:00
d86a254604 Merge branch 'master' into dev 2022-02-05 10:39:23 +01:00
3d9b0d039a [Jenkins] Dependency Updates 2022-01-27 12:20:02 +01:00
39ae13e01a [Jenkins] Dependency Updates 2022-01-27 04:39:08 +01:00
eeea0148f6 Merge branch 'master' into dev 2022-01-05 17:14:28 +01:00
a25360f50f [Jenkins] Dependency Updates 2021-12-23 12:19:02 +01:00
4212776bb9 [Jenkins] Dependency Updates 2021-12-23 04:38:08 +01:00
4d42dff80a [Jenkins] Dependency Updates 2021-11-25 12:19:02 +01:00
d680694d0a [Jenkins] Dependency Updates 2021-11-25 04:38:07 +01:00
c174e90562 [test] Remove use of deprecated code in test
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-22 08:20:51 +01:00
6bb3ad2354 [test] Fix invalid cast
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-22 08:19:53 +01:00
0f731270d5 [test] Fix the test of history text listener
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-13 19:13:00 +01:00
45fa90c75e Merge branch 'master' into dev 2021-11-13 19:00:38 +01:00
da107f0a40 [doc] Added comments on a brain overloading method.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 10:06:48 +01:00
14007f4d9a [fix] Remove use of deprecated code
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 10:00:06 +01:00
c500c3c046 [fix] Specify command type
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 09:53:35 +01:00
0c1cfe3946 [style] Set abstract class constructor as protected
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 09:52:11 +01:00
66d25697a8 [fix] Set waits inside loops
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 09:50:51 +01:00
a9c97a7ebc [chore] Remove commented out code
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-12 09:31:49 +01:00
0acc900a7c [Jenkins] Dependency Updates 2021-11-11 12:19:03 +01:00
8025122906 [test] Complete tests.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-10 11:14:08 +01:00
c8804fcd74 [Jenkins] Dependency Updates 2021-11-10 05:36:03 +01:00
80b8993e1f [Jenkins] Dependency Updates 2021-11-08 10:09:38 +01:00
625cacb198 [fix] Fix use of computeIfPresent with HashMap with possible null values
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 12:22:11 +01:00
ea01d346d3 [test] Use assert equals
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 12:13:13 +01:00
b38980eeb5 [chore] Move InterruptedIOException full name into documentation.
This avoids unnecessarily importing it.

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:59:32 +01:00
7b7d0e6747 [style] protected context for constructor of abstract classes
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:57:13 +01:00
8643b69054 [refactor] Use mapping computeIfPresent/Absent for conditional branch
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:55:21 +01:00
d726312341 [fix] Use string concatenation in delegated function for logging
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:45:29 +01:00
2ece273148 [fix] Put wait in while loops to consider spurious interruptions.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:44:20 +01:00
63de5448de [refactor] Reduced complexity of argument reading by one by refactoring
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:32:33 +01:00
51d8caa51e [fix] Unclosed stream wrapped in delegating stream.
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:22:40 +01:00
72f768e6de [fix] Bug in Test for interactive
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2021-11-07 11:20:38 +01:00
8f386b4abd [tests] Add test on input contract
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2020-04-10 15:58:30 -04:00
1454938db8 [fix] Fix imports in new version of tests
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2020-04-10 15:53:39 -04:00
2f24c30d44 [jenkins] Update configuration and dependency 2020-04-06 06:25:29 -04:00
c97e5de32e [chore] update dependencies
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2020-04-04 12:45:33 -04:00
3df6482a64 [tests] Fix failing test because of incoherent assertion
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2020-04-04 11:48:53 -04:00
5c7635f550 Fix cycle
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2019-06-09 12:13:41 -04:00
54a267092d Moved util class to the right package
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2019-06-08 20:13:39 -04:00
c1ce1277d3 Extract interface as method return
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2019-06-08 20:09:03 -04:00
ba61efaa4a Add test with long execution command
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2019-06-08 19:59:26 -04:00
7a2991acc1 Reduce line duplication due to moved class
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
2019-06-08 12:05:50 -04:00
fe8f0212ea [maven-release-plugin] prepare for next development iteration 2019-06-08 11:34:22 -04:00
48 changed files with 501 additions and 437 deletions

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>ebigeon-config</artifactId> <artifactId>ebigeon-config</artifactId>
<version>1.8.21</version> <version>1.8.33</version>
</parent> </parent>
<groupId>net.bigeon.gclc</groupId> <groupId>net.bigeon.gclc</groupId>
@ -38,7 +38,7 @@
</developers> </developers>
<scm> <scm>
<tag>HEAD</tag> <tag>HEAD</tag>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
</scm> </scm>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -49,12 +49,12 @@
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.1.0</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bigeon.test</groupId> <groupId>net.bigeon.test</groupId>
<artifactId>junitmt</artifactId> <artifactId>junitmt</artifactId>
<version>1.0.2</version> <version>1.0.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -100,7 +100,7 @@ public abstract class ForkTask implements Task {
/** Create the task. /** Create the task.
* *
* @param lines the number of print to store in the output */ * @param lines the number of print to store in the output */
public ForkTask(final int lines) { protected ForkTask(final int lines) {
out = new ConnectingConsoleOutput(ConnectingConsoleOutput.PERSIST, lines); out = new ConnectingConsoleOutput(ConnectingConsoleOutput.PERSIST, lines);
} }
@ -142,15 +142,18 @@ public abstract class ForkTask implements Task {
* @param timeout the maximal time to join for (0 for ever) */ * @param timeout the maximal time to join for (0 for ever) */
public final void join(final ConsoleOutput out, final ConsoleInput in, public final void join(final ConsoleOutput out, final ConsoleInput in,
final long timeout) { final long timeout) {
final long tic = System.currentTimeMillis();
synchronized (runLock) { synchronized (runLock) {
this.out.connect(out); this.out.connect(out);
this.in.connect(in); this.in.connect(in);
try { long tac = System.currentTimeMillis() - tic;
if (running) { while (running && tac < timeout) {
try {
runLock.wait(timeout); runLock.wait(timeout);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
} }
} catch (final InterruptedException e) { tac = System.currentTimeMillis() - tic;
Thread.currentThread().interrupt();
} }
this.out.disconnect(); this.out.disconnect();
this.in.disconnect(); this.in.disconnect();

View File

@ -84,8 +84,8 @@ public abstract class TaskSpawner extends Command {
private final ExecutorService threadPool; private final ExecutorService threadPool;
/** @param name the command name /** @param name the command name
* @param pool the pool */ * @param threadPool the pool */
public TaskSpawner(final String name, final TaskPool pool, protected TaskSpawner(final String name, final TaskPool pool,
final ExecutorService threadPool) { final ExecutorService threadPool) {
super(name); super(name);
this.pool = pool; this.pool = pool;

View File

@ -72,20 +72,16 @@ import java.io.InterruptedIOException;
import java.util.function.Supplier; import java.util.function.Supplier;
import net.bigeon.gclc.manager.ConsoleInput; import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.tools.ConstantString;
/** A console input that can be connected to and diconnected from. /** A console input that can be connected to and diconnected from.
* *
* @author Emmanuel Bigeon */ * @author Emmanuel Bigeon */
public final class ConnectingConsoleInput implements ConsoleInput { public final class ConnectingConsoleInput implements ConsoleInput {
/** The empty string provider. */
private static final ConstantString EMPTY_STRING = new ConstantString("");
/** If the input is closed. */ /** If the input is closed. */
private boolean close = false; private boolean close = false;
/** The prompt string. */ /** The prompt string. */
private Supplier<String> prompt = EMPTY_STRING; private Supplier<String> prompt = () -> "";
/** If the input is currently in prompting state. /** If the input is currently in prompting state.
* <p> * <p>
* To change it you should be in a promptLock. */ * To change it you should be in a promptLock. */
@ -210,10 +206,18 @@ public final class ConnectingConsoleInput implements ConsoleInput {
return doPrompt(message, timeout, tic); return doPrompt(message, timeout, tic);
} }
/** Actually do the prompting
*
* @param message the prompt message
* @param timeout the time to wait for an answer
* @param tic the moment the wait started
* @return the message provided through the prompting
* @throws IOException if an IO error occurred while prompting. */
private String doPrompt(final String message, final long timeout, final long tic) private String doPrompt(final String message, final long timeout, final long tic)
throws IOException { throws IOException {
do { do {
if (!checkPrompt()) { if (!checkPrompt()) {
// We are not prompting... lets stop here.
break; break;
} }
getConnection(getTimeoutLeft(tic, timeout)); getConnection(getTimeoutLeft(tic, timeout));
@ -224,10 +228,13 @@ public final class ConnectingConsoleInput implements ConsoleInput {
actualConnected = connected; actualConnected = connected;
} }
if (!connect) { if (!connect) {
// There is no provide of input... So lets start again, until we actually
// DO get a provider of input.
continue; continue;
} }
try { try {
final String res = actualPrompt(message, timeout, tic, actualConnected); final String res = actualPrompt(message, timeout, tic, actualConnected);
// We got something from the prompting
synchronized (promptLock) { synchronized (promptLock) {
if (prompting) { if (prompting) {
prompting = false; prompting = false;
@ -286,10 +293,10 @@ public final class ConnectingConsoleInput implements ConsoleInput {
} }
private void getConnection(final long timeout) throws InterruptedIOException { private void getConnection(final long timeout) throws InterruptedIOException {
boolean connect; final long tic = System.currentTimeMillis();
synchronized (connectionLock) { synchronized (connectionLock) {
connect = connected != null; while ((connected == null || !interrupting)
if (!connect) { && (tic + timeout) > System.currentTimeMillis()) {
try { try {
connectionLock.wait(timeout); connectionLock.wait(timeout);
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
@ -307,7 +314,7 @@ public final class ConnectingConsoleInput implements ConsoleInput {
* @see fr.bigeon.gclc.manager.ConsoleInput#setPrompt(java.lang.String) */ * @see fr.bigeon.gclc.manager.ConsoleInput#setPrompt(java.lang.String) */
@Override @Override
public void setPrompt(final String prompt) { public void setPrompt(final String prompt) {
this.prompt = new ConstantString(prompt); this.prompt = () -> prompt;
} }
/* (non-Javadoc) /* (non-Javadoc)

View File

@ -1,10 +1,6 @@
package net.bigeon.gclc.process.io; package net.bigeon.gclc.process.io;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
@ -12,16 +8,16 @@ import java.io.PipedInputStream;
import java.io.PipedOutputStream; import java.io.PipedOutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import org.junit.Test; import org.junit.Test;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.StreamConsoleInput; import net.bigeon.gclc.manager.StreamConsoleInput;
import net.bigeon.gclc.tools.ConstantString;
import net.bigeon.test.junitmt.ATestRunnable;
import net.bigeon.test.junitmt.FunctionalTestRunnable; import net.bigeon.test.junitmt.FunctionalTestRunnable;
import net.bigeon.test.junitmt.TestFunction;
import net.bigeon.test.junitmt.ThreadTest; import net.bigeon.test.junitmt.ThreadTest;
import net.bigeon.test.junitmt.api.ATestRunnable;
import net.bigeon.test.junitmt.api.TestFunction;
public class ConnectingConsoleInputTest { public class ConnectingConsoleInputTest {
@ -67,9 +63,8 @@ public class ConnectingConsoleInputTest {
public void testCoveragePrompt() { public void testCoveragePrompt() {
final ConnectingConsoleInput in = new ConnectingConsoleInput(); final ConnectingConsoleInput in = new ConnectingConsoleInput();
in.setPrompt("test"); in.setPrompt("test");
assertEquals("Prompt should be set correctly", "test", assertEquals("Prompt should be set correctly", "test", in.getPrompt().get());
((ConstantString) in.getPrompt()).get()); final Supplier<String> prompt = () -> "other";
final ConstantString prompt = new ConstantString("other");
in.setPrompt(prompt); in.setPrompt(prompt);
assertEquals("Prompt should be set correctly", prompt, in.getPrompt()); assertEquals("Prompt should be set correctly", prompt, in.getPrompt());
} }
@ -79,51 +74,43 @@ public class ConnectingConsoleInputTest {
final ConnectingConsoleInput in = new ConnectingConsoleInput(); final ConnectingConsoleInput in = new ConnectingConsoleInput();
// Unconnected // Unconnected
final AtomicBoolean ended = new AtomicBoolean(false); final AtomicBoolean ended = new AtomicBoolean(false);
final TestFunction one = new TestFunction() { final TestFunction one = () -> {
try {
@Override final String res1 = in.prompt("m1", -1);
public void apply() throws Exception { fail("interruption of infinite waiting prompt should cause error, but was "
+ res1);
} catch (final InterruptedIOException e1) {
// ok
}
try {
final String res2 = in.prompt("m2", 25000);
fail("interruption of finite waiting prompt should cause error, but was "
+ res2);
} catch (final InterruptedIOException e2) {
// ok
}
synchronized (ended) {
ended.set(true);
try { try {
final String res = in.prompt("m1", -1); assertNull("Overtime should return null", in.prompt("m3", 200));
fail("interruption of infinite waiting prompt should cause error, but was " } catch (final InterruptedIOException e3) {
+ res); fail("Unexpected interruption error in overtime");
} catch (final InterruptedIOException e) {
// ok
}
try {
final String res = in.prompt("m2", 25000);
fail("interruption of finite waiting prompt should cause error, but was "
+ res);
} catch (final InterruptedIOException e) {
// ok
}
synchronized (ended) {
ended.set(true);
try {
assertNull("Overtime should return null", in.prompt("m3", 200));
} catch (final InterruptedIOException e) {
fail("Unexpected interruption error in overtime");
}
} }
} }
}; };
final ATestRunnable runnable = new FunctionalTestRunnable(one); final ATestRunnable runnable = new FunctionalTestRunnable(one);
final Thread th = new Thread(runnable); final Thread th = new Thread(runnable, "TestPromptSequence");
final Thread inter = new Thread(new Runnable() { final Thread inter = new Thread(() -> {
while (!ended.get()) {
@Override try {
public void run() { th.join(100);
while (!ended.get()) { } catch (final InterruptedException e) {
try { // TODO Auto-generated catch block
th.join(100); e.printStackTrace();
} catch (final InterruptedException e) { }
// TODO Auto-generated catch block synchronized (ended) {
e.printStackTrace(); if (!ended.get()) {
} in.interruptPrompt();
synchronized (ended) {
if (!ended.get()) {
in.interruptPrompt();
}
} }
} }
} }
@ -139,21 +126,17 @@ public class ConnectingConsoleInputTest {
in.connect(new StreamConsoleInput(null, pis, StandardCharsets.UTF_8)); in.connect(new StreamConsoleInput(null, pis, StandardCharsets.UTF_8));
final ATestRunnable runnable2 = new FunctionalTestRunnable(one); final ATestRunnable runnable2 = new FunctionalTestRunnable(one);
final Thread th2 = new Thread(runnable2); final Thread th2 = new Thread(runnable2);
final Thread inter2 = new Thread(new Runnable() { final Thread inter2 = new Thread(() -> {
while (!ended.get()) {
@Override try {
public void run() { th2.join(100);
while (!ended.get()) { } catch (final InterruptedException e) {
try { // TODO Auto-generated catch block
th2.join(100); e.printStackTrace();
} catch (final InterruptedException e) { }
// TODO Auto-generated catch block synchronized (ended) {
e.printStackTrace(); if (!ended.get()) {
} in.interruptPrompt();
synchronized (ended) {
if (!ended.get()) {
in.interruptPrompt();
}
} }
} }
} }

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>ebigeon-public-conf</artifactId> <artifactId>ebigeon-public-conf</artifactId>
<version>1.0.10</version> <version>1.0.12</version>
</parent> </parent>
<groupId>net.bigeon.gclc</groupId> <groupId>net.bigeon.gclc</groupId>
<artifactId>socket</artifactId> <artifactId>socket</artifactId>
@ -35,7 +35,7 @@
</developer> </developer>
</developers> </developers>
<scm> <scm>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<properties> <properties>
@ -46,17 +46,17 @@
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.1.0</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>smu</artifactId> <artifactId>smu</artifactId>
<version>1.0.7</version> <version>1.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bigeon.test</groupId> <groupId>net.bigeon.test</groupId>
<artifactId>junitmt</artifactId> <artifactId>junitmt</artifactId>
<version>1.0.2</version> <version>1.0.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -51,7 +51,6 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.bigeon.gclc.manager.ConsoleInput; import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.tools.ConstantString;
import net.bigeon.gclc.utils.ReadingRunnable; import net.bigeon.gclc.utils.ReadingRunnable;
/** A console input where the stream can be plugged. /** A console input where the stream can be plugged.
@ -78,7 +77,7 @@ public final class PluggableConsoleInput implements ConsoleInput {
/** If the element is closed. */ /** If the element is closed. */
private boolean closed = false; private boolean closed = false;
/** The default prompt. */ /** The default prompt. */
private Supplier<String> prompt = new ConstantString("> "); //$NON-NLS-1$ private Supplier<String> prompt = () -> "> "; //$NON-NLS-1$
/** If the input is plugged or buffering. */ /** If the input is plugged or buffering. */
private boolean connected = false; private boolean connected = false;
/** The current connexion (if any). */ /** The current connexion (if any). */
@ -263,7 +262,7 @@ public final class PluggableConsoleInput implements ConsoleInput {
* @see net.bigeon.gclc.manager.ConsoleInput#setPrompt(java.lang.String) */ * @see net.bigeon.gclc.manager.ConsoleInput#setPrompt(java.lang.String) */
@Override @Override
public void setPrompt(final String prompt) { public void setPrompt(final String prompt) {
setPrompt(new ConstantString(prompt)); setPrompt(() -> prompt);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -294,7 +293,9 @@ public final class PluggableConsoleInput implements ConsoleInput {
brutalDisconnection(); brutalDisconnection();
} }
} }
connexionLock.wait(connexionTimeout); while (!connected) {
connexionLock.wait(connexionTimeout);
}
} }
return null; return null;
} }

View File

@ -4,46 +4,8 @@
*/ */
package net.bigeon.gclc.socket; package net.bigeon.gclc.socket;
/*-
* #%L
* GCLC Socket
* %%
* Copyright (C) 2016 - 2018 Bigeon
* %%
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
* #L%
*/
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Collection;
import net.bigeon.gclc.command.Command; import net.bigeon.gclc.command.Command;
import net.bigeon.gclc.exception.CommandRunException; import net.bigeon.gclc.exception.CommandRunException;
import net.bigeon.gclc.exception.CommandRunExceptionType;
import net.bigeon.gclc.manager.ConsoleInput; import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.manager.ConsoleOutput; import net.bigeon.gclc.manager.ConsoleOutput;
@ -56,11 +18,7 @@ import net.bigeon.gclc.manager.ConsoleOutput;
@Deprecated @Deprecated
public final class RemoteDisconnectCommand<T> extends Command { public final class RemoteDisconnectCommand<T> extends Command {
/** The connexion manager. */ private final net.bigeon.gclc.socket.cmd.RemoteDisconnectCommand<T> real;
private final ConnexionManager<T> manager;
/** If all connexion should be disconnected when no argument have been
* specified. */
private final boolean all;
/** Create the disconnection command. /** Create the disconnection command.
* *
@ -71,8 +29,8 @@ public final class RemoteDisconnectCommand<T> extends Command {
public RemoteDisconnectCommand(final String name, final ConnexionManager<T> manager, public RemoteDisconnectCommand(final String name, final ConnexionManager<T> manager,
final boolean all) { final boolean all) {
super(name); super(name);
this.manager = manager; real = new net.bigeon.gclc.socket.cmd.RemoteDisconnectCommand<>(name, manager,
this.all = all; all);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -81,52 +39,20 @@ public final class RemoteDisconnectCommand<T> extends Command {
@Override @Override
public void execute(final ConsoleOutput out, final ConsoleInput in, public void execute(final ConsoleOutput out, final ConsoleInput in,
final String... args) throws CommandRunException { final String... args) throws CommandRunException {
if (args.length == 0 && all) { real.execute(out, in, args);
final Collection<String> coll = manager.getConnected();
for (final String string : coll) {
manager.disconnect(string);
}
}
for (final String string : args) {
if (manager.isConnected(string)) {
manager.disconnect(string);
} else {
print(out,
MessageFormat.format("[WARNING] {0} is not connected", string)); //$NON-NLS-1$
}
}
}
/** Print a message if the output is defined.
*
* @param out the output
* @param string the message
* @throws CommandRunException if the output exists but cannot be printed to */
private static void print(final ConsoleOutput out, final String string)
throws CommandRunException {
if (out != null) {
try {
out.println(string);
} catch (final IOException e) {
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
"Unable to print to existing output", e); //$NON-NLS-1$
}
}
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see fr.bigeon.gclc.command.ICommand#tip() */ * @see fr.bigeon.gclc.command.ICommand#tip() */
@Override @Override
public String tip() { public String tip() {
return "Close a connexion."; //$NON-NLS-1$ return real.tip();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see fr.bigeon.gclc.command.Command#usageDetail() */ * @see fr.bigeon.gclc.command.Command#usageDetail() */
@Override @Override
protected String usageDetail() { protected String usageDetail() {
return MessageFormat.format( return "";
" If arguments are provided the corresponding connexions are closed, otherwise\n{0} are.",
all ? "all connexions" : "none");
} }
} }

View File

@ -3,11 +3,11 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>swt-public-conf</artifactId> <artifactId>swt-public-conf</artifactId>
<version>1.0.1</version> <version>1.0.2</version>
</parent> </parent>
<groupId>net.bigeon.gclc</groupId> <groupId>net.bigeon.gclc</groupId>
<artifactId>swt</artifactId> <artifactId>swt</artifactId>
<version>1.2.1-SNAPSHOT</version> <version>1.2.2-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>GCLC swt</name> <name>GCLC swt</name>
<description>A swt window for console applications</description> <description>A swt window for console applications</description>
@ -35,7 +35,7 @@
</developer> </developer>
</developers> </developers>
<scm> <scm>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<properties> <properties>
@ -48,27 +48,26 @@
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.1.0</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>collections</artifactId> <artifactId>collections</artifactId>
<version>1.2.6</version> <version>1.3.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.27.0</version> <version>5.15.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<reporting> <reporting>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version> <version>3.0.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.github.sevntu-checkstyle</groupId> <groupId>com.github.sevntu-checkstyle</groupId>

View File

@ -79,6 +79,8 @@ import org.eclipse.swt.widgets.Text;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
import net.bigeon.gclc.swt.api.ConsoleOutputDisplay;
import net.bigeon.gclc.swt.io.ConsoleInputManager; import net.bigeon.gclc.swt.io.ConsoleInputManager;
import net.bigeon.gclc.swt.io.ConsoleOutputManager; import net.bigeon.gclc.swt.io.ConsoleOutputManager;
import net.bigeon.gclc.swt.io.ConsolePromptManager; import net.bigeon.gclc.swt.io.ConsolePromptManager;
@ -131,12 +133,12 @@ public final class SWTConsole extends Composite {
} }
/** @return the inputManager */ /** @return the inputManager */
public ConsoleInputManager getInputManager() { public ConsoleDelayIO getInputManager() {
return inputManager; return inputManager;
} }
/** @return the outputManager */ /** @return the outputManager */
public ConsoleOutputManager getOutputManager() { public ConsoleOutputDisplay getOutputManager() {
return outputManager; return outputManager;
} }

View File

@ -78,6 +78,8 @@ import org.eclipse.swt.widgets.Text;
import net.bigeon.gclc.ConsoleApplication; import net.bigeon.gclc.ConsoleApplication;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.swt.api.ConsoleDelayIO;
import net.bigeon.gclc.swt.api.ConsoleOutputDisplay;
import net.bigeon.gclc.swt.io.ConsoleInputManager; import net.bigeon.gclc.swt.io.ConsoleInputManager;
import net.bigeon.gclc.swt.io.ConsoleOutputManager; import net.bigeon.gclc.swt.io.ConsoleOutputManager;
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener; import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
@ -132,14 +134,14 @@ public final class SWTConsoleView extends Composite {
/** Get the manager of console input. /** Get the manager of console input.
* *
* @return the input manager */ * @return the input manager */
public ConsoleInputManager getInputManager() { public ConsoleDelayIO getInputManager() {
return inManager; return inManager;
} }
/** Get the manager of console output. /** Get the manager of console output.
* *
* @return the output manager */ * @return the output manager */
public ConsoleOutputManager getOutputManager() { public ConsoleOutputDisplay getOutputManager() {
return outManager; return outManager;
} }
} }

View File

@ -96,4 +96,12 @@ public final class ConsoleOutputManager implements ConsoleOutputDisplay {
public Thread getForwardThread() { public Thread getForwardThread() {
return forwardThread; return forwardThread;
} }
/** @return the output consumer */
public PipedConsoleOutput getManager() {
if (forward == null) {
return null;
}
return forward.getOuput();
}
} }

View File

@ -6,8 +6,8 @@ package net.bigeon.gclc.swt.tools;
import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.Widget;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.manager.forwarding.AOutputForwardRunnable;
import net.bigeon.gclc.swt.api.ConsoleOutputDisplay; import net.bigeon.gclc.swt.api.ConsoleOutputDisplay;
import net.bigeon.gclc.tools.AOutputForwardRunnable;
/** The local implementation of the forwarding runnable. /** The local implementation of the forwarding runnable.
* *

View File

@ -3,6 +3,7 @@
*/ */
package net.bigeon.gclc.swt; package net.bigeon.gclc.swt;
import static org.mockito.ArgumentMatchers.any;
/*- /*-
* #%L * #%L
* GCLC swt * GCLC swt
@ -36,48 +37,128 @@ package net.bigeon.gclc.swt;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import net.bigeon.gclc.swt.io.ConsolePromptManager; import net.bigeon.gclc.swt.io.ConsolePromptManager;
/** /** @author Emmanuel Bigeon */
* @author Emmanuel Bigeon
*
*/
public class ConsolePromptManagerTest { public class ConsolePromptManagerTest {
private final Label label = mock(Label.class); private final Label label = mock(Label.class);
private final ConsolePromptManager manager = new ConsolePromptManager(label); private final ConsolePromptManager manager = new ConsolePromptManager(label);
/** /** Test method for
* Test method for {@link net.bigeon.gclc.swt.io.ConsolePromptManager#setPrompt(java.lang.String)}. * {@link net.bigeon.gclc.swt.io.ConsolePromptManager#setPrompt(java.lang.String)}. */
*/
@Test @Test
public void testSetPrompt() { public void testSetPrompt() {
manager.setPrompt("abc"); manager.setPrompt("abc");
verify(label).setText("abc"); verify(label).setText("abc");
} }
/** /** Test method for
* Test method for {@link net.bigeon.gclc.swt.io.ConsolePromptManager#setStream(java.io.BufferedReader)}. * {@link net.bigeon.gclc.swt.io.ConsolePromptManager#setStream(java.io.BufferedReader)}.
*/ *
* @throws IOException if error */
@Test @Test
public void testSetStream() { public void testSetStream() throws IOException {
// Create the dispaly, in case...
final Display d = mock(Display.class);
when(label.getDisplay()).thenReturn(d);
Mockito.doAnswer(invocation -> {
((Runnable) invocation.getArgument(0)).run();
return null;
}).when(d).asyncExec(any(Runnable.class));
Mockito.doAnswer(invocation -> {
((Runnable) invocation.getArgument(0)).run();
return null;
}).when(d).syncExec(any(Runnable.class));
// Test.
BufferedReader output = mock(BufferedReader.class); BufferedReader output = mock(BufferedReader.class);
final Object lock = new Object();
final AtomicInteger calls = new AtomicInteger(0);
Mockito.when(output.readLine()).then(new Answer<String>() {
String[] ans = { "A line" };
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
synchronized (lock) {
if (calls.get() >= ans.length) {
calls.incrementAndGet();
lock.notify();
return null;
}
lock.notify();
return ans[calls.getAndIncrement()];
}
}
});
manager.setStream(output); manager.setStream(output);
manager.setStream(output); manager.setStream(output);
synchronized (lock) {
while (calls.get() < 2) {
try {
lock.wait(10);
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
verify(output, times(2)).readLine();
output = mock(BufferedReader.class); output = mock(BufferedReader.class);
calls.set(0);
Mockito.when(output.readLine()).then(new Answer<String>() {
String[] ans = { "A line" };
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
synchronized (lock) {
if (calls.get() >= ans.length) {
calls.incrementAndGet();
lock.notify();
return null;
}
lock.notify();
return ans[calls.getAndIncrement()];
}
}
});
manager.setStream(output); manager.setStream(output);
while (calls.get() < 2) {
synchronized (lock) {
try {
lock.wait(10);
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
manager.setStream(null); manager.setStream(null);
manager.setStream(output); manager.setStream(output);
while (calls.get() < 3) {
synchronized (lock) {
try {
lock.wait(10);
} catch (final InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
verify(output, times(3)).readLine();
verify(label, times(2)).setText("A line");
} }
} }

View File

@ -69,11 +69,14 @@ package net.bigeon.gclc.swt;
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.*;
import java.io.IOException;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito;
import net.bigeon.gclc.swt.api.ConsoleDelayIO; import net.bigeon.gclc.swt.api.ConsoleDelayIO;
import net.bigeon.gclc.swt.tools.HistoryTextKeyListener; import net.bigeon.gclc.swt.tools.HistoryTextKeyListener;
@ -145,11 +148,23 @@ public class HistoryTextKeyListenerTest {
} }
@Test @Test
public void testKeyPressed() { public void testKeyPressedA() throws IOException {
final ConsoleDelayIO io = mock(ConsoleDelayIO.class); final ConsoleDelayIO io = mock(ConsoleDelayIO.class);
final KeyEvent event = mock(KeyEvent.class); final KeyEvent event = mock(KeyEvent.class);
event.keyCode = 'a'; event.keyCode = 'a';
final HistoryTextKeyListener listener = new HistoryTextKeyListener(io); final HistoryTextKeyListener listener = new HistoryTextKeyListener(io);
listener.keyPressed(event); listener.keyPressed(event);
verifyNoInteractions(io);
}
@Test
public void testKeyPressedReturn() throws IOException {
final ConsoleDelayIO io = mock(ConsoleDelayIO.class);
Mockito.when(io.getInput()).thenReturn("Alpha");
final KeyEvent event = mock(KeyEvent.class);
event.keyCode = '\r';
final HistoryTextKeyListener listener = new HistoryTextKeyListener(io);
listener.keyPressed(event);
verify(io, times(1)).validateInput();
} }
} }

View File

@ -50,8 +50,7 @@ import java.util.logging.Logger;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.junit.Test; import org.junit.Test;
import org.mockito.invocation.InvocationOnMock; import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import net.bigeon.gclc.swt.tools.PromptReadingRunnable; import net.bigeon.gclc.swt.tools.PromptReadingRunnable;
@ -61,16 +60,10 @@ public class PromptReadingRunnableTest {
private final Display display = mock(Display.class); private final Display display = mock(Display.class);
{ {
when(view.getDisplay()).thenReturn(display); when(view.getDisplay()).thenReturn(display);
doAnswer(new Answer<Object>() { doAnswer(invocation -> {
/* (non-Javadoc) final Runnable runnable = invocation.getArgument(0);
* @see runnable.run();
* org.mockito.stubbing.Answer#answer(org.mockito.invocation.InvocationOnMock) */ return null;
@Override
public Object answer(final InvocationOnMock invocation) throws Throwable {
final Runnable runnable = invocation.getArgument(0);
runnable.run();
return null;
}
}).when(display).syncExec(any(Runnable.class)); }).when(display).syncExec(any(Runnable.class));
} }
@ -85,6 +78,7 @@ public class PromptReadingRunnableTest {
final PromptReadingRunnable runnable = new PromptReadingRunnable(reader, view); final PromptReadingRunnable runnable = new PromptReadingRunnable(reader, view);
runnable.run(); runnable.run();
Mockito.verify(reader, Mockito.times(3)).readLine();
} }
/** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}. /** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}.
@ -102,6 +96,7 @@ public class PromptReadingRunnableTest {
runnable.run(); runnable.run();
logger.setLevel(back); logger.setLevel(back);
Mockito.verify(reader, Mockito.times(1)).readLine();
} }
} }

View File

@ -38,6 +38,7 @@ package net.bigeon.gclc.swt;
*/ */
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -46,6 +47,7 @@ import org.junit.Test;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
/** @author Emmanuel Bigeon */ /** @author Emmanuel Bigeon */
public class SWTConsoleShellTest { public class SWTConsoleShellTest {
@ -70,6 +72,8 @@ public class SWTConsoleShellTest {
final SWTConsole console = new SWTConsole(new Shell(), SWT.NONE); final SWTConsole console = new SWTConsole(new Shell(), SWT.NONE);
// Disconnection should work. // Disconnection should work.
console.connect(null, null, null); console.connect(null, null, null);
assertNull("Console should disconnect",
((ConsoleOutputManager) console.getOutputManager()).getManager());
} }
} }

View File

@ -39,6 +39,7 @@ package net.bigeon.gclc.swt;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
@ -46,6 +47,7 @@ import org.junit.Test;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.swt.io.ConsoleOutputManager;
/** @author Emmanuel Bigeon */ /** @author Emmanuel Bigeon */
public class SWTConsoleViewTest { public class SWTConsoleViewTest {
@ -74,5 +76,7 @@ public class SWTConsoleViewTest {
final SWTConsoleView view = new SWTConsoleView(new Shell(), SWT.NONE); final SWTConsoleView view = new SWTConsoleView(new Shell(), SWT.NONE);
// Disconnection should work. // Disconnection should work.
view.setManager(null, null); view.setManager(null, null);
assertNull("Disconnection should replace the input.",
((ConsoleOutputManager) view.getOutputManager()).getManager());
} }
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>ebigeon-config</artifactId> <artifactId>ebigeon-config</artifactId>
<version>1.8.21</version> <version>1.8.33</version>
</parent> </parent>
<groupId>net.bigeon.gclc</groupId> <groupId>net.bigeon.gclc</groupId>
<artifactId>test</artifactId> <artifactId>test</artifactId>
@ -37,7 +37,7 @@
</developer> </developer>
</developers> </developers>
<scm> <scm>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<properties> <properties>
@ -49,17 +49,17 @@
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.0.12</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bigeon.test</groupId> <groupId>net.bigeon.test</groupId>
<artifactId>junitmt</artifactId> <artifactId>junitmt</artifactId>
<version>1.0.2</version> <version>1.0.4</version>
</dependency> </dependency>
</dependencies> </dependencies>
<reporting> <reporting>
@ -67,7 +67,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version> <version>3.0.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.github.sevntu-checkstyle</groupId> <groupId>com.github.sevntu-checkstyle</groupId>

View File

@ -13,7 +13,6 @@ import java.util.function.Supplier;
import net.bigeon.gclc.manager.ConsoleInput; import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.test.junitmt.FunctionalTestRunnable; import net.bigeon.test.junitmt.FunctionalTestRunnable;
import net.bigeon.test.junitmt.TestFunction;
import net.bigeon.test.junitmt.ThreadTest; import net.bigeon.test.junitmt.ThreadTest;
/** @author Emmanuel Bigeon */ /** @author Emmanuel Bigeon */
@ -38,24 +37,17 @@ public final class InputContract {
// Test interruption contract // Test interruption contract
final ConsoleInput input2 = inputs.get(); final ConsoleInput input2 = inputs.get();
final FunctionalTestRunnable prompting = new FunctionalTestRunnable( final FunctionalTestRunnable prompting = new FunctionalTestRunnable(
new TestFunction() { () -> {
try {
@Override input2.prompt();
public void apply() throws Exception { fail("Interrupted prompt should throw INterruptedIOException");
try { } catch (final InterruptedIOException e) {
input2.prompt(); // ok
fail("Interrupted prompt should throw INterruptedIOException");
} catch (final InterruptedIOException e) {
// ok
}
} }
}); });
final Thread th = new Thread(prompting); final Thread th = new Thread(prompting);
th.start(); th.start();
// while (!input2.isPrompting()) {
th.join(200); th.join(200);
//
// }
input2.interruptPrompt(); input2.interruptPrompt();
ThreadTest.assertRuns(th, prompting); ThreadTest.assertRuns(th, prompting);
} }

View File

@ -0,0 +1,52 @@
/** gclc-test: InputContractTest
* Created on Apr. 6, 2020
*/
package net.bigeon.gclc.test;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import org.junit.After;
import org.junit.Test;
import net.bigeon.gclc.manager.EmptyInput;
import net.bigeon.gclc.manager.StreamConsoleInput;
/** @author Emmanuel Bigeon */
public class InputContractTest {
/** Test method for
* {@link net.bigeon.gclc.test.InputContract#testInputContract(java.util.function.Supplier)}. */
@Test
public void testTestInputContract() throws IOException, InterruptedException {
final InputContract contract = new InputContract();
try (InputStream in = new PipedInputStream(new PipedOutputStream());
PrintStream out = new PrintStream("temp.txt")) {
contract.testInputContract(
() -> new StreamConsoleInput(out, in, StandardCharsets.UTF_8));
}
try {
contract.testInputContract(() -> EmptyInput.INSTANCE);
fail("Empty input does not fit the contract for inputs since it cannot be closed.");
} catch (final AssertionError e) {
// ok
}
}
@After
public void tearDown() {
final File f = new File("temp.txt");
if (f.exists()) {
f.delete();
}
}
}

View File

@ -3,7 +3,7 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>ebigeon-config</artifactId> <artifactId>ebigeon-config</artifactId>
<version>1.8.21</version> <version>1.8.33</version>
</parent> </parent>
<groupId>net.bigeon.gclc</groupId> <groupId>net.bigeon.gclc</groupId>
<artifactId>system</artifactId> <artifactId>system</artifactId>
@ -35,7 +35,7 @@
</developer> </developer>
</developers> </developers>
<scm> <scm>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
<tag>HEAD</tag> <tag>HEAD</tag>
</scm> </scm>
<properties> <properties>
@ -48,12 +48,12 @@
<dependency> <dependency>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.0.11</version> <version>2.1.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.23.0</version> <version>5.15.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -67,7 +67,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version> <version>3.0.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.github.sevntu-checkstyle</groupId> <groupId>com.github.sevntu-checkstyle</groupId>

View File

@ -101,7 +101,7 @@ public class ExecSystemCommand extends Command {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
while (th.isAlive()) { while (th.isAlive()) {
final String user = in.prompt(); final String user = in.prompt();
// Avoid interruption being sent to process. // Forward to process if not empty.
if (!user.isEmpty()) { if (!user.isEmpty()) {
writer.write(user + EOL); writer.write(user + EOL);
} }

View File

@ -33,17 +33,17 @@ package net.bigeon.gclc.system;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.fail;
import org.junit.Test; import org.junit.jupiter.api.Test;
import net.bigeon.gclc.exception.CommandRunException; import net.bigeon.gclc.exception.CommandRunException;
import net.bigeon.gclc.manager.ConsoleInput; import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.manager.ConsoleOutput; import net.bigeon.gclc.manager.ConsoleOutput;
import net.bigeon.gclc.utils.EmptyInput; import net.bigeon.gclc.manager.EmptyInput;
import net.bigeon.gclc.utils.SinkOutput; import net.bigeon.gclc.manager.SinkOutput;
public class ExecSystemCommandTest { public class ExecSystemCommandTest {
@ -51,10 +51,10 @@ public class ExecSystemCommandTest {
@Test @Test
public void testExecSystemCommand() { public void testExecSystemCommand() {
final ExecSystemCommand cmd = new ExecSystemCommand("test"); final ExecSystemCommand cmd = new ExecSystemCommand("test");
assertEquals("Name should be preserved", "test", cmd.getCommandName()); assertEquals("test", cmd.getCommandName(), "Name should be preserved");
assertNotNull("tip should be defined", cmd.tip()); assertNotNull(cmd.tip(), "tip should be defined");
assertNotNull("usage should be defined", cmd.usagePattern()); assertNotNull(cmd.usagePattern(), "usage should be defined");
assertNotNull("usage should be defined", cmd.usageDetail()); assertNotNull(cmd.usageDetail(), "usage should be detailed");
} }
/** Test the execution of the command. /** Test the execution of the command.
@ -79,4 +79,26 @@ public class ExecSystemCommandTest {
} }
} }
/** Test the execution of the command.
*
* @throws CommandRunException if the command fails */
@Test
public void testLongExecute() throws CommandRunException {
final ConsoleOutput out = SinkOutput.INSTANCE;
final ConsoleInput in = EmptyInput.INSTANCE;
final ExecSystemCommand cmd = new ExecSystemCommand();
if (System.getProperty("os.name").contains("indows")) {
cmd.execute(out, in, "cmd", "/C", "dir", "/s");
} else if (System.getProperty("os.name").contains("inux")) {
cmd.execute(out, in, "ls", "-R");
}
try {
cmd.execute(out, in, "inexistent");
fail("Able to execute inexistent command in system");
} catch (final CommandRunException e) {
// ok
}
}
} }

View File

@ -3,18 +3,18 @@
*/ */
package net.bigeon.gclc.system; package net.bigeon.gclc.system;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import net.bigeon.gclc.exception.CommandRunException; import net.bigeon.gclc.exception.CommandRunException;
import net.bigeon.gclc.utils.SinkOutput; import net.bigeon.gclc.manager.SinkOutput;
import net.bigeon.gclc.utils.StreamConsoleOutput; import net.bigeon.gclc.manager.StreamConsoleOutput;
/** @author Emmanuel Bigeon */ /** @author Emmanuel Bigeon */
public class ForwardingRunnableTest { public class ForwardingRunnableTest {
@ -27,8 +27,8 @@ public class ForwardingRunnableTest {
// Runnable should close immediatly. // Runnable should close immediatly.
runnable.run(); runnable.run();
assertTrue("Error should be a CommandRunException", assertInstanceOf(CommandRunException.class, runnable.getError(),
runnable.getError() instanceof CommandRunException); "Error should be a CommandRunException");
} }
@Test @Test
@ -39,6 +39,6 @@ public class ForwardingRunnableTest {
is); is);
// Runnable should close immediatly. // Runnable should close immediatly.
runnable.run(); runnable.run();
assertTrue("Error should be an IO", runnable.getError() instanceof IOException); assertInstanceOf(IOException.class, runnable.getError(), "Error should be an IO");
} }
} }

View File

@ -4,11 +4,11 @@
<parent> <parent>
<groupId>net.bigeon.config</groupId> <groupId>net.bigeon.config</groupId>
<artifactId>ebigeon-public-conf</artifactId> <artifactId>ebigeon-public-conf</artifactId>
<version>1.0.10</version> <version>1.0.12</version>
</parent> </parent>
<groupId>net.bigeon</groupId> <groupId>net.bigeon</groupId>
<artifactId>gclc</artifactId> <artifactId>gclc</artifactId>
<version>2.1.2</version> <version>2.1.6-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Generic Command Ligne console</name> <name>Generic Command Ligne console</name>
<description>A generic framework for console applications, with customized command input and output streams.</description> <description>A generic framework for console applications, with customized command input and output streams.</description>
@ -36,8 +36,8 @@
</developer> </developer>
</developers> </developers>
<scm> <scm>
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection> <developerConnection>scm:git:gitea@git.code.bigeon.net:emmanuel/gclc-core.git</developerConnection>
<tag>gclc-2.1.2</tag> <tag>HEAD</tag>
</scm> </scm>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -49,7 +49,7 @@
<dependency> <dependency>
<groupId>net.bigeon.test</groupId> <groupId>net.bigeon.test</groupId>
<artifactId>junitmt</artifactId> <artifactId>junitmt</artifactId>
<version>1.0.2</version> <version>1.0.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -191,7 +191,7 @@ public final class ConsoleApplication implements ICommandProvider {
args = GCLCConstants.splitCommand(cmd); args = GCLCConstants.splitCommand(cmd);
} catch (final CommandParsingException e) { } catch (final CommandParsingException e) {
out.println("Command line cannot be parsed"); //$NON-NLS-1$ out.println("Command line cannot be parsed"); //$NON-NLS-1$
LOGGER.log(Level.FINE, "Invalid user command " + cmd, e); //$NON-NLS-1$ LOGGER.log(Level.FINE, e, () -> "Invalid user command " + cmd); //$NON-NLS-1$
return; return;
} }
if (!args.isEmpty()) { if (!args.isEmpty()) {
@ -199,7 +199,7 @@ public final class ConsoleApplication implements ICommandProvider {
executeSub(out, in, args.get(0), executeSub(out, in, args.get(0),
Arrays.copyOfRange(args.toArray(new String[0]), 1, args.size())); Arrays.copyOfRange(args.toArray(new String[0]), 1, args.size()));
} catch (final CommandRunException e) { } catch (final CommandRunException e) {
LOGGER.log(Level.FINE, "Command failed: " + cmd, e); //$NON-NLS-1$ LOGGER.log(Level.FINE, e, () -> "Command failed: " + cmd); //$NON-NLS-1$
out.println(Messages.getString("ConsoleApplication.cmd.failed", cmd)); //$NON-NLS-1$ out.println(Messages.getString("ConsoleApplication.cmd.failed", cmd)); //$NON-NLS-1$
out.println(e.getLocalizedMessage()); out.println(e.getLocalizedMessage());
if (e.getType() == CommandRunExceptionType.USAGE) { if (e.getType() == CommandRunExceptionType.USAGE) {

View File

@ -146,10 +146,7 @@ public final class GCLCConstants {
continue; continue;
} }
if (c == ' ' && !inString) { if (c == ' ' && !inString) {
final String arg = cmd.substring(startIndex, index - 1); addArgument(args, cmd.substring(startIndex, index - 1));
if (!arg.isEmpty()) {
args.add(removeEscaped(arg));
}
startIndex = index; startIndex = index;
} else if (c == '"') { } else if (c == '"') {
if (inString) { if (inString) {
@ -169,4 +166,13 @@ public final class GCLCConstants {
return args; return args;
} }
/** Add an argument to the list of arguments if it is not an empty string.
*
* @param args the list of argument
* @param arg the candidate argument */
private static void addArgument(final List<String> args, final String arg) {
if (!arg.isEmpty()) {
args.add(removeEscaped(arg));
}
}
} }

View File

@ -73,7 +73,7 @@ public abstract class Command implements ICommand {
/** Create the command. /** Create the command.
* *
* @param name the command name */ * @param name the command name */
public Command(final String name) { protected Command(final String name) {
super(); super();
if (name == null) { if (name == null) {
throw new IllegalArgumentException("The command name is mandatory"); throw new IllegalArgumentException("The command name is mandatory");

View File

@ -103,7 +103,7 @@ public final class CommandParameters {
* @param key the key * @param key the key
* @return if the key was specified */ * @return if the key was specified */
public boolean isActive(final String key) { public boolean isActive(final String key) {
Boolean val = booleanArguments.get(key); final Boolean val = booleanArguments.get(key);
return val != null && val.booleanValue(); return val != null && val.booleanValue();
} }
@ -198,9 +198,8 @@ public final class CommandParameters {
* @param string the key * @param string the key
* @param value the value */ * @param value the value */
public void set(final String string, final boolean value) { public void set(final String string, final boolean value) {
if (booleanArguments.containsKey(string)) { booleanArguments.computeIfPresent(string,
booleanArguments.put(string, Boolean.valueOf(value)); (final String k, final Boolean v) -> Boolean.valueOf(value));
}
} }
/** Set a string parameter value. /** Set a string parameter value.
@ -208,6 +207,9 @@ public final class CommandParameters {
* @param string the key * @param string the key
* @param value the value */ * @param value the value */
public void set(final String string, final String value) { public void set(final String string, final String value) {
// DO NOT USE computeIfPresent. This is a HashMap, not a ConcurrentHashMap and
// keys can be associated to null, but computeIfPresent will consider them as
// absent!
if (stringArguments.containsKey(string)) { if (stringArguments.containsKey(string)) {
stringArguments.put(string, value); stringArguments.put(string, value);
} }

View File

@ -94,7 +94,7 @@ public abstract class ParametrizedCommand extends Command {
* parameters. * parameters.
* *
* @param name the name */ * @param name the name */
public ParametrizedCommand(final String name) { protected ParametrizedCommand(final String name) {
this(name, true); this(name, true);
} }
@ -106,7 +106,7 @@ public abstract class ParametrizedCommand extends Command {
* *
* @param name the name * @param name the name
* @param strict if the arguments are restricted to the declared ones */ * @param strict if the arguments are restricted to the declared ones */
public ParametrizedCommand(final String name, final boolean strict) { protected ParametrizedCommand(final String name, final boolean strict) {
super(name); super(name);
data = new ParametrizedCommandData(strict); data = new ParametrizedCommandData(strict);
} }

View File

@ -149,14 +149,16 @@ public final class ParametrizedCommandData {
* @param needed if the parameter is needed * @param needed if the parameter is needed
* @throws InvalidParameterException if the new definition is invalid */ * @throws InvalidParameterException if the new definition is invalid */
private void checkParam(final String param, final boolean needed) { private void checkParam(final String param, final boolean needed) {
final Boolean val = stringParams.get(param); final Boolean val = stringParams.computeIfPresent(param,
if (val != null) { (final String k, final Boolean v) -> {
final Boolean need = Boolean.valueOf(needed || val.booleanValue()); final Boolean need = Boolean.valueOf(needed || v.booleanValue());
stringParams.put(param, need);
params.put(param, need); params.put(param, need);
return; return need;
});
if (val == null) {
throw new InvalidParameterException(
"Parameter is already defined as boolean"); //$NON-NLS-1$
} }
throw new InvalidParameterException("Parameter is already defined as boolean"); //$NON-NLS-1$
} }
/** Retrieve the boolean parameters (aka flags). /** Retrieve the boolean parameters (aka flags).

View File

@ -105,8 +105,8 @@ public final class Messages {
try { try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args); return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
} catch (final MissingResourceException e) { } catch (final MissingResourceException e) {
LOGGER.log(Level.WARNING, LOGGER.log(Level.WARNING, e,
"Unrecognized internationalization message key: " + key, e); //$NON-NLS-1$ () -> "Unrecognized internationalization message key: " + key); //$NON-NLS-1$
return '!' + key + '!'; return '!' + key + '!';
} }
} }

View File

@ -72,7 +72,6 @@ package net.bigeon.gclc.manager;
* #L% * #L%
*/ */
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.function.Supplier; import java.util.function.Supplier;
/** A console application input. /** A console application input.
@ -94,7 +93,7 @@ public interface ConsoleInput extends AutoCloseable {
/** Indicate to the input that is should interrompt the prompting, if possible. /** Indicate to the input that is should interrompt the prompting, if possible.
* <p> * <p>
* The pending {@link #prompt()} or {@link #prompt(String)} operations should * The pending {@link #prompt()} or {@link #prompt(String)} operations should
* return immediately by throwing an InterruptedIOException. */ * return immediately by throwing an java.io.InterruptedIOException. */
void interruptPrompt(); void interruptPrompt();
/** Test if the input is closed. /** Test if the input is closed.
@ -109,7 +108,7 @@ public interface ConsoleInput extends AutoCloseable {
* *
* @return the user inputed string * @return the user inputed string
* @throws IOException if the manager is closed or could not read the prompt * @throws IOException if the manager is closed or could not read the prompt
* @throws InterruptedIOException if the prompt was interrupted */ * @throws java.io.InterruptedIOException if the prompt was interrupted */
String prompt() throws IOException; String prompt() throws IOException;
/** Prompt the user, with an allotated time to answer. /** Prompt the user, with an allotated time to answer.
@ -117,7 +116,7 @@ public interface ConsoleInput extends AutoCloseable {
* @param timeout the time to wait in milliseconds * @param timeout the time to wait in milliseconds
* @return the user inputed string, null if the timeout was reached * @return the user inputed string, null if the timeout was reached
* @throws IOException if the manager is closed or could not read the prompt * @throws IOException if the manager is closed or could not read the prompt
* @throws InterruptedIOException if the prompt was interrupted */ * @throws java.io.InterruptedIOException if the prompt was interrupted */
String prompt(long timeout) throws IOException; String prompt(long timeout) throws IOException;
/** Prompt the user, with a hint on what is prompted. /** Prompt the user, with a hint on what is prompted.
@ -125,7 +124,7 @@ public interface ConsoleInput extends AutoCloseable {
* @param message the message to prompt the user * @param message the message to prompt the user
* @return the user inputed string * @return the user inputed string
* @throws IOException if the manager is closed or could not read the prompt * @throws IOException if the manager is closed or could not read the prompt
* @throws InterruptedIOException if the prompt was interrupted */ * @throws java.io.InterruptedIOException if the prompt was interrupted */
String prompt(String message) throws IOException; String prompt(String message) throws IOException;
/** Prompt the user, with a hint on what is prompted and an allotated time to /** Prompt the user, with a hint on what is prompted and an allotated time to
@ -135,7 +134,7 @@ public interface ConsoleInput extends AutoCloseable {
* @param message the message to prompt the user * @param message the message to prompt the user
* @return the user inputed string, null if the timeout was reached * @return the user inputed string, null if the timeout was reached
* @throws IOException if the manager is closed or could not read the prompt * @throws IOException if the manager is closed or could not read the prompt
* @throws InterruptedIOException if the prompt was interrupted */ * @throws java.io.InterruptedIOException if the prompt was interrupted */
String prompt(String message, long timeout) throws IOException; String prompt(String message, long timeout) throws IOException;
/** Set a prompting prefix. /** Set a prompting prefix.

View File

@ -101,13 +101,14 @@ public final class PipedConsoleOutput implements ConsoleOutput {
private final PrintStream outPrint; private final PrintStream outPrint;
/** The reading thread. */ /** The reading thread. */
private final ReadingRunnable reading; private final ReadingRunnable reading;
private final PipedOutputStream out;
/** Create a manager that will write and read through piped stream. /** Create a manager that will write and read through piped stream.
* *
* @throws IOException if the piping failed for streams */ * @throws IOException if the piping failed for streams */
public PipedConsoleOutput() throws IOException { public PipedConsoleOutput() throws IOException {
commandOutput = new PipedInputStream(); commandOutput = new PipedInputStream();
final PipedOutputStream out = new PipedOutputStream(commandOutput); out = new PipedOutputStream(commandOutput);
commandBuffOutput = new BufferedReader( commandBuffOutput = new BufferedReader(
new InputStreamReader(commandOutput, StandardCharsets.UTF_8)); new InputStreamReader(commandOutput, StandardCharsets.UTF_8));
outPrint = new PrintStream(out, true, UTF_8); outPrint = new PrintStream(out, true, UTF_8);
@ -133,6 +134,7 @@ public final class PipedConsoleOutput implements ConsoleOutput {
reading.setRunning(false); reading.setRunning(false);
innerManager.close(); innerManager.close();
outPrint.close(); outPrint.close();
out.close();
commandBuffOutput.close(); commandBuffOutput.close();
commandOutput.close(); commandOutput.close();
} }

View File

@ -1,43 +0,0 @@
/**
*
*/
/** This package contains the {@link java.lang.Runnable} implementations used to
* forward messages to or from console output or input.
*
* @author Emmanuel Bigeon */
package net.bigeon.gclc.manager.forwarding;
/*-
* #%L
* Generic Command Ligne console
* %%
* Copyright (C) 2014 - 2018 Bigeon
* %%
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
* #L%
*/

View File

@ -36,7 +36,7 @@
* gclc:net.bigeon.gclc.tools.AOutputForwardRunnable.java * gclc:net.bigeon.gclc.tools.AOutputForwardRunnable.java
* Created on: Dec 1, 2016 * Created on: Dec 1, 2016
*/ */
package net.bigeon.gclc.manager.forwarding; package net.bigeon.gclc.tools;
/*- /*-
* #%L * #%L
@ -97,7 +97,7 @@ public abstract class AOutputForwardRunnable implements Runnable {
/** Create a forwarding runnable. /** Create a forwarding runnable.
* *
* @param manager the manager */ * @param manager the manager */
public AOutputForwardRunnable(final PipedConsoleOutput manager) { protected AOutputForwardRunnable(final PipedConsoleOutput manager) {
super(); super();
this.manager = manager; this.manager = manager;
timeout = DEFAULT_TIMEOUT; timeout = DEFAULT_TIMEOUT;
@ -116,7 +116,8 @@ public abstract class AOutputForwardRunnable implements Runnable {
* *
* @param manager the manager * @param manager the manager
* @param timeout the timeout between message requests. */ * @param timeout the timeout between message requests. */
public AOutputForwardRunnable(final PipedConsoleOutput manager, final long timeout) { protected AOutputForwardRunnable(final PipedConsoleOutput manager,
final long timeout) {
super(); super();
this.manager = manager; this.manager = manager;
this.timeout = timeout; this.timeout = timeout;
@ -156,8 +157,11 @@ public abstract class AOutputForwardRunnable implements Runnable {
/** a method to wait some time. */ /** a method to wait some time. */
protected final void waitASec() { protected final void waitASec() {
try { try {
final long tic = System.currentTimeMillis();
synchronized (this) { synchronized (this) {
wait(timeout); while (System.currentTimeMillis() - tic < timeout) {
wait(timeout + tic - System.currentTimeMillis());
}
} }
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
LOGGER.log(Level.SEVERE, "Interrupted wait", //$NON-NLS-1$ LOGGER.log(Level.SEVERE, "Interrupted wait", //$NON-NLS-1$

View File

@ -128,8 +128,11 @@ public final class ReadingRunnable implements Runnable {
* @throws IOException if the runnable was stopped and no essage was found. */ * @throws IOException if the runnable was stopped and no essage was found. */
private void doWaitMessage(final long timeout) throws IOException { private void doWaitMessage(final long timeout) throws IOException {
try { try {
final long tic = System.currentTimeMillis();
synchronized (lock) { synchronized (lock) {
lock.wait(timeout); while (System.currentTimeMillis() - tic < timeout && messages.isEmpty()) {
lock.wait(timeout);
}
} }
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
LOGGER.log(Level.SEVERE, THREAD_INTERRUPTION_EXCEPTION, e); LOGGER.log(Level.SEVERE, THREAD_INTERRUPTION_EXCEPTION, e);
@ -199,13 +202,13 @@ public final class ReadingRunnable implements Runnable {
public void waitForDelivery(final String message) throws InterruptedException { public void waitForDelivery(final String message) throws InterruptedException {
Object mLock; Object mLock;
synchronized (messageBlockerLock) { synchronized (messageBlockerLock) {
if (!messageBlocker.containsKey(message)) { messageBlocker.computeIfAbsent(message, (final String k) -> new Object());
messageBlocker.put(message, new Object());
}
mLock = messageBlocker.get(message); mLock = messageBlocker.get(message);
} }
synchronized (mLock) { synchronized (mLock) {
mLock.wait(); while (messageBlocker.containsKey(message)) {
mLock.wait();
}
} }
} }
@ -251,9 +254,9 @@ public final class ReadingRunnable implements Runnable {
final Object mLock = messageBlocker.get(message); final Object mLock = messageBlocker.get(message);
if (mLock!=null) { if (mLock!=null) {
synchronized (mLock) { synchronized (mLock) {
messageBlocker.remove(message);
mLock.notifyAll(); mLock.notifyAll();
} }
messageBlocker.remove(message);
} }
} }
} }

View File

@ -71,11 +71,7 @@ package net.bigeon.gclc;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;

View File

@ -72,7 +72,6 @@ package net.bigeon.gclc;
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.util.List; import java.util.List;
@ -87,52 +86,77 @@ import net.bigeon.gclc.exception.CommandParsingException;
@SuppressWarnings({ "nls", "static-method" }) @SuppressWarnings({ "nls", "static-method" })
public class GCLCConstantsTest { public class GCLCConstantsTest {
@Test
public void testSplitCommandSingle() throws CommandParsingException {
List<String> res;
res = GCLCConstants.splitCommand("aCommand");
assertEquals("single word command should have one element", 1, res.size());
assertEquals("Command should be preserved", "aCommand", res.get(0));
}
@Test
public void testSplitCommandSeveral() throws CommandParsingException {
List<String> res;
res = GCLCConstants.splitCommand("aCommand with some arguments");
assertEquals("Command size", 4, res.size());
assertEquals("Elements should be preserved", "aCommand", res.get(0));
assertEquals("Command should be preserved", "with", res.get(1));
assertEquals("Command should be preserved", "some", res.get(2));
assertEquals("Command should be preserved", "arguments", res.get(3));
}
/** Test method for /** Test method for
* {@link net.bigeon.gclc.GCLCConstants#splitCommand(java.lang.String)}. * {@link net.bigeon.gclc.GCLCConstants#splitCommand(java.lang.String)}.
* *
* @throws CommandParsingException if an error occured */ * @throws CommandParsingException if an error occured */
@Test @Test
public void testSplitCommand() throws CommandParsingException { public void testSplitCommandMultiSpaces() throws CommandParsingException {
List<String> res; List<String> res;
res = GCLCConstants.splitCommand("aCommand");
assertTrue("single word command should have one element", res.size() == 1);
assertTrue("Command should be preserved", res.get(0).equals("aCommand"));
res = GCLCConstants.splitCommand("aCommand with some arguments");
assertEquals("Command size", 4, res.size());
assertEquals("Elements should be preserved", "aCommand", res.get(0));
assertTrue("Elements should be preserved", res.get(1).equals("with"));
assertTrue("Elements should be preserved", res.get(2).equals("some"));
assertTrue("Elements should be preserved", res.get(3).equals("arguments"));
res = GCLCConstants.splitCommand("aCommand with some arguments"); res = GCLCConstants.splitCommand("aCommand with some arguments");
assertEquals("Command size", 4, res.size()); assertEquals("Command size", 4, res.size());
assertTrue("Elements should be preserved", res.get(0).equals("aCommand")); assertEquals("Command should be preserved", "aCommand", res.get(0));
assertTrue("Elements should be preserved", res.get(1).equals("with")); assertEquals("Command should be preserved", "with", res.get(1));
assertTrue("Elements should be preserved", res.get(2).equals("some")); assertEquals("Command should be preserved", "some", res.get(2));
assertTrue("Elements should be preserved", res.get(3).equals("arguments")); assertEquals("Command should be preserved", "arguments", res.get(3));
}
public void testSplitCommandWithString() throws CommandParsingException {
List<String> res;
res = GCLCConstants.splitCommand("aCommand \"with some\" arguments"); res = GCLCConstants.splitCommand("aCommand \"with some\" arguments");
assertEquals("Command size", 3, res.size()); assertEquals("Command size", 3, res.size());
assertTrue("Elements should be preserved", res.get(0).equals("aCommand")); assertEquals("Command should be preserved", "aCommand", res.get(0));
assertTrue("Elements should be preserved", res.get(1).equals("with some")); assertEquals("Command should be preserved", "with some", res.get(1));
assertTrue("Elements should be preserved", res.get(2).equals("arguments")); assertEquals("Command should be preserved", "arguments", res.get(2));
res = GCLCConstants.splitCommand("aCommand with\\ some arguments");
assertEquals("Command size", 3, res.size());
assertTrue("Elements should be preserved", res.get(0).equals("aCommand"));
assertTrue("Elements should be preserved", res.get(1).equals("with some"));
assertTrue("Elements should be preserved", res.get(2).equals("arguments"));
res = GCLCConstants.splitCommand("aCommand wi\\\"th some arguments");
assertEquals("Command size", 4, res.size());
assertTrue("Elements should be preserved", res.get(0).equals("aCommand"));
assertTrue("Elements should be preserved", res.get(1).equals("wi\"th"));
assertTrue("Elements should be preserved", res.get(2).equals("some"));
assertTrue("Elements should be preserved", res.get(3).equals("arguments"));
res = GCLCConstants.splitCommand("aCommand with \"some arguments\""); res = GCLCConstants.splitCommand("aCommand with \"some arguments\"");
assertEquals("Command size", 3, res.size()); assertEquals("Command size", 3, res.size());
assertTrue("Elements should be preserved", res.get(0).equals("aCommand")); assertEquals("Command should be preserved", "aCommand", res.get(0));
assertTrue("Elements should be preserved", res.get(1).equals("with")); assertEquals("Command should be preserved", "with", res.get(1));
assertTrue("Elements should be preserved", res.get(2).equals("some arguments")); assertEquals("Command should be preserved", "some arguments", res.get(2));
}
public void testSplitCommandWithEscape() throws CommandParsingException {
List<String> res;
res = GCLCConstants.splitCommand("aCommand with\\ some arguments");
assertEquals("Command size", 3, res.size());
assertEquals("Command should be preserved", "aCommand", res.get(0));
assertEquals("Command should be preserved", "with some", res.get(1));
assertEquals("Command should be preserved", "arguments", res.get(2));
}
public void testSplitCommandWithQuoteInString() throws CommandParsingException {
List<String> res;
res = GCLCConstants.splitCommand("aCommand wi\\\"th some arguments");
assertEquals("Command size", 4, res.size());
assertEquals("Command should be preserved", "aCommand", res.get(0));
assertEquals("Command should be preserved", "wi\"th", res.get(1));
assertEquals("Command should be preserved", "some", res.get(2));
assertEquals("Command should be preserved", "arguments", res.get(3));
}
public void testSplitCommandInvalidQuoting() throws CommandParsingException {
List<String> res;
try { try {
// Wrong lines? // Wrong lines?
res = GCLCConstants.splitCommand("aCommand with \"some ar\"guments"); res = GCLCConstants.splitCommand("aCommand with \"some ar\"guments");

View File

@ -71,11 +71,7 @@ package net.bigeon.gclc.command;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;

View File

@ -33,8 +33,7 @@ package net.bigeon.gclc.command;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.fail;
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;

View File

@ -71,11 +71,7 @@ package net.bigeon.gclc.command;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -93,10 +89,10 @@ import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.manager.ConsoleOutput; import net.bigeon.gclc.manager.ConsoleOutput;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.test.junitmt.ATestRunnable;
import net.bigeon.test.junitmt.FunctionalTestRunnable; import net.bigeon.test.junitmt.FunctionalTestRunnable;
import net.bigeon.test.junitmt.TestFunction;
import net.bigeon.test.junitmt.ThreadTest; import net.bigeon.test.junitmt.ThreadTest;
import net.bigeon.test.junitmt.api.ATestRunnable;
import net.bigeon.test.junitmt.api.TestFunction;
/** /**
* <p> * <p>
@ -513,21 +509,18 @@ public class ParametrizedCommandTest {
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);
final TestFunction function = new TestFunction() { final TestFunction function = () -> {
assertEquals("value of " + str1 + "? ", buf.readLine());
@Override in.type("");
public void apply() throws Exception { assertEquals("value of " + str1 + "? (cannot be empty) ",
assertEquals("value of " + str1 + "? ", buf.readLine()); buf.readLine());
in.type(""); in.type("");
assertEquals("value of " + str1 + "? (cannot be empty) ", assertEquals("value of " + str1 + "? (cannot be empty) ",
buf.readLine()); buf.readLine());
in.type(""); in.type(str2);
assertEquals("value of " + str1 + "? (cannot be empty) ",
buf.readLine());
in.type(str2);
}
}; };
final ATestRunnable testConsole = new FunctionalTestRunnable(function); final FunctionalTestRunnable testConsole = new FunctionalTestRunnable(
function);
final Thread th = new Thread(testConsole); final Thread th = new Thread(testConsole);
th.start(); th.start();
@ -543,13 +536,9 @@ public class ParametrizedCommandTest {
new InputStreamReader(pis, StandardCharsets.UTF_8)); new InputStreamReader(pis, StandardCharsets.UTF_8));
PipedConsoleInput in = new PipedConsoleInput(new PrintStream(pout))) { PipedConsoleInput in = new PipedConsoleInput(new PrintStream(pout))) {
final TestFunction function = new TestFunction() { final TestFunction function = () -> {
assertEquals("value of " + str1 + "? ", buf.readLine());
@Override in.type(str2);
public void apply() throws Exception {
assertEquals("value of " + str1 + "? ", buf.readLine());
in.type(str2);
}
}; };
final ATestRunnable testConsole = new FunctionalTestRunnable(function); final ATestRunnable testConsole = new FunctionalTestRunnable(function);
@ -565,7 +554,6 @@ public class ParametrizedCommandTest {
final PipedConsoleInput test = new PipedConsoleInput(null); final PipedConsoleInput test = new PipedConsoleInput(null);
test.close(); test.close();
out.close(); out.close();
cmd.execute(out, test, "-" + str1, str2);
cmd.execute(out, test, "-" + addParam); cmd.execute(out, test, "-" + addParam);
fail("Closed manager shall cause error"); fail("Closed manager shall cause error");
} catch (final CommandRunException e) { } catch (final CommandRunException e) {

View File

@ -71,10 +71,7 @@ package net.bigeon.gclc.command;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;

View File

@ -92,8 +92,8 @@ import org.junit.Test;
import net.bigeon.gclc.utils.ReadingRunnable; import net.bigeon.gclc.utils.ReadingRunnable;
import net.bigeon.test.junitmt.FunctionalTestRunnable; import net.bigeon.test.junitmt.FunctionalTestRunnable;
import net.bigeon.test.junitmt.TestFunction;
import net.bigeon.test.junitmt.ThreadTest; import net.bigeon.test.junitmt.ThreadTest;
import net.bigeon.test.junitmt.api.TestFunction;
/** /**
* <p> * <p>

View File

@ -71,10 +71,7 @@ package net.bigeon.gclc.manager;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -71,10 +71,7 @@ package net.bigeon.gclc.prompt;
* knowledge of the CeCILL license and that you accept its terms. * knowledge of the CeCILL license and that you accept its terms.
* #L% * #L%
*/ */
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -94,10 +91,10 @@ import org.junit.Test;
import net.bigeon.gclc.manager.PipedConsoleInput; import net.bigeon.gclc.manager.PipedConsoleInput;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.test.junitmt.ATestRunnable;
import net.bigeon.test.junitmt.FunctionalTestRunnable; import net.bigeon.test.junitmt.FunctionalTestRunnable;
import net.bigeon.test.junitmt.TestFunction;
import net.bigeon.test.junitmt.ThreadTest; import net.bigeon.test.junitmt.ThreadTest;
import net.bigeon.test.junitmt.api.ATestRunnable;
import net.bigeon.test.junitmt.api.TestFunction;
/** /**
* <p> * <p>

View File

@ -78,7 +78,6 @@ import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import net.bigeon.gclc.manager.PipedConsoleOutput; import net.bigeon.gclc.manager.PipedConsoleOutput;
import net.bigeon.gclc.manager.forwarding.AOutputForwardRunnable;
/** /**
* <p> * <p>
@ -143,7 +142,7 @@ public class AOutputForwardRunnableTest {
} }
/** Test method for /** Test method for
* {@link net.bigeon.gclc.manager.forwarding.AOutputForwardRunnable#run()}. */ * {@link net.bigeon.gclc.tools.AOutputForwardRunnable#run()}. */
@Test @Test
public final void testRun() { public final void testRun() {
try (PipedConsoleOutput manager = new PipedConsoleOutput()) { try (PipedConsoleOutput manager = new PipedConsoleOutput()) {