PageRenderTime 66ms CodeModel.GetById 58ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/hazelcast-client/src/test/java/com/hazelcast/client/HazelcastClientIdGeneratorTest.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 53 lines | 30 code | 6 blank | 17 comment | 2 complexity | 60cd098c1f7d18d1e06a90478b1730b5 MD5 | raw file
 1/*
 2 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License");
 5 * you may not use this file except in compliance with the License.
 6 * You may obtain a copy of the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.hazelcast.client;
18
19import com.hazelcast.core.HazelcastInstance;
20import com.hazelcast.core.IdGenerator;
21import org.junit.Test;
22
23import java.util.HashMap;
24import java.util.Map;
25
26import static junit.framework.Assert.assertTrue;
27import static org.junit.Assert.assertNull;
28
29public class HazelcastClientIdGeneratorTest extends HazelcastClientTestBase {
30
31    @Test
32    public void idGenerator() {
33        HazelcastClient hClient = getHazelcastClient();
34        HazelcastInstance h = getHazelcastInstance();
35        IdGenerator nativeId = h.getIdGenerator("id");
36        IdGenerator clientId = hClient.getIdGenerator("id");
37        long v = clientId.newId();
38        Map<Long, Integer> map = new HashMap<Long, Integer>();
39        int count = 10;
40        for (int i = 0; i < count; i++) {
41            long genId = nativeId.newId();
42            assertNull(map.put(genId, 1));
43//            System.out.println(genId);
44        }
45        System.out.println(v);
46        for (int i = 0; i < count; i++) {
47            long genId = clientId.newId();
48            assertNull(map.put(genId, 1));
49//            System.out.println(genId);
50        }
51        assertTrue(true);
52    }
53}