@Test
  public void testNodeCreationAndWhitePagesRegistration() {
    Grid grid = new GridImpl(new HashMap<String, Object>());

    GridPeerConfiguration conf = new GridPeerConfiguration();

    // Configuring the WhitePages
    GridPeerServiceConfiguration wplConf = new WhitePagesLocalConfiguration();
    conf.addConfiguration(wplConf);

    conf.configure(grid);

    GridNode gnode = grid.createGridNode("test1@local");

    WhitePages pages = grid.get(WhitePages.class);
    GridServiceDescription<GridNode> gsd = pages.create("test1@local", "grid0");

    GridServiceDescription<GridNode> serviceDescription = pages.lookup("test1@local");

    GridConnection connection = grid.get(ConnectionFactoryService.class).createConnection(gsd);
    assertSame(gnode, connection.connect());
  }
  @Test
  public void test1() {

    Map<String, GridServiceDescription> coreServicesMap =
        new HashMap<
            String,
            GridServiceDescription>(); // Hazelcast.newHazelcastInstance( null ).getMap(
                                       // CoreServicesLookup.class.getName() );

    SystemEventListener l = SystemEventListenerFactory.getSystemEventListener();

    GridImpl grid1 = new GridImpl(new ConcurrentHashMap<String, Object>());

    GridPeerConfiguration conf = new GridPeerConfiguration();

    GridPeerServiceConfiguration coreSeviceConf =
        new CoreServicesLookupConfiguration(coreServicesMap);
    conf.addConfiguration(coreSeviceConf);

    MultiplexSocketServiceCongifuration socketConf =
        new MultiplexSocketServiceCongifuration(
            new MultiplexSocketServerImpl("127.0.0.1", new MinaAcceptorFactoryService(), l, grid1));
    conf.addConfiguration(socketConf);

    WhitePagesLocalConfiguration wplConf = new WhitePagesLocalConfiguration();
    wplConf.setWhitePages(
        new JpaWhitePages(Persistence.createEntityManagerFactory("org.drools.grid")));
    conf.addConfiguration(wplConf);

    socketConf.addService(WhitePages.class.getName(), wplConf.getWhitePages(), 5012);

    conf.configure(grid1);

    GridImpl grid2 = new GridImpl(new ConcurrentHashMap<String, Object>());
    conf = new GridPeerConfiguration();

    // coreServicesMap = Hazelcast.newHazelcastInstance( null ).getMap(
    // CoreServicesLookup.class.getName() );
    coreSeviceConf = new CoreServicesLookupConfiguration(coreServicesMap);
    conf.addConfiguration(coreSeviceConf);

    GridPeerServiceConfiguration wprConf = new WhitePagesRemoteConfiguration();
    conf.addConfiguration(wprConf);

    conf.configure(grid2);

    WhitePages wp = grid2.get(WhitePages.class);

    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);
    grid1.get(SocketService.class).close();
  }