String name = "org/apache/hadoop/gateway/topology/xml/simple-topology-ambari-format.conf";
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( "topology2" ) );
assertThat( topology.getTimestamp(), is( file.lastModified() ) );
assertThat( topology.getServices().size(), is( 4 ) );
assertThat( topology.getProviders().size(), is( 2 ) );
Service webhdfsService = topology.getService( "WEBHDFS", null );
assertThat( webhdfsService, notNullValue() );
assertThat( webhdfsService.getRole(), is( "WEBHDFS" ) );
assertThat( webhdfsService.getName(), nullValue() );
assertThat( webhdfsService.getUrls().size(), is( 2 ) );
assertThat( webhdfsService.getUrls(), hasItem( "http://host1:50070/webhdfs" ) );
assertThat( webhdfsService.getUrls(), hasItem( "http://host2:50070/webhdfs" ) );
Service webhcatService = topology.getService( "WEBHCAT", null );
assertThat( webhcatService, notNullValue() );
assertThat( webhcatService.getRole(), is( "WEBHCAT" ) );
assertThat( webhcatService.getName(), nullValue() );
assertThat( webhcatService.getUrls().size(), is( 1 ) );
assertThat( webhcatService.getUrls(), hasItem( "http://host:50111/templeton" ) );
Service oozieService = topology.getService( "OOZIE", null );
assertThat( oozieService, notNullValue() );
assertThat( oozieService.getRole(), is( "OOZIE" ) );
assertThat( oozieService.getName(), nullValue() );
assertThat( webhcatService.getUrls().size(), is( 1 ) );
assertThat( oozieService.getUrls(), hasItem( "http://host:11000/oozie" ) );
Service hiveService = topology.getService( "HIVE", null );
assertThat( hiveService, notNullValue() );
assertThat( hiveService.getRole(), is( "HIVE" ) );
assertThat( hiveService.getName(), nullValue() );
assertThat( webhcatService.getUrls().size(), is( 1 ) );
assertThat( hiveService.getUrls(), hasItem( "http://host:10000" ) );
Provider authenticationProvider = topology.getProvider( "authentication", "ShiroProvider" );
assertThat( authenticationProvider, notNullValue() );
assertThat( authenticationProvider.isEnabled(), is( true ) );
assertThat( authenticationProvider.getRole(), is( "authentication" ) );
assertThat( authenticationProvider.getName(), is( "ShiroProvider" ) );
assertThat( authenticationProvider.getParams().size(), is( 5 ) );
assertThat( authenticationProvider.getParams().get("main.ldapRealm.contextFactory.url"), is( "ldap://localhost:33389" ) );
Provider identityAssertionProvider = topology.getProvider( "identity-assertion", "Default" );
assertThat( identityAssertionProvider, notNullValue() );
assertThat( identityAssertionProvider.isEnabled(), is( false ) );
assertThat( identityAssertionProvider.getRole(), is( "identity-assertion" ) );
assertThat( identityAssertionProvider.getName(), is( "Default" ) );
assertThat( identityAssertionProvider.getParams().size(), is( 2 ) );