Removed unreachable code, set test output in fine grain logging
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
f3c3580855
commit
d07795cb6a
@ -203,12 +203,6 @@ public class SocketConsoleApplicationShell implements Runnable {
|
||||
BufferedReader inBuf = new BufferedReader(isr)) {
|
||||
consoleInput.connect(outStream);
|
||||
runSokectServer();
|
||||
// Close the application
|
||||
// Pass command to application
|
||||
if (app.isRunning()) {
|
||||
writer.write(applicationShutdown + EOL);
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
} catch (
|
||||
|
||||
@ -278,7 +272,8 @@ public class SocketConsoleApplicationShell implements Runnable {
|
||||
* @throws IOException if the communication failed */
|
||||
private void communicate(final Socket socket, final PrintWriter writer,
|
||||
BufferedReader in) throws IOException {
|
||||
Thread th = new Thread(new OutputForwardRunnable(writer, socket), "ClientComm"); //$NON-NLS-1$
|
||||
Thread th = new Thread(new OutputForwardRunnable(writer, socket),
|
||||
"ClientComm"); //$NON-NLS-1$
|
||||
th.start();
|
||||
if (autoClose) {
|
||||
communicateOnce(socket, in);
|
||||
@ -295,9 +290,7 @@ public class SocketConsoleApplicationShell implements Runnable {
|
||||
ReadingRunnable reading = new ReadingRunnable(in);
|
||||
Thread th = new Thread(reading, "gclcToApp"); //$NON-NLS-1$
|
||||
th.start();
|
||||
if (app.isRunning()) {
|
||||
communicationContent(reading);
|
||||
}
|
||||
communicationContent(reading);
|
||||
reading.setRunning(false);
|
||||
socket.shutdownOutput();
|
||||
}
|
||||
|
@ -48,20 +48,18 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import fr.bigeon.smu.StringEncoder;
|
||||
|
||||
/** Test class for {@link SocketConsoleApplicationShell}
|
||||
*
|
||||
* @author Emmanuel Bigeon */
|
||||
@SuppressWarnings({"static-method", "unused", "javadoc", "nls"})
|
||||
public class SocketConsoleApplicationTest {
|
||||
|
||||
private static final StringEncoder ENCODER = new StringEncoder("%",
|
||||
Arrays.asList("\n")); //$NON-NLS-1$
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(SocketConsoleApplicationTest.class.getName());
|
||||
|
||||
@Test
|
||||
public void integrationTest() {
|
||||
@ -90,14 +88,14 @@ public class SocketConsoleApplicationTest {
|
||||
int i = 0;
|
||||
String[] cmds = {"help", "toto", "test", "bye"};
|
||||
while ((fromServer = in.readLine()) != null) {
|
||||
System.out.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
LOGGER.fine("Server: \n" + fromServer);
|
||||
if (fromServer.equals("Bye.")) {
|
||||
break;
|
||||
}
|
||||
while (fromServer != null && !fromServer.equals("> ")) {
|
||||
fromServer = in.readLine();
|
||||
System.out
|
||||
.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
.println("Server: \n" + fromServer);
|
||||
}
|
||||
if (fromServer == null) {
|
||||
fail("Null pointer");
|
||||
@ -105,7 +103,7 @@ public class SocketConsoleApplicationTest {
|
||||
|
||||
final String fromUser = cmds[i];
|
||||
if (fromUser != null) {
|
||||
System.out.println("Client: " + fromUser);
|
||||
LOGGER.fine("Client: " + fromUser);
|
||||
out.println(fromUser);
|
||||
}
|
||||
i++;
|
||||
@ -126,20 +124,20 @@ public class SocketConsoleApplicationTest {
|
||||
String[] cmds = {"help", "toto", "test",
|
||||
ConsoleTestApplication.EXIT};
|
||||
while ((fromServer = in.readLine()) != null) {
|
||||
System.out.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
LOGGER.fine("Server: \n" + fromServer);
|
||||
while (fromServer != null && !fromServer.equals("> ")) {
|
||||
System.out
|
||||
.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
.println("Server: \n" + fromServer);
|
||||
fromServer = in.readLine();
|
||||
}
|
||||
if (fromServer == null) {
|
||||
break;
|
||||
}
|
||||
System.out.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
LOGGER.fine("Server: \n" + fromServer);
|
||||
|
||||
final String fromUser = cmds[i];
|
||||
if (fromUser != null) {
|
||||
System.out.println("Client: " + fromUser);
|
||||
LOGGER.fine("Client: " + fromUser);
|
||||
out.println(fromUser);
|
||||
}
|
||||
i++;
|
||||
@ -168,7 +166,7 @@ public class SocketConsoleApplicationTest {
|
||||
while (fromServer != null && !fromServer.equals("> ")) {
|
||||
fromServer = in.readLine();
|
||||
System.out
|
||||
.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
.println("Server: \n" + fromServer);
|
||||
}
|
||||
if (fromServer == null) {
|
||||
break;
|
||||
@ -176,7 +174,7 @@ public class SocketConsoleApplicationTest {
|
||||
|
||||
final String fromUser = cmds[i];
|
||||
if (fromUser != null) {
|
||||
System.out.println("Client: " + fromUser);
|
||||
LOGGER.fine("Client: " + fromUser);
|
||||
out.println(fromUser);
|
||||
}
|
||||
i++;
|
||||
@ -217,7 +215,7 @@ public class SocketConsoleApplicationTest {
|
||||
!fromServer.equals("See you")) {
|
||||
fromServer = in.readLine();
|
||||
System.out
|
||||
.println("Server: \n" + ENCODER.decode(fromServer));
|
||||
.println("Server: \n" + fromServer);
|
||||
}
|
||||
if (fromServer == null || fromServer.equals("Bye.") ||
|
||||
fromServer.equals("See you")) {
|
||||
@ -226,7 +224,7 @@ public class SocketConsoleApplicationTest {
|
||||
|
||||
final String fromUser = cmds[i];
|
||||
if (fromUser != null) {
|
||||
System.out.println("Client: " + fromUser);
|
||||
LOGGER.fine("Client: " + fromUser);
|
||||
out.println(fromUser);
|
||||
}
|
||||
i++;
|
||||
|
Loading…
Reference in New Issue
Block a user