예제 #1
0
  @Test
  public void testMapRecordEviction() throws InterruptedException {
    int size = 100000;
    Config cfg = new Config();
    MapConfig mc = cfg.getMapConfig("testMapRecordEviction");
    mc.setTimeToLiveSeconds(1);
    final CountDownLatch latch = new CountDownLatch(size);
    mc.addEntryListenerConfig(
        new EntryListenerConfig()
            .setImplementation(
                new EntryAdapter() {
                  public void entryEvicted(EntryEvent event) {
                    latch.countDown();
                  }
                })
            .setLocal(true));

    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance[] instances = factory.newInstances(cfg);

    IMap map = instances[0].getMap("testMapRecordEviction");
    for (int i = 0; i < size; i++) {
      map.put(i, i);
    }
    assertTrue(latch.await(5, TimeUnit.MINUTES));
    assertEquals(0, map.size());
  }
예제 #2
0
 private void testConfig2Xml2Config(String fileName) {
   final Config config = new ClasspathXmlConfig(fileName);
   final String xml = new ConfigXmlGenerator(true).generate(config);
   final Config config2 = new InMemoryXmlConfig(xml);
   assertTrue(config.isCompatible(config2));
   assertTrue(config2.isCompatible(config));
 }
예제 #3
0
  @Test
  public void testZeroResetsTTL() throws InterruptedException {
    Config cfg = new Config();
    MapConfig mc = cfg.getMapConfig("testZeroResetsTTL");
    int ttl = 5;
    mc.setTimeToLiveSeconds(ttl);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    HazelcastInstance instance = factory.newHazelcastInstance(cfg);
    IMap<Object, Object> map = instance.getMap("testZeroResetsTTL");
    final CountDownLatch latch = new CountDownLatch(1);
    map.addEntryListener(
        new EntryAdapter<Object, Object>() {
          public void entryEvicted(EntryEvent event) {
            latch.countDown();
          }
        },
        false);

    map.put(1, 1);
    map.put(2, 2);
    map.put(1, 2, 0, TimeUnit.SECONDS);
    latch.await(10, TimeUnit.SECONDS);
    assertNull(map.get(2));
    assertEquals(2, map.get(1));
  }
예제 #4
0
 @Test
 public void testCaseInsensitivityOfSettings() {
   String xml =
       "<hazelcast>\n"
           + "<map name=\"testCaseInsensitivity\">"
           + "<in-memory-format>binary</in-memory-format>     "
           + "<backup-count>1</backup-count>                 "
           + "<async-backup-count>0</async-backup-count>    "
           + "<time-to-live-seconds>0</time-to-live-seconds>"
           + "<max-idle-seconds>0</max-idle-seconds>    "
           + "<eviction-policy>none</eviction-policy>  "
           + "<max-size policy=\"per_partition\">0</max-size>"
           + "<eviction-percentage>25</eviction-percentage>"
           + "<merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   final MapConfig mapConfig = config.getMapConfig("testCaseInsensitivity");
   assertTrue(mapConfig.getInMemoryFormat().equals(InMemoryFormat.BINARY));
   assertTrue(mapConfig.getEvictionPolicy().equals(MapConfig.EvictionPolicy.NONE));
   assertTrue(
       mapConfig
           .getMaxSizeConfig()
           .getMaxSizePolicy()
           .equals(MaxSizeConfig.MaxSizePolicy.PER_PARTITION));
 }
