fixed failing tests
This commit is contained in:
parent
7c0056270a
commit
e71fcf4ef7
@ -14,46 +14,44 @@ public class EchoMultiTest {
|
|||||||
Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(5555));
|
Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(5555));
|
||||||
}
|
}
|
||||||
|
|
||||||
EchoClient client = new EchoClient();
|
|
||||||
|
|
||||||
@Before
|
@Test
|
||||||
public void init() {
|
public void givenClient1_whenServerResponds_thenCorrect() {
|
||||||
|
EchoClient client = new EchoClient();
|
||||||
client.startConnection("127.0.0.1", 5555);
|
client.startConnection("127.0.0.1", 5555);
|
||||||
}
|
String msg1 = client.sendMessage("hello");
|
||||||
|
String msg2 = client.sendMessage("world");
|
||||||
@After
|
String terminate = client.sendMessage(".");
|
||||||
public void finish(){
|
assertEquals(msg1, "hello");
|
||||||
|
assertEquals(msg2, "world");
|
||||||
|
assertEquals(terminate, "bye");
|
||||||
client.stopConnection();
|
client.stopConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenClient1_whenServerResponds_thenCorrect() {
|
|
||||||
String msg1 = client.sendMessage("hello");
|
|
||||||
String msg2 = client.sendMessage("world");
|
|
||||||
String terminate = client.sendMessage(".");
|
|
||||||
assertEquals(msg1, "hello");
|
|
||||||
assertEquals(msg2, "world");
|
|
||||||
assertEquals(terminate, "bye");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenClient2_whenServerResponds_thenCorrect() {
|
public void givenClient2_whenServerResponds_thenCorrect() {
|
||||||
|
EchoClient client = new EchoClient();
|
||||||
|
client.startConnection("127.0.0.1", 5555);
|
||||||
String msg1 = client.sendMessage("hello");
|
String msg1 = client.sendMessage("hello");
|
||||||
String msg2 = client.sendMessage("world");
|
String msg2 = client.sendMessage("world");
|
||||||
String terminate = client.sendMessage(".");
|
String terminate = client.sendMessage(".");
|
||||||
assertEquals(msg1, "hello");
|
assertEquals(msg1, "hello");
|
||||||
assertEquals(msg2, "world");
|
assertEquals(msg2, "world");
|
||||||
assertEquals(terminate, "bye");
|
assertEquals(terminate, "bye");
|
||||||
|
client.stopConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenClient3_whenServerResponds_thenCorrect() {
|
public void givenClient3_whenServerResponds_thenCorrect() {
|
||||||
|
EchoClient client = new EchoClient();
|
||||||
|
client.startConnection("127.0.0.1", 5555);
|
||||||
String msg1 = client.sendMessage("hello");
|
String msg1 = client.sendMessage("hello");
|
||||||
String msg2 = client.sendMessage("world");
|
String msg2 = client.sendMessage("world");
|
||||||
String terminate = client.sendMessage(".");
|
String terminate = client.sendMessage(".");
|
||||||
assertEquals(msg1, "hello");
|
assertEquals(msg1, "hello");
|
||||||
assertEquals(msg2, "world");
|
assertEquals(msg2, "world");
|
||||||
assertEquals(terminate, "bye");
|
assertEquals(terminate, "bye");
|
||||||
|
client.stopConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,23 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class EchoTest {
|
public class EchoTest {
|
||||||
EchoClient client = null;
|
{
|
||||||
|
Executors.newSingleThreadExecutor().submit(() -> new EchoServer().start(4444));
|
||||||
|
}
|
||||||
|
|
||||||
|
EchoClient client = new EchoClient();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void init() {
|
||||||
client = new EchoClient();
|
|
||||||
client.startConnection("127.0.0.1", 4444);
|
client.startConnection("127.0.0.1", 4444);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test @Ignore
|
@Test
|
||||||
public void givenClient_whenServerEchosMessage_thenCorrect() {
|
public void givenClient_whenServerEchosMessage_thenCorrect() {
|
||||||
|
|
||||||
String resp1 = client.sendMessage("hello");
|
String resp1 = client.sendMessage("hello");
|
||||||
|
@ -19,11 +19,12 @@ public class GreetServerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
client = new GreetClient();
|
client = new GreetClient();
|
||||||
|
client.startConnection("127.0.0.1", 6666);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenGreetingClient_whenServerRespondsWhenStarted_thenCorrect() {
|
public void givenGreetingClient_whenServerRespondsWhenStarted_thenCorrect() {
|
||||||
client.startConnection("127.0.0.1", 6666);
|
|
||||||
String response = client.sendMessage("hello server");
|
String response = client.sendMessage("hello server");
|
||||||
assertEquals("hello client", response);
|
assertEquals("hello client", response);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user