Merge pull request #634 from egimaben/master

fixed failing tests
This commit is contained in:
Alex Theedom 2016-08-24 21:00:20 +01:00 committed by GitHub
commit 0e1d0b4092
3 changed files with 25 additions and 22 deletions

View File

@ -14,46 +14,44 @@ public class EchoMultiTest {
Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(5555));
}
EchoClient client = new EchoClient();
@Before
public void init() {
@Test
public void givenClient1_whenServerResponds_thenCorrect() {
EchoClient client = new EchoClient();
client.startConnection("127.0.0.1", 5555);
}
@After
public void finish(){
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
assertEquals(terminate, "bye");
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
public void givenClient2_whenServerResponds_thenCorrect() {
EchoClient client = new EchoClient();
client.startConnection("127.0.0.1", 5555);
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
assertEquals(terminate, "bye");
client.stopConnection();
}
@Test
public void givenClient3_whenServerResponds_thenCorrect() {
EchoClient client = new EchoClient();
client.startConnection("127.0.0.1", 5555);
String msg1 = client.sendMessage("hello");
String msg2 = client.sendMessage("world");
String terminate = client.sendMessage(".");
assertEquals(msg1, "hello");
assertEquals(msg2, "world");
assertEquals(terminate, "bye");
client.stopConnection();
}
}

View File

@ -4,19 +4,23 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.concurrent.Executors;
import static org.junit.Assert.assertEquals;
public class EchoTest {
EchoClient client = null;
{
Executors.newSingleThreadExecutor().submit(() -> new EchoServer().start(4444));
}
EchoClient client = new EchoClient();
@Before
public void setup() {
client = new EchoClient();
public void init() {
client.startConnection("127.0.0.1", 4444);
}
@Test @Ignore
@Test
public void givenClient_whenServerEchosMessage_thenCorrect() {
String resp1 = client.sendMessage("hello");

View File

@ -19,11 +19,12 @@ public class GreetServerTest {
@Before
public void init() {
client = new GreetClient();
client.startConnection("127.0.0.1", 6666);
}
@Test
public void givenGreetingClient_whenServerRespondsWhenStarted_thenCorrect() {
client.startConnection("127.0.0.1", 6666);
String response = client.sendMessage("hello server");
assertEquals("hello client", response);
}