Ejemplo n.º 1
0
 /**
  * Tests the client manager by adding different clients with the same output stream, but different
  * nicknames.
  */
 @Test
 public void testAddClientsWithDifferentNames() {
   ClientManager manager = new ClientManager();
   Client client1 = new Client("client1", System.out);
   Client client2 = new Client("clientd2", System.out);
   Client client3 = new Client("clientr3", System.out);
   Client client4 = new Client("client4", System.out);
   Client client5 = new Client("client5", System.out);
   manager.addClient(client1);
   manager.addClient(client2);
   manager.addClient(client3);
   manager.addClient(client4);
   manager.addClient(client5);
   Set<Client> clients = manager.getClients();
   assertEquals(6, clients.size());
 }
Ejemplo n.º 2
0
 /**
  * Tests the client manager by trying to add some clients with invalid characters in their names.
  */
 @Test
 public void testAddClientsWithInvalidNames() {
   ClientManager manager = new ClientManager();
   Client client1 = new Client("client[s", System.out);
   Client client2 =
       new Client(
           "clien[]ts",
           new OutputStream() {
             @Override
             public void write(int b) throws IOException {}
           });
   manager.addClient(client1);
   manager.addClient(client2);
   Set<Client> clients = manager.getClients();
   assertEquals(1, clients.size());
 }