Move UDPTest

This commit is contained in:
Grzegorz Piwowarek
2016-10-25 17:11:25 +02:00
parent 89b50437be
commit c9f858ca32

View File

@@ -0,0 +1,37 @@
package com.baeldung.java.networking.url;
import com.baeldung.java.networking.udp.EchoClient;
import com.baeldung.java.networking.udp.EchoServer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
public class UDPTest {
private EchoClient client;
@Before
public void setup() throws IOException {
new EchoServer().start();
client = new EchoClient();
}
@Test
public void whenCanSendAndReceivePacket_thenCorrect1() {
String echo = client.sendEcho("hello server");
assertEquals("hello server", echo);
echo = client.sendEcho("server is working");
assertFalse(echo.equals("hello server"));
}
@After
public void tearDown() {
client.sendEcho("end");
client.close();
}
}