예제 #5
0
  public void joinExistingClient(int site, boolean useHB) throws Exception {
    EnvironmentConfig ec = makeBasicConfig();

    int p = config.getMyPort(site);
    ReplicationManagerSiteConfig dbsite = new ReplicationManagerSiteConfig("localhost", p);
    dbsite.setLocalSite(true);
    dbsite.setLegacy(true);
    ec.addReplicationManagerSite(dbsite);

    p = config.getOtherPort(site);
    dbsite = new ReplicationManagerSiteConfig("localhost", p);
    dbsite.setLegacy(true);
    ec.addReplicationManagerSite(dbsite);

    MyEventHandler monitor = new MyEventHandler();
    monitors[site] = monitor;
    ec.setEventHandler(monitor);
    File clientDir = new File(config.getBaseDir(), "dir" + site);
    assertTrue(clientDir.exists());
    Environment client = new Environment(clientDir, ec);
    client.setReplicationConfig(ReplicationConfig.STRICT_2SITE, false);

    if (useHB) {
      client.setReplicationTimeout(ReplicationTimeoutType.HEARTBEAT_SEND, 3000000);
      client.setReplicationTimeout(ReplicationTimeoutType.HEARTBEAT_MONITOR, 6000000);
    }

    envs[site] = client;
    client.setReplicationTimeout(ReplicationTimeoutType.CONNECTION_RETRY, 1000000); // be impatient
    client.replicationManagerStart(3, ReplicationManagerStartPolicy.REP_CLIENT);
    monitor.await();

    assertTrue(client.getReplicationStats(StatsConfig.DEFAULT).getStartupComplete());
  }
예제 #6
0
  @Test
  public void readVariables() {
    String xml =
        "<hazelcast>\n"
            + "    <semaphore name=\"${name}\">\n"
            + "        <initial-permits>${initial.permits}</initial-permits>\n"
            + "        <backup-count>${backupcount.part1}${backupcount.part2}</backup-count>\n"
            + "        <async-backup-count>${notreplaced}</async-backup-count>\n"
            + "    </semaphore>"
            + "</hazelcast>";
    ByteArrayInputStream bis = new ByteArrayInputStream(xml.getBytes());
    XmlConfigBuilder configBuilder = new XmlConfigBuilder(bis);

    Properties properties = new Properties();
    properties.setProperty("name", "s");
    properties.setProperty("initial.permits", "25");
    properties.setProperty("backupcount.part1", "1");
    properties.setProperty("backupcount.part2", "0");
    configBuilder.setProperties(properties);

    Config config = configBuilder.build();
    SemaphoreConfig semaphoreConfig = config.getSemaphoreConfig("s");
    assertEquals(25, semaphoreConfig.getInitialPermits());
    assertEquals(10, semaphoreConfig.getBackupCount());
    assertEquals(0, semaphoreConfig.getAsyncBackupCount());
  }
예제 #7
0
  public void restart(int siteId) throws Exception {
    EnvironmentConfig ec = makeBasicConfig();

    int p = config.getMyPort(siteId);
    ReplicationManagerSiteConfig dbsite = new ReplicationManagerSiteConfig("localhost", p);
    dbsite.setLocalSite(true);
    dbsite.setLegacy(true);
    ec.addReplicationManagerSite(dbsite);

    p = config.getOtherPort(siteId);
    dbsite = new ReplicationManagerSiteConfig("localhost", p);
    dbsite.setLegacy(true);
    ec.addReplicationManagerSite(dbsite);

    MyEventHandler monitor = new MyEventHandler();
    ec.setEventHandler(monitor);
    File clientDir = new File(config.getBaseDir(), "dir" + siteId);
    assertTrue(clientDir.exists());
    Environment client = new Environment(clientDir, ec);
    client.setReplicationConfig(ReplicationConfig.STRICT_2SITE, false);

    envs[siteId] = client;
    monitors[siteId] = monitor;
    // we want to make sure we don't retry from here after the
    // initial failure, because we want to make the old master
    // connect to us.
    client.setReplicationTimeout(ReplicationTimeoutType.CONNECTION_RETRY, Integer.MAX_VALUE);
    client.replicationManagerStart(3, ReplicationManagerStartPolicy.REP_CLIENT);
  }
예제 #8
0
 @Test
 public final void testServerPasswordNullString() {
   String password = null;
   config.serverPassword(password);
   assertTrue(
       "Password is not String (nulls and others should not be allowed)",
       config.serverPassword() instanceof java.lang.String);
 }
