Search in sources :

Example 96 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientReliableTopicOverloadTest method setupCluster.

@Before
public void setupCluster() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(5));
    hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenError_*").setTopicOverloadPolicy(TopicOverloadPolicy.ERROR));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardOldest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_OLDEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardNewest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_NEWEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenBlock_*").setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    serializationService = ((HazelcastClientProxy) client).getSerializationService();
    String topicName = getTestMethodName();
    topic = client.<String>getReliableTopic(topicName);
    ringbuffer = ((ClientReliableTopicProxy<String>) topic).getRingbuffer();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 97 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ProxyFactoryTest method testCustomProxy_usingFactoryClassName.

@Test
public void testCustomProxy_usingFactoryClassName() {
    ClientConfig clientConfig = new ClientConfig();
    ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
    proxyFactoryConfig.setService(SERVICE_NAME);
    proxyFactoryConfig.setClassName(CustomProxyFactory.class.getName());
    clientConfig.addProxyFactoryConfig(proxyFactoryConfig);
    testCustomProxy(clientConfig);
}
Also used : ProxyFactoryConfig(com.hazelcast.client.config.ProxyFactoryConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 98 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ProxyFactoryTest method testCustomProxy_usingFactoryImplementation.

@Test
public void testCustomProxy_usingFactoryImplementation() {
    ClientConfig clientConfig = new ClientConfig();
    ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
    proxyFactoryConfig.setService(SERVICE_NAME);
    proxyFactoryConfig.setFactoryImpl(new CustomProxyFactory());
    clientConfig.addProxyFactoryConfig(proxyFactoryConfig);
    testCustomProxy(clientConfig);
}
Also used : ProxyFactoryConfig(com.hazelcast.client.config.ProxyFactoryConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 99 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ProxyFactoryTest method testProxy_whenInitThrowsError.

@Test
public void testProxy_whenInitThrowsError() {
    ClientConfig clientConfig = new ClientConfig();
    ProxyFactoryConfig proxyFactoryConfig = new ProxyFactoryConfig();
    proxyFactoryConfig.setService(SERVICE_NAME);
    proxyFactoryConfig.setFactoryImpl(new ClientProxyFactory() {

        @Override
        public ClientProxy create(String id) {
            return new ClientProxy(SERVICE_NAME, id) {

                @Override
                protected void onInitialize() {
                    super.onInitialize();
                    throw new ExpectedError();
                }
            };
        }
    });
    clientConfig.addProxyFactoryConfig(proxyFactoryConfig);
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    String objectName = "custom-object";
    try {
        client.getDistributedObject(SERVICE_NAME, objectName);
        fail("Client proxy initialization should fail!");
    } catch (ExpectedError expected) {
    }
}
Also used : ProxyFactoryConfig(com.hazelcast.client.config.ProxyFactoryConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 100 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class AtomicLongStableReadStressTest method setUp.

@Before
public void setUp() {
    super.setUp();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().setRedoOperation(true);
    client = HazelcastClient.newHazelcastClient(clientConfig);
    references = new IAtomicLong[REFERENCE_COUNT];
    for (int k = 0; k < references.length; k++) {
        references[k] = client.getAtomicLong("atomicreference:" + k);
    }
    stressThreads = new StressThread[CLIENT_THREAD_COUNT];
    for (int k = 0; k < stressThreads.length; k++) {
        stressThreads[k] = new StressThread();
        stressThreads[k].start();
    }
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Aggregations

ClientConfig (com.hazelcast.client.config.ClientConfig)214 Test (org.junit.Test)129 HazelcastInstance (com.hazelcast.core.HazelcastInstance)110 QuickTest (com.hazelcast.test.annotation.QuickTest)107 ParallelTest (com.hazelcast.test.annotation.ParallelTest)81 Config (com.hazelcast.config.Config)45 NearCacheConfig (com.hazelcast.config.NearCacheConfig)32 NightlyTest (com.hazelcast.test.annotation.NightlyTest)32 CountDownLatch (java.util.concurrent.CountDownLatch)25 AssertTask (com.hazelcast.test.AssertTask)20 Before (org.junit.Before)20 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)16 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)15 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)13 CachingProvider (javax.cache.spi.CachingProvider)13 IMap (com.hazelcast.core.IMap)12 LifecycleListener (com.hazelcast.core.LifecycleListener)12 LifecycleEvent (com.hazelcast.core.LifecycleEvent)11 Data (com.hazelcast.nio.serialization.Data)11 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)10