コード例 #1
0
 // Check all iterators for correct size counts
 private void checkSizes(int expectedSize) {
   assertEquals("size()", _nbhm.size(), expectedSize);
   Collection<String> vals = _nbhm.values();
   checkSizes("values()", vals.size(), vals.iterator(), expectedSize);
   Set<String> keys = _nbhm.keySet();
   checkSizes("keySet()", keys.size(), keys.iterator(), expectedSize);
   Set<Entry<String, String>> ents = _nbhm.entrySet();
   checkSizes("entrySet()", ents.size(), ents.iterator(), expectedSize);
 }
コード例 #2
0
 @Test
 public void testInstance() {
   assertNotNull(instance);
   final Set<Member> members = instance.getCluster().getMembers();
   assertEquals(1, members.size());
   final Member member = members.iterator().next();
   final InetSocketAddress inetSocketAddress = member.getInetSocketAddress();
   assertEquals(5700, inetSocketAddress.getPort());
   assertEquals("test-instance", config.getInstanceName());
   assertEquals("HAZELCAST_ENTERPRISE_LICENSE_KEY", config.getLicenseKey());
 }
コード例 #3
0
  @Test
  public void testAddService() {
    ServiceHolder tested = new ServiceHolder();
    Object service = new Object();

    tested.addService(service);

    Set<String> services = getField(tested, "services");

    assertEquals("Size of the \"services\" Set should be 1", 1, services.size());
    assertSame(
        "The services Set should didn't contain the expect service",
        service,
        services.iterator().next());
  }
 @Test
 public void iterateOverMapKeys() {
   HazelcastClient hClient = getHazelcastClient();
   Map<String, String> map = hClient.getMap("iterateOverMapKeys");
   map.put("1", "A");
   map.put("2", "B");
   map.put("3", "C");
   Set<String> keySet = map.keySet();
   assertEquals(3, keySet.size());
   Set<String> s = new HashSet<String>();
   for (String string : keySet) {
     s.add(string);
     assertTrue(Arrays.asList("1", "2", "3").contains(string));
   }
   assertEquals(3, s.size());
   Iterator<String> iterator = keySet.iterator();
   while (iterator.hasNext()) {
     iterator.next();
     iterator.remove();
   }
   assertEquals(0, map.size());
 }