public class JpaWhitePagesTest {
@Test
public void test1() {
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.grid" );
WhitePages wp = new JpaWhitePages( emf );
wp.create( "s1" );
wp.create( "s2" );
wp.create( "s3" );
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 );
}