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:
commit
b4f05d4f6f
|
@ -40,8 +40,8 @@ public class AsyncEchoClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String sendMessage(String message) throws ExecutionException, InterruptedException {
|
public String sendMessage(String message) throws Exception {
|
||||||
byte[] byteMsg = new String(message).getBytes();
|
byte[] byteMsg = message.getBytes();
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(byteMsg);
|
ByteBuffer buffer = ByteBuffer.wrap(byteMsg);
|
||||||
Future<Integer> writeResult = client.write(buffer);
|
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();
|
AsyncEchoClient client = AsyncEchoClient.getInstance();
|
||||||
client.start();
|
client.start();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.baeldung.java.nio2.async;
|
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.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class AsyncEchoTest {
|
public class AsyncEchoTest {
|
||||||
|
|
||||||
Process server;
|
Process server;
|
||||||
|
@ -21,7 +20,7 @@ public class AsyncEchoTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenServerClient_whenServerEchosMessage_thenCorrect() throws ExecutionException, InterruptedException {
|
public void givenServerClient_whenServerEchosMessage_thenCorrect() throws Exception {
|
||||||
String resp1 = client.sendMessage("hello");
|
String resp1 = client.sendMessage("hello");
|
||||||
String resp2 = client.sendMessage("world");
|
String resp2 = client.sendMessage("world");
|
||||||
assertEquals("hello", resp1);
|
assertEquals("hello", resp1);
|
||||||
|
|
Loading…
Reference in New Issue