예제 #9
0
 @Test
 public final void testServerUsernameNullString() {
   String username = null;
   config.serverUsername(username);
   assertTrue(
       "Username is not String (nulls and others should not be allowed)",
       config.serverUsername() instanceof java.lang.String);
 }
 @Test
 public void testGetType() throws Exception {
   Config config = new Config();
   ReturnType.setConfig(config);
   TestObject to = new TestObject();
   Method stringMethod = to.getClass().getMethod("getString");
   assertEquals("java.lang.String", ReturnType.getType(stringMethod).getName());
   Method intMethod = to.getClass().getMethod("getInteger");
   assertEquals("int", ReturnType.getType(intMethod).getName());
   Method xmlDataMethod = to.getClass().getMethod("getXmlDate");
   assertTrue(ReturnType.getType(xmlDataMethod).isDate());
   assertEquals("date", ReturnType.getType(xmlDataMethod).getName());
   Method testBool = to.getClass().getMethod("isBool");
   assertEquals("boolean", ReturnType.getType(testBool).getName());
   Method testObject2Method = to.getClass().getMethod("getTestObject2");
   assertEquals("com.moesol.test.TestObject2Jso", ReturnType.getType(testObject2Method).getName());
   Method testObjectListGet = to.getClass().getMethod("getList");
   assertTrue(ReturnType.getType(testObjectListGet).isList());
   assertFalse(ReturnType.getType(testObjectListGet).isDate());
   assertTrue(ReturnType.getType(testObjectListGet).isList());
   assertEquals(
       "com.moesol.test.TestObject2Jso", ReturnType.getType(testObjectListGet).getParameterType());
   Method testObjectListSet = to.getClass().getMethod("setList", List.class);
   assertTrue(ReturnType.getType(testObjectListSet).isList());
   assertEquals(
       "com.moesol.test.TestObject2Jso", ReturnType.getType(testObjectListSet).getParameterType());
   Method testIntArray = to.getClass().getMethod("getIntArray");
   ReturnType type = ReturnType.getType(testIntArray);
   assertFalse(type.isList());
   assertTrue(type.isArray());
   assertEquals("int", type.getParameterType());
   Method testObjArray = to.getClass().getMethod("getObjArray");
   type = ReturnType.getType(testObjArray);
   assertTrue(type.isArray());
   assertFalse(type.isList());
   assertEquals("com.moesol.test.TestObject2Jso", type.getParameterType());
   Method testStringList = to.getClass().getMethod("getStringList");
   type = ReturnType.getType(testStringList);
   assertTrue(type.isArray());
   assertFalse(type.isList());
   assertEquals("java.lang.String", type.getParameterType());
   Method testStringArray = to.getClass().getMethod("getStringArray");
   type = ReturnType.getType(testStringArray);
   assertTrue(type.isArray());
   assertFalse(type.isList());
   assertEquals("java.lang.String", type.getParameterType());
   config.setOldPackage("com.moesol");
   config.setNewPackage("com.newname");
   assertEquals(
       "com.newname.test.TestObject2Jso", ReturnType.getType(testObject2Method).getName());
   assertEquals(
       "com.newname.test.TestObject2Jso",
       ReturnType.getType(testObjectListSet).getParameterType());
   assertEquals(
       "com.newname.test.TestObject2Jso", ReturnType.getType(testObjArray).getParameterType());
 }
예제 #11
0
 @Test
 public void testEmptyManagementCenterConfig() {
   String xml = "<hazelcast>\n" + "</hazelcast>";
   final Config config = buildConfig(xml);
   final ManagementCenterConfig manCenterCfg = config.getManagementCenterConfig();
   assertFalse(manCenterCfg.isEnabled());
   assertNull(manCenterCfg.getClusterId());
   assertNull(manCenterCfg.getSecurityToken());
   assertNull(manCenterCfg.getUrl());
 }
 @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());
 }
