NetworkTopology implements IOReadableWritable { public NetworkTopology() { this.rootNode = new NetworkNode(DEFAULT_ROOT_NODE_NAME, null, this); } NetworkTopology(); static NetworkTopology fromFile(final File topologyFile); static NetworkTopology fromFile(final String topologyFileName); static NetworkTopology createEmptyTopology(); NetworkNode getNodeByName(final String name); NetworkNode getRootNode(); @Override void read(final DataInput in); @Override void write(final DataOutput out); int getDepth(); @Override String toString(); Iterator<NetworkNode> iterator(); void setAttachment(Object attachment); Object getAttachment();  }
@Test public void testNetworkTopology() { NetworkTopology topology; try { topology = NetworkTopology.fromFile(getPathToTopologyFile()); } catch (IOException e) { fail(e.getMessage()); return; } assertEquals(topology.getDepth(), 4); final NetworkNode networkNode = topology.getNodeByName("rackswitch3"); if (networkNode == null) { assertEquals("Cannot find network node rackswitch3", true, false); return; } assertEquals(networkNode.getNumberOfChildNodes(), 4); }