Refactor examples

This commit is contained in:
Grzegorz Piwowarek 2016-10-23 11:57:11 +02:00
parent 8031458265
commit 65daa3aee2
6 changed files with 8 additions and 10 deletions

View File

@ -23,8 +23,7 @@ public class EchoClient {
public String sendMessage(String msg) {
try {
out.println(msg);
String resp = in.readLine();
return resp;
return in.readLine();
} catch (Exception e) {
return null;
}

View File

@ -46,7 +46,7 @@ public class EchoMultiServer {
clientSocket.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
if ("".equals(inputLine)) {
if (".".equals(inputLine)) {
out.println("bye");
break;
}

View File

@ -18,7 +18,7 @@ public class EchoServer {
clientSocket.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
if ("".equals(inputLine)) {
if (".".equals(inputLine)) {
out.println("good bye");
break;
}

View File

@ -26,8 +26,7 @@ public class GreetClient {
public String sendMessage(String msg) {
try {
out.println(msg);
String resp = in.readLine();
return resp;
return in.readLine();
} catch (Exception e) {
return null;
}

View File

@ -23,7 +23,7 @@ public class EchoMultiTest {
client.startConnection("127.0.0.1", PORT);
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage("");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
@ -37,7 +37,7 @@ public class EchoMultiTest {
client.startConnection("127.0.0.1", PORT);
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage("");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
assertEquals(terminate, "bye");
@ -50,7 +50,7 @@ public class EchoMultiTest {
client.startConnection("127.0.0.1", PORT);
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage("");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
assertEquals(terminate, "bye");

View File

@ -31,7 +31,7 @@ public class EchoTest {
String resp1 = client.sendMessage("hello");
String resp2 = client.sendMessage("world");
String resp3 = client.sendMessage("!");
String resp4 = client.sendMessage("");
String resp4 = client.sendMessage(".");
assertEquals("hello", resp1);
assertEquals("world", resp2);
assertEquals("!", resp3);