예제 #13
0
  @Test
  public void testMapRecordIdleEvictionOnMigration() throws InterruptedException {
    Config cfg = new Config();
    final String name = "testMapRecordIdleEvictionOnMigration";
    MapConfig mc = cfg.getMapConfig(name);
    int maxIdleSeconds = 10;
    int size = 100;
    final int nsize = size / 5;
    mc.setMaxIdleSeconds(maxIdleSeconds);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);

    HazelcastInstance instance1 = factory.newHazelcastInstance(cfg);
    final IMap map = instance1.getMap(name);
    final CountDownLatch latch = new CountDownLatch(size - nsize);
    map.addEntryListener(
        new EntryAdapter() {
          public void entryEvicted(EntryEvent event) {
            latch.countDown();
          }
        },
        false);

    for (int i = 0; i < size; i++) {
      map.put(i, i);
    }
    final Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                while (!Thread.currentThread().isInterrupted()) {
                  try {
                    for (int i = 0; i < nsize; i++) {
                      map.get(i);
                    }
                    Thread.sleep(1000);
                  } catch (HazelcastInstanceNotActiveException e) {
                    return;
                  } catch (InterruptedException e) {
                    return;
                  }
                }
              }
            });
    thread.start();
    HazelcastInstance instance2 = factory.newHazelcastInstance(cfg);
    HazelcastInstance instance3 = factory.newHazelcastInstance(cfg);

    assertTrue(latch.await(1, TimeUnit.MINUTES));
    Assert.assertEquals(nsize, map.size());

    thread.interrupt();
    thread.join(5000);
  }
 @Test
 public void testProperties() {
   final Properties properties = config.getProperties();
   assertNotNull(properties);
   assertEquals("5", properties.get(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS));
   assertEquals("5", properties.get(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS));
   final Config config2 = instance.getConfig();
   final Properties properties2 = config2.getProperties();
   assertNotNull(properties2);
   assertEquals("5", properties2.get(GroupProperties.PROP_MERGE_FIRST_RUN_DELAY_SECONDS));
   assertEquals("5", properties2.get(GroupProperties.PROP_MERGE_NEXT_RUN_DELAY_SECONDS));
 }
 @Test
 public void testExecutorConfig() {
   ExecutorConfig testExecConfig = config.getExecutorConfig("testExec");
   assertNotNull(testExecConfig);
   assertEquals("testExec", testExecConfig.getName());
   assertEquals(2, testExecConfig.getPoolSize());
   assertEquals(100, testExecConfig.getQueueCapacity());
   ExecutorConfig testExec2Config = config.getExecutorConfig("testExec2");
   assertNotNull(testExec2Config);
   assertEquals("testExec2", testExec2Config.getName());
   assertEquals(5, testExec2Config.getPoolSize());
   assertEquals(300, testExec2Config.getQueueCapacity());
 }
예제 #16
0
 @Test
 public void testManagementCenterConfig_onlySecurityTokenSet() {
   String xml =
       "<hazelcast>\n"
           + "<management-center security-token=\"someToken\">"
           + "</management-center>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   final ManagementCenterConfig manCenterCfg = config.getManagementCenterConfig();
   assertTrue(manCenterCfg.isEnabled());
   assertEquals("someToken", manCenterCfg.getSecurityToken());
   assertNull(manCenterCfg.getClusterId());
   assertNull(manCenterCfg.getUrl());
 }
예제 #17
0
 /**
  * Test for issue 614
  *
  * @throws InterruptedException
  */
 @Test
 public void testContainsKeyShouldDelayEviction() throws InterruptedException {
   Config cfg = new Config();
   String mapname = "testContainsKeyShouldDelayEviction";
   cfg.getMapConfig(mapname).setMaxIdleSeconds(3);
   TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
   HazelcastInstance instance = factory.newHazelcastInstance(cfg);
   IMap<Object, Object> map = instance.getMap(mapname);
   map.put(1, 1);
   for (int i = 0; i < 20; i++) {
     assertTrue(map.containsKey(1));
     Thread.sleep(500);
   }
 }
예제 #18
0
 @Test
 public void testMapStoreInitialModeEager() {
   String xml =
       "<hazelcast>\n"
           + "<map name=\"mymap\">"
           + "<map-store enabled=\"true\" initial-mode=\"EAGER\"></map-store>"
           + "</map>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   System.out.println("config = " + config);
   final MapStoreConfig mapStoreConfig = config.getMapConfig("mymap").getMapStoreConfig();
   assertTrue(mapStoreConfig.isEnabled());
   assertEquals(MapStoreConfig.InitialLoadMode.EAGER, mapStoreConfig.getInitialLoadMode());
 }
 @Test
 public void testQueueConfig() {
   QueueConfig testQConfig = config.getQueueConfig("testQ");
   assertNotNull(testQConfig);
   assertEquals("testQ", testQConfig.getName());
   assertEquals(1000, testQConfig.getMaxSize());
   QueueConfig qConfig = config.getQueueConfig("q");
   assertNotNull(qConfig);
   assertEquals("q", qConfig.getName());
   assertEquals(2500, qConfig.getMaxSize());
   assertEquals(1, testQConfig.getItemListenerConfigs().size());
   ItemListenerConfig listenerConfig = testQConfig.getItemListenerConfigs().get(0);
   assertEquals("com.hazelcast.spring.DummyItemListener", listenerConfig.getClassName());
   assertTrue(listenerConfig.isIncludeValue());
 }
