String name = "org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml";
URL url = ClassLoader.getSystemResource( name );
assertThat( "Failed to find URL for resource " + name, url, notNullValue() );
File file = new File( url.getFile() );
TopologyBuilder topologyBuilder = digester.parse( url );
Topology topology = topologyBuilder.build();
assertThat( "Failed to parse resource " + name, topology, notNullValue() );
topology.setTimestamp( file.lastModified() );
assertThat( topology.getName(), is( "topology" ) );
assertThat( topology.getTimestamp(), is( file.lastModified() ) );
assertThat( topology.getServices().size(), is( 1 ) );
Service comp = topology.getServices().iterator().next();
assertThat( comp, notNullValue() );
assertThat( comp.getRole(), is( "WEBHDFS" ) );
assertThat( comp.getUrl(), is( "http://host:80/webhdfs" ) );
Provider provider = topology.getProviders().iterator().next();
assertThat( provider, notNullValue() );
assertThat( provider.isEnabled(), is(true) );
assertThat( provider.getRole(), is( "authentication" ) );
assertThat( provider.getParams().size(), is(5));
}