Upgrade dependency on gclc, fixed test.
This commit is contained in:
parent
201b6ad366
commit
063cad61cd
@ -81,7 +81,7 @@ of Emmanuel Bigeon. -->
|
||||
<dependency>
|
||||
<groupId>fr.bigeon</groupId>
|
||||
<artifactId>gclc</artifactId>
|
||||
<version>1.3.3</version>
|
||||
<version>1.3.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.bigeon</groupId>
|
||||
|
@ -240,7 +240,7 @@ public class SocketConsoleApplicationShell implements Runnable, AutoCloseable {
|
||||
consoleManager.close();
|
||||
} catch (IOException e) {
|
||||
LOGGER.warning("Unable to close application correctly"); //$NON-NLS-1$
|
||||
LOGGER.log(Level.FINE, "Application closing caused an exception",
|
||||
LOGGER.log(Level.FINE, "Application closing caused an exception", //$NON-NLS-1$
|
||||
e);
|
||||
}
|
||||
LOGGER.info("Closing Server"); //$NON-NLS-1$
|
||||
@ -271,17 +271,15 @@ public class SocketConsoleApplicationShell implements Runnable, AutoCloseable {
|
||||
Thread th = new Thread(cc, "ClientComm"); //$NON-NLS-1$
|
||||
th.start();
|
||||
if (autoClose) {
|
||||
communicateOnce(socket, in);
|
||||
communicateOnce(in);
|
||||
} else {
|
||||
communicateLoop(socket, in);
|
||||
communicateLoop(in);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param socket the socket
|
||||
* @param in the input from the client
|
||||
/** @param in the input from the client
|
||||
* @throws IOException if the communication failed */
|
||||
private void communicateOnce(Socket socket,
|
||||
BufferedReader in) throws IOException {
|
||||
private void communicateOnce(BufferedReader in) throws IOException {
|
||||
ReadingRunnable reading = new ReadingRunnable(in);
|
||||
Thread th = new Thread(reading, "gclcToApp"); //$NON-NLS-1$
|
||||
th.start();
|
||||
@ -303,11 +301,9 @@ public class SocketConsoleApplicationShell implements Runnable, AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param socket the socket
|
||||
* @param in the input from the client
|
||||
/** @param in the input from the client
|
||||
* @throws IOException if the communication failed */
|
||||
private void communicateLoop(Socket socket,
|
||||
BufferedReader in) throws IOException {
|
||||
private void communicateLoop(BufferedReader in) throws IOException {
|
||||
ReadingRunnable reading = new ReadingRunnable(in);
|
||||
Thread th = new Thread(reading, "gclcToApp"); //$NON-NLS-1$
|
||||
th.start();
|
||||
|
@ -51,7 +51,7 @@
|
||||
<dependency>
|
||||
<groupId>fr.bigeon</groupId>
|
||||
<artifactId>gclc</artifactId>
|
||||
<version>1.3.3</version>
|
||||
<version>1.3.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.bigeon</groupId>
|
||||
|
@ -39,21 +39,23 @@
|
||||
package fr.bigeon.gclc.manager;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
/** <p>
|
||||
* TODO
|
||||
*
|
||||
* @author Emmanuel Bigeon
|
||||
*
|
||||
*/
|
||||
* @author Emmanuel Bigeon */
|
||||
public class ReadingRunnableTest {
|
||||
|
||||
/**
|
||||
@ -61,11 +63,10 @@ public class ReadingRunnableTest {
|
||||
@Before
|
||||
public void setUp() {}
|
||||
|
||||
/**
|
||||
* Test method for {@link fr.bigeon.gclc.manager.ReadingRunnable#getMessage()}.
|
||||
*/
|
||||
/** Test method for
|
||||
* {@link fr.bigeon.gclc.manager.ReadingRunnable#getMessage()}. */
|
||||
@Test
|
||||
public final void testGetMessage(){
|
||||
public final void testGetMessage() {
|
||||
BufferedReader reader = null;
|
||||
ReadingRunnable runnable = new ReadingRunnable(reader);
|
||||
runnable.setRunning(false);
|
||||
@ -79,11 +80,10 @@ public class ReadingRunnableTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link fr.bigeon.gclc.manager.ReadingRunnable#hasMessage()}.
|
||||
*/
|
||||
/** Test method for
|
||||
* {@link fr.bigeon.gclc.manager.ReadingRunnable#hasMessage()}. */
|
||||
@Test
|
||||
public final void testHasMessage(){
|
||||
public final void testHasMessage() {
|
||||
|
||||
BufferedReader reader = null;
|
||||
ReadingRunnable runnable = new ReadingRunnable(reader);
|
||||
@ -97,11 +97,53 @@ public class ReadingRunnableTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link fr.bigeon.gclc.manager.ReadingRunnable#getWaitForDelivery(java.lang.String)}.
|
||||
*/
|
||||
/** Test method for
|
||||
* {@link fr.bigeon.gclc.manager.ReadingRunnable#getWaitForDelivery(java.lang.String)}.
|
||||
*
|
||||
* @throws InterruptedException */
|
||||
@Test
|
||||
public final void testGetWaitForDelivery(){
|
||||
public final void testGetWaitForDelivery() throws InterruptedException {
|
||||
try (PipedOutputStream out = new PipedOutputStream();
|
||||
InputStream piped = new PipedInputStream(out);
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(piped, "UTF-8"))) {
|
||||
final ReadingRunnable runnable = new ReadingRunnable(reader);
|
||||
Thread th0 = new Thread(runnable, "read");
|
||||
th0.start();
|
||||
Thread th = runnable.getWaitForDelivery("");
|
||||
|
||||
final Object start = new Object();
|
||||
|
||||
Thread th2 = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (start) {
|
||||
start.notify();
|
||||
}
|
||||
try {
|
||||
runnable.getMessage();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, "get");
|
||||
synchronized (start) {
|
||||
th2.start();
|
||||
start.wait();
|
||||
}
|
||||
runnable.interrupt();
|
||||
try {
|
||||
th.join();
|
||||
} catch (InterruptedException e) {
|
||||
assertNull(e);
|
||||
}
|
||||
runnable.setRunning(false);
|
||||
out.close();
|
||||
} catch (IOException e1) {
|
||||
assertNull(e1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user