PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 11ms RepoModel.GetById 2ms app.codeStats 0ms

/hazelcast/src/test/java/com/hazelcast/core/HazelcastLogTest.java

https://bitbucket.org/gabral6_gmailcom/hazelcast
Java | 72 lines | 43 code | 8 blank | 21 comment | 1 complexity | f534238f3e937a657941d6b5ca8fb656 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.core;
18
19import com.hazelcast.config.Config;
20import com.hazelcast.config.MapConfig;
21import com.hazelcast.config.MultiMapConfig;
22import com.hazelcast.config.NearCacheConfig;
23import com.hazelcast.impl.Node;
24import com.hazelcast.impl.TestUtil;
25import com.hazelcast.util.Clock;
26import com.hazelcast.impl.GroupProperties;
27import org.junit.*;
28import org.junit.runner.RunWith;
29
30import java.io.Serializable;
31import java.util.*;
32import java.util.concurrent.*;
33import java.util.concurrent.atomic.AtomicBoolean;
34import java.util.concurrent.atomic.AtomicInteger;
35
36import static org.junit.Assert.*;
37
38/**
39 * HazelcastTest tests general behavior for one node.
40 * Node is created in the beginning of the tests and the same for all test methods.
41 * <p/>
42 * Unit test is whiteboard'n'fast.
43 */
44@RunWith(com.hazelcast.util.RandomBlockJUnit4ClassRunner.class)
45public class HazelcastLogTest {
46
47    @BeforeClass
48    @AfterClass
49    public static void init() throws Exception {
50        System.setProperty(GroupProperties.PROP_VERSION_CHECK_ENABLED, "false");
51        Hazelcast.shutdownAll();
52    }
53
54    @Test
55    public void testDisablingSystemLogs() throws Exception {
56        Config config = new Config();
57        config.setProperty(GroupProperties.PROP_SYSTEM_LOG_ENABLED, "true");
58        config.getGroupConfig().setName("testDisablingSystemLogs");
59        HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
60        HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
61        instance.getMap("map").put("key", "value");
62        Node node = TestUtil.getNode(instance);
63        assertTrue(node.getSystemLogService().getLogBundle().size() > 0);
64        Hazelcast.shutdownAll();
65        config.setProperty(GroupProperties.PROP_SYSTEM_LOG_ENABLED, "false");
66        instance = Hazelcast.newHazelcastInstance(config);
67        instance2 = Hazelcast.newHazelcastInstance(config);
68        instance.getMap("map").put("key2", "value2");
69        assertTrue(node.getSystemLogService().getLogBundle().size() == 0);
70    }
71
72}