예제 #20
0
 @Test
 public void testNotEnabledWithURLManagementCenterConfig() {
   String xml =
       "<hazelcast>\n"
           + "<management-center enabled=\"false\">"
           + "http://localhost:8080/mancenter"
           + "</management-center>"
           + "</hazelcast>";
   final Config config = buildConfig(xml);
   final ManagementCenterConfig manCenterCfg = config.getManagementCenterConfig();
   assertFalse(manCenterCfg.isEnabled());
   assertNull(manCenterCfg.getClusterId());
   assertNull(manCenterCfg.getSecurityToken());
   assertEquals("http://localhost:8080/mancenter", manCenterCfg.getUrl());
 }
예제 #21
0
 /*
    github issue 585
 */
 @Test
 public void testIssue585ZeroTTLShouldPreventEvictionWithSet() throws InterruptedException {
   Config config = new Config();
   config.getGroupConfig().setName("testIssue585ZeroTTLShouldPreventEvictionWithSet");
   NearCacheConfig nearCacheConfig = new NearCacheConfig();
   config.getMapConfig("default").setNearCacheConfig(nearCacheConfig);
   int n = 1;
   TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n);
   HazelcastInstance h = factory.newHazelcastInstance(config);
   IMap<String, String> map = h.getMap("testIssue585ZeroTTLShouldPreventEvictionWithSet");
   map.set("key", "value", 1, TimeUnit.SECONDS);
   map.set("key", "value2", 0, TimeUnit.SECONDS);
   Thread.sleep(2000);
   assertEquals("value2", map.get("key"));
   h.getLifecycleService().shutdown();
 }
 @Test
 public void testGroupConfig() {
   GroupConfig groupConfig = config.getGroupConfig();
   assertNotNull(groupConfig);
   assertEquals("spring-group", groupConfig.getName());
   assertEquals("spring-group-pass", groupConfig.getPassword());
 }
 @Test
 public void testNetworkConfig() {
   NetworkConfig networkConfig = config.getNetworkConfig();
   assertNotNull(networkConfig);
   assertEquals(5700, networkConfig.getPort());
   assertFalse(networkConfig.isPortAutoIncrement());
   final Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions();
   assertEquals(2, allowedPorts.size());
   Iterator portIter = allowedPorts.iterator();
   assertEquals("35000-35100", portIter.next());
   assertEquals("36000,36100", portIter.next());
   assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled());
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8);
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16);
   assertFalse(networkConfig.getInterfaces().isEnabled());
   assertEquals(1, networkConfig.getInterfaces().getInterfaces().size());
   assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next());
   TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig();
   assertNotNull(tcp);
   assertTrue(tcp.isEnabled());
   assertTrue(networkConfig.getSymmetricEncryptionConfig().isEnabled());
   final List<String> members = tcp.getMembers();
   assertEquals(members.toString(), 2, members.size());
   assertEquals("127.0.0.1:5700", members.get(0));
   assertEquals("127.0.0.1:5701", members.get(1));
   assertEquals("127.0.0.1:5700", tcp.getRequiredMember());
   AwsConfig aws = networkConfig.getJoin().getAwsConfig();
   assertFalse(aws.isEnabled());
   assertEquals("sample-access-key", aws.getAccessKey());
   assertEquals("sample-secret-key", aws.getSecretKey());
   assertEquals("sample-region", aws.getRegion());
   assertEquals("sample-group", aws.getSecurityGroupName());
   assertEquals("sample-tag-key", aws.getTagKey());
   assertEquals("sample-tag-value", aws.getTagValue());
 }
 @Test
 public void testSSLConfig() {
   SSLConfig sslConfig = config.getNetworkConfig().getSSLConfig();
   assertNotNull(sslConfig);
   assertFalse(sslConfig.isEnabled());
   assertEquals(DummySSLContextFactory.class.getName(), sslConfig.getFactoryClassName());
   assertEquals(sslContextFactory, sslConfig.getFactoryImplementation());
 }
 @Test
 public void testManagementCenterConfig() {
   ManagementCenterConfig managementCenterConfig = config.getManagementCenterConfig();
   assertNotNull(managementCenterConfig);
   assertTrue(managementCenterConfig.isEnabled());
   assertEquals("myserver:80", managementCenterConfig.getUrl());
   assertEquals(4, managementCenterConfig.getUpdateInterval());
 }
