ClientTestCase.java 851 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package client;
  2. import static org.junit.Assert.*;
  3. import org.junit.AfterClass;
  4. import org.junit.BeforeClass;
  5. import org.junit.Test;
  6. import server.Server;
  7. public class ClientTestCase {
  8. public static ChatWindow user1;
  9. public static ChatWindow user2;
  10. static Thread runServer = new Thread(){
  11. @Override
  12. public void run() {
  13. Server.main(new String[]{});
  14. }
  15. };
  16. @BeforeClass
  17. public static void setUpClass() {
  18. runServer.start();
  19. user1 = new ChatWindow("localhost", 25566, "user1");
  20. assertTrue(user1.so.isConnected());
  21. }
  22. @Test
  23. public void testSend() {
  24. user1.send("Hello!");
  25. }
  26. @Test
  27. public void testPM() {
  28. user2 = new ChatWindow("localhost", 25566, "user2");
  29. user1.send("/pm user2 Hi there user2!");
  30. }
  31. @AfterClass
  32. public static void tearDownClass() {
  33. Server.exit();
  34. }
  35. }