### Question:
GmondDataReader { public List<Host> getUpToDateHostsInfo() throws GangliaException { return parseGangliaMetrics(getGangliaCurrentMetrics()); } GmondDataReader(String host, int port); List<Host> getUpToDateHostsInfo(); void setSocket(Socket socket);  }### Answer:
@Test public void testParseGangliaCurrentMetricsWithOneHost() throws Exception { when(socket.getInputStream()).thenReturn( getClass().getResourceAsStream("/campinas.xml")); List<Host> hosts = gmondReader.getUpToDateHostsInfo(); assertEquals(1, hosts.size()); assertEquals("0.00", hosts.get(0).getMetricValue("load_one")); }
@Test public void testParseGangliaCurrentMetricsWithManyHosts() throws Exception { when(socket.getInputStream()).thenReturn( getClass().getResourceAsStream("/ganglia_opencirrus.xml")); List<Host> hosts = gmondReader.getUpToDateHostsInfo(); assertEquals(22, hosts.size()); assertEquals("opencirrus-08039.hpl.hp.com", hosts.get(0).getHostName()); }