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