// tests the getList method after adding clients
  @Test
  public void testGetList() throws IOException {
    serverNodes.add(channel1);
    serverNodes.add(channel2);
    serverNodes.add(channel3);

    String output = serverNodes.getList();
    assertEquals(output, "ServerNodes: 1 2 3");
  }
  // tests the getList method on an empty list that was once filled
  @Test
  public void testEmptyListAfterRemovals() throws IOException {
    serverNodes.add(channel1);
    serverNodes.add(channel2);
    serverNodes.add(channel3);

    serverNodes.remove(channel3);
    serverNodes.remove(channel2);
    serverNodes.remove(channel1);

    String output = serverNodes.getList();
    assertEquals(output, "ServerNodes: ");
  }
示例#3
0
 /**
  * Initialize the Test Called before every test case method. Stubs out some test channels, add to
  * the Server Node and initializes the Hive
  */
 @Before
 public void initialize() {
   channel1 = new Channel("1");
   channel2 = new Channel("2");
   channel3 = new Channel("3");
   serverNodes = new ServerNodes();
   try {
     serverNodes.add(channel1);
     serverNodes.add(channel2);
     serverNodes.add(channel3);
     hive = new Hive(serverNodes);
     channel1.getBuffer().clear();
     channel2.getBuffer().clear();
     channel3.getBuffer().clear();
   } catch (IOException e) {
     fail();
   }
 }