GridPeerServiceConfiguration wprConf = new WhitePagesRemoteConfiguration( );
conf.addConfiguration( wprConf );
conf.configure( grid2 );
WhitePages wp = grid2.get( WhitePages.class );
wp.create( "s1", "grid0" );
wp.create( "s2", "grid0" );
wp.create( "s3", "grid0" );
GridServiceDescription<String> gs1 = wp.lookup( "s1" );
gs1.addAddress( "p1" ).setObject( "v1" );
gs1.addAddress( "p2" ).setObject( "v2" );
gs1 = wp.lookup( "s1" );
assertEquals( 2,
gs1.getAddresses().size() );
assertEquals( "v1",
gs1.getAddresses().get( "p1" ).getObject() );
assertEquals( "v2",
gs1.getAddresses().get( "p2" ).getObject() );
gs1.removeAddress( "p2" );
gs1 = wp.lookup( "s1" );
assertEquals( 1,
gs1.getAddresses().size() );
assertEquals( "v1",
gs1.getAddresses().get( "p1" ).getObject() );
wp.remove( "s1" );
assertNull( wp.lookup( "s1" ) );
GridServiceDescription gs2 = wp.lookup( "s2" );
assertNotNull( gs2 );
grid1.get( SocketService.class ).close();
}