em.getTransaction().begin();
em.persist( gsd1 );
em.getTransaction().commit();
em.close();
GridServiceDescriptionImpl gsd2 = new GridServiceDescriptionImpl( "s1", "grid0" );
gsd2.setServiceInterface( WhitePages.class );
gsd2.addAddress( "socket" ).setObject( new InetSocketAddress( "127.0.0.1",
8000 ) );
gsd2.addAddress( "p2" ).setObject( "v2" );
em = emf.createEntityManager();
em.getTransaction().begin();
em.persist( gsd2 );
em.getTransaction().commit();
em.close();
em = emf.createEntityManager();
GridServiceDescription<WhitePages> gsd1r = em.find( GridServiceDescriptionImpl.class,
WhitePages.class.getName() );
assertNotNull( gsd1r );
assertEquals( gsd1,
gsd1r );
assertEquals( new InetSocketAddress( "127.0.0.1",
8010 ),
gsd1.getAddresses().get( "socket" ).getObject() );
assertEquals( "v1",
gsd1.getAddresses().get( "p1" ).getObject() );
GridServiceDescription<WhitePages> gsd2r = em.find( GridServiceDescriptionImpl.class,
"s1" );
assertNotNull( gsd2r );
assertEquals( gsd2,
gsd2r );
assertEquals( new InetSocketAddress( "127.0.0.1",
8000 ),
gsd2.getAddresses().get( "socket" ).getObject() );
assertEquals( "v2",
gsd2.getAddresses().get( "p2" ).getObject() );
}