summaryrefslogtreecommitdiffstats
path: root/common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java
diff options
context:
space:
mode:
authornoahs <noah.shogan@gmail.com>2017-12-06 13:11:38 +0200
committernoahs <noah.shogan@amdocs.com>2017-12-06 17:38:57 +0200
commitf9f112f5fd5b193e79e38442cc566b7b437f87d2 (patch)
tree01a1ef7f840cbacb5ed465095926d14e83a7fd27 /common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java
parent0566f581c0f310384f42838c388f57234ed1d60e (diff)
Duplicate logging frameworks merging
There was two copies of the SDC logging framework Change-Id: I55c94c9817a83162c6d90e504dfd91e4858c7269 Issue-ID: SDC-703 Signed-off-by: noahs <noah.shogan@amdocs.com>
Diffstat (limited to 'common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java')
-rw-r--r--common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java216
1 files changed, 0 insertions, 216 deletions
diff --git a/common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java b/common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java
deleted file mode 100644
index f2a6549a2a..0000000000
--- a/common/openecomp-logging-lib/openecomp-logging-core/src/test/java/org/openecomp/core/logging/context/MDCPropagationFactoryTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.core.logging.context;
-
-import org.slf4j.MDC;
-import org.testng.annotations.Test;
-
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.testng.Assert.*;
-
-/**
- * @author evitaliy
- * @since 12/09/2016.
- */
-public class MDCPropagationFactoryTest {
-
- @Test
- public void testNoPropagation() throws InterruptedException {
-
- String uuid = UUID.randomUUID().toString();
- AtomicBoolean complete = new AtomicBoolean(false);
- MDC.put("data", uuid);
-
- Runnable runnable = () -> {
- assertNull(MDC.get("data"));
- complete.set(true);
- };
-
- Thread thread = new Thread(runnable);
- thread.start();
- thread.join();
-
- assertEquals(MDC.get("data"), uuid);
- assertTrue(complete.get());
- }
-
- @Test
- public void testPropagation() throws InterruptedException {
-
- String uuid = UUID.randomUUID().toString();
- AtomicBoolean complete = new AtomicBoolean(false);
- MDC.put("data", uuid);
-
- MdcPropagationService factory = new MdcPropagationService();
- Runnable runnable = factory.create(() -> {
- assertEquals(MDC.get("data"), uuid);
- complete.set(true);
- });
-
- Thread thread = new Thread(runnable);
- thread.start();
- thread.join();
-
- assertEquals(MDC.get("data"), uuid);
- assertTrue(complete.get());
- }
-
- @Test
- public void testReplacement() throws InterruptedException {
-
- String innerUuid = UUID.randomUUID().toString();
- AtomicBoolean innerComplete = new AtomicBoolean(false);
- AtomicBoolean outerComplete = new AtomicBoolean(false);
-
- MDC.put("data", innerUuid);
-
- MdcPropagationService factory = new MdcPropagationService();
-
- // should run with the context of main thread
- Runnable inner = factory.create(() -> {
- assertEquals(MDC.get("data"), innerUuid);
- innerComplete.set(true);
- });
-
- // pushes its own context, but runs the inner runnable
- Runnable outer = () -> {
- String outerUuid = UUID.randomUUID().toString();
- MDC.put("data", outerUuid);
- inner.run();
- assertEquals(MDC.get("data"), outerUuid);
- outerComplete.set(true);
- };
-
-
- Thread thread = new Thread(outer);
- thread.start();
- thread.join();
-
- assertEquals(MDC.get("data"), innerUuid);
- assertTrue(outerComplete.get());
- assertTrue(innerComplete.get());
- }
-
- @Test
- public void testEmpty() throws InterruptedException {
-
- final AtomicBoolean complete = new AtomicBoolean(false);
-
- MDC.remove("data");
- assertNull(MDC.get("data"));
-
- MdcPropagationService factory = new MdcPropagationService();
- Runnable runnable = factory.create(() -> {
- assertNull(MDC.get("data"));
- complete.set(true);
- });
-
- Thread thread = new Thread(runnable);
- thread.start();
- thread.join();
-
- assertNull(MDC.get("data"));
- assertTrue(complete.get());
- }
-
- @Test
- public void testCleanup() throws Exception {
-
- String innerUuid = UUID.randomUUID().toString();
- AtomicBoolean innerComplete = new AtomicBoolean(false);
- AtomicBoolean outerComplete = new AtomicBoolean(false);
-
- MDC.put("data", innerUuid);
-
- MdcPropagationService factory = new MdcPropagationService();
-
- // should run with the context of main thread
- Runnable inner = factory.create(() -> {
- assertEquals(MDC.get("data"), innerUuid);
- innerComplete.set(true);
- });
-
- // pushes its own context, but runs the inner runnable
- Runnable outer = () -> {
- assertNull(MDC.get("data"));
- inner.run();
- assertNull(MDC.get("data"));
- outerComplete.set(true);
- };
-
- Thread thread = new Thread(outer);
- thread.start();
- thread.join();
-
- assertEquals(MDC.get("data"), innerUuid);
- assertTrue(outerComplete.get());
- assertTrue(innerComplete.get());
- }
-
- @Test
- public void testCleanupAfterError() throws Exception {
-
- String innerUuid = UUID.randomUUID().toString();
- AtomicBoolean innerComplete = new AtomicBoolean(false);
- AtomicBoolean outerComplete = new AtomicBoolean(false);
- AtomicBoolean exceptionThrown = new AtomicBoolean(false);
-
- MDC.put("data", innerUuid);
-
- MdcPropagationService factory = new MdcPropagationService();
-
- // should run with the context of main thread
- Runnable inner = factory.create(() -> {
- assertEquals(MDC.get("data"), innerUuid);
- innerComplete.set(true);
- throw new RuntimeException();
- });
-
- // pushes its own context, but runs the inner runnable
- Runnable outer = () -> {
-
- String outerUuid = UUID.randomUUID().toString();
- MDC.put("data", outerUuid);
- assertEquals(MDC.get("data"), outerUuid);
-
- try {
- inner.run();
- } catch (RuntimeException e) {
- exceptionThrown.set(true);
- } finally {
- assertEquals(MDC.get("data"), outerUuid);
- outerComplete.set(true);
- }
- };
-
- Thread thread = new Thread(outer);
- thread.start();
- thread.join();
-
- assertEquals(MDC.get("data"), innerUuid);
- assertTrue(outerComplete.get());
- assertTrue(innerComplete.get());
- assertTrue(exceptionThrown.get());
- }
-
-}