public void testEventFilter() throws Exception {
    Object[] filterFactoryParams = new Object[] {"string_key_1", "user_1"};
    ClientEntryListener listener = new ClientEntryListener();
    remoteCache.addClientListener(listener, filterFactoryParams, null);

    User user1 = new UserPB();
    user1.setId(1);
    user1.setName("John");
    user1.setSurname("Doe");
    user1.setGender(User.Gender.MALE);
    user1.setAge(22);

    remoteCache.put("string_key_1", "string value 1");
    remoteCache.put("string_key_2", "string value 2");
    remoteCache.put("user_1", user1);

    assertEquals(3, remoteCache.keySet().size());

    ClientCacheEntryCreatedEvent e = listener.createEvents.poll(5, TimeUnit.SECONDS);
    assertEquals("string_key_1", e.getKey());

    e = listener.createEvents.poll(5, TimeUnit.SECONDS);
    assertEquals("user_1", e.getKey());

    e = listener.createEvents.poll(5, TimeUnit.SECONDS);
    assertNull("No more elements expected in queue!", e);
  }
コード例 #2
0
 private User createUser() {
   User user = new UserPB();
   user.setId(1);
   user.setName("Tom");
   user.setSurname("Cat");
   user.setGender(User.Gender.MALE);
   user.setAccountIds(Collections.singleton(12));
   Address address = new AddressPB();
   address.setStreet("Dark Alley");
   address.setPostCode("1234");
   user.setAddresses(Collections.singletonList(address));
   return user;
 }
コード例 #3
0
  public void testEventFilter() throws Exception {
    User user1 = new UserPB();
    user1.setId(1);
    user1.setName("John");
    user1.setSurname("Doe");
    user1.setGender(User.Gender.MALE);
    user1.setAge(22);

    NoopEventListener listener = new NoopEventListener();
    remoteCache.addClientListener(listener);

    expectElementsInQueue(listener.createEvents, 0);

    remoteCache.put("user_" + user1.getId(), user1);

    assertEquals(1, remoteCache.size());
    expectElementsInQueue(listener.createEvents, 1);

    remoteCache.removeClientListener(listener);
  }
コード例 #4
0
 private void assertUser(User user) {
   assertNotNull(user);
   assertEquals(1, user.getId());
   assertEquals("Tom", user.getName());
   assertEquals("Cat", user.getSurname());
   assertEquals(User.Gender.MALE, user.getGender());
   assertNotNull(user.getAccountIds());
   assertEquals(1, user.getAccountIds().size());
   assertTrue(user.getAccountIds().contains(12));
   assertNotNull(user.getAddresses());
   assertEquals(1, user.getAddresses().size());
   assertEquals("Dark Alley", user.getAddresses().get(0).getStreet());
   assertEquals("1234", user.getAddresses().get(0).getPostCode());
 }