예제 #26
0
  @Test
  public void testEvictionLFU() {
    try {
      final int k = 1;
      final int size = 10000;

      final String mapName = "testEvictionLFU";
      Config cfg = new Config();
      MapConfig mc = cfg.getMapConfig(mapName);
      mc.setEvictionPolicy(MapConfig.EvictionPolicy.LFU);
      mc.setEvictionPercentage(20);
      MaxSizeConfig msc = new MaxSizeConfig();
      msc.setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.PER_NODE);
      msc.setSize(size);
      mc.setMaxSizeConfig(msc);

      TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(k);
      final HazelcastInstance[] instances = factory.newInstances(cfg);
      IMap<Object, Object> map = instances[0].getMap(mapName);

      for (int i = 0; i < size / 2; i++) {
        map.put(i, i);
        map.get(i);
      }
      Thread.sleep(1000);
      for (int i = size / 2; i < size; i++) {
        map.put(i, i);
      }

      Thread.sleep(3000);

      Assert.assertFalse("No eviction!?!?!?", map.size() == size);
      boolean isFrequentlyUsedEvicted = false;
      for (int i = 0; i < size / 2; i++) {
        if (map.get(i) == null) {
          isFrequentlyUsedEvicted = true;
          break;
        }
      }
      Assert.assertFalse(isFrequentlyUsedEvicted);
      instances[0].getLifecycleService().shutdown();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
 @Test
 public void testSocketInterceptorConfig() {
   SocketInterceptorConfig socketInterceptorConfig =
       config.getNetworkConfig().getSocketInterceptorConfig();
   assertNotNull(socketInterceptorConfig);
   assertFalse(socketInterceptorConfig.isEnabled());
   assertEquals(DummySocketInterceptor.class.getName(), socketInterceptorConfig.getClassName());
   assertEquals(socketInterceptor, socketInterceptorConfig.getImplementation());
 }
 @Test
 public void testTopicConfig() {
   TopicConfig testTopicConfig = config.getTopicConfig("testTopic");
   assertNotNull(testTopicConfig);
   assertEquals("testTopic", testTopicConfig.getName());
   assertEquals(1, testTopicConfig.getMessageListenerConfigs().size());
   ListenerConfig listenerConfig = testTopicConfig.getMessageListenerConfigs().get(0);
   assertEquals("com.hazelcast.spring.DummyMessageListener", listenerConfig.getClassName());
 }
예제 #29
0
 @BeforeClass
 public static void setup() {
   try {
     Config.setup();
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
예제 #30
0
 @Test
 public void readSemaphoreConfig() {
   String xml =
       "<hazelcast>\n"
           + "    <semaphore name=\"default\">\n"
           + "        <initial-permits>1</initial-permits>\n"
           + "    </semaphore>"
           + "    <semaphore name=\"custom\">\n"
           + "        <initial-permits>10</initial-permits>\n"
           + "        <semaphore-factory enabled=\"true\">"
           + "             <class-name>com.acme.MySemaphore</class-name>\n"
           + "        </semaphore-factory>"
           + "    </semaphore>"
           + "</hazelcast>";
   Config config = buildConfig(xml);
   SemaphoreConfig defaultConfig = config.getSemaphoreConfig("default");
   SemaphoreConfig customConfig = config.getSemaphoreConfig("custom");
   assertEquals(1, defaultConfig.getInitialPermits());
   assertEquals(10, customConfig.getInitialPermits());
 }