2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.logging.ref.slf4j.common;
24 import java.lang.reflect.Constructor;
25 import java.lang.reflect.InvocationTargetException;
27 import org.testng.Assert;
28 import org.testng.annotations.Test;
30 import static org.hamcrest.MatcherAssert.assertThat;
31 import static org.hamcrest.core.Is.is;
32 import static org.hamcrest.core.IsInstanceOf.instanceOf;
35 * Tests for {@link ONAPLogConstants}.
37 public class ONAPLogConstantsTest {
40 public void testConstructor() throws Exception {
42 ONAPLogConstants.class.getDeclaredConstructors()[0].newInstance();
43 Assert.fail("Should fail for hidden constructor.");
45 catch (final IllegalAccessException e) {
51 public void testConstructorUnsupported() throws Exception {
53 Constructor<?> c = ONAPLogConstants.class.getDeclaredConstructors()[0];
54 c.setAccessible(true);
56 Assert.fail("Should fail for hidden constructor.");
58 catch (final InvocationTargetException e) {
59 assertThat(e.getCause(), instanceOf(UnsupportedOperationException.class));
64 public void testHeaders() {
65 assertThat(ONAPLogConstants.Headers.REQUEST_ID.toString(), is("X-ONAP-RequestID"));
66 assertThat(ONAPLogConstants.Headers.INVOCATION_ID.toString(), is("X-ONAP-InvocationID"));
67 assertThat(ONAPLogConstants.Headers.PARTNER_NAME.toString(), is("X-ONAP-PartnerName"));
71 public void testMarkers() {
72 assertThat(ONAPLogConstants.Markers.ENTRY.toString(), is("ENTRY"));
73 assertThat(ONAPLogConstants.Markers.EXIT.toString(), is("EXIT"));
74 assertThat(ONAPLogConstants.Markers.INVOKE.toString(), is("INVOKE"));
75 assertThat(ONAPLogConstants.Markers.INVOKE_ASYNCHRONOUS.toString(), is("INVOKE [ ASYNCHRONOUS ]"));
76 assertThat(ONAPLogConstants.Markers.INVOKE_SYNCHRONOUS.toString(), is("INVOKE [ SYNCHRONOUS ]"));
80 public void testInvocationMode() {
81 assertThat(ONAPLogConstants.InvocationMode.SYNCHRONOUS.getMarker(),
82 is(ONAPLogConstants.Markers.INVOKE_SYNCHRONOUS));
83 assertThat(ONAPLogConstants.InvocationMode.ASYNCHRONOUS.getMarker(),
84 is(ONAPLogConstants.Markers.INVOKE_ASYNCHRONOUS));