Merge remote-tracking branch 'origin/master'

Conflicts:
	core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoClient.java
	core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoTest.java
This commit is contained in:
slavisa-baeldung 2016-12-03 11:11:16 +01:00
commit b4f05d4f6f
2 changed files with 8 additions and 9 deletions

View File

@ -40,8 +40,8 @@ public class AsyncEchoClient {
}
}
public String sendMessage(String message) throws ExecutionException, InterruptedException {
byte[] byteMsg = new String(message).getBytes();
public String sendMessage(String message) throws Exception {
byte[] byteMsg = message.getBytes();
ByteBuffer buffer = ByteBuffer.wrap(byteMsg);
Future<Integer> writeResult = client.write(buffer);
@ -65,7 +65,7 @@ public class AsyncEchoClient {
}
}
public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
public static void main(String[] args) throws Exception {
AsyncEchoClient client = AsyncEchoClient.getInstance();
client.start();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

View File

@ -1,14 +1,13 @@
package com.baeldung.java.nio2.async;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
public class AsyncEchoTest {
Process server;
@ -21,7 +20,7 @@ public class AsyncEchoTest {
}
@Test
public void givenServerClient_whenServerEchosMessage_thenCorrect() throws ExecutionException, InterruptedException {
public void givenServerClient_whenServerEchosMessage_thenCorrect() throws Exception {
String resp1 = client.sendMessage("hello");
String resp2 = client.sendMessage("world");
assertEquals("hello", resp1);