2 * ============LICENSE_START====================================================
\r
4 * ===========================================================================
\r
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
\r
6 * ===========================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END====================================================
\r
22 package org.onap.aaf.misc.env.impl;
\r
24 import static org.junit.Assert.assertTrue;
\r
25 import static org.mockito.MockitoAnnotations.initMocks;
\r
27 import org.apache.log4j.Level;
\r
28 import org.apache.log4j.Logger;
\r
29 import org.junit.Before;
\r
30 import org.junit.Test;
\r
31 import org.mockito.Mock;
\r
32 import org.mockito.Mockito;
\r
33 import org.onap.aaf.misc.env.APIException;
\r
35 public class JU_Log4JLogTargetTest {
\r
44 public void setup() {
\r
49 public void testLoggable() {
\r
50 Log4JLogTarget logObj = null;
\r
52 logObj = new Log4JLogTarget( "testLogger", Level.DEBUG);
\r
53 } catch (APIException e) {
\r
54 // TODO Auto-generated catch block
\r
55 e.printStackTrace();
\r
57 boolean retVal = logObj.isLoggable();
\r
62 public void testLog() {
\r
63 Log4JLogTarget logObj = null;
\r
65 logObj = new Log4JLogTarget( null, Level.DEBUG);
\r
66 } catch (APIException e) {
\r
67 // TODO Auto-generated catch block
\r
68 e.printStackTrace();
\r
70 logObj.log(new Object[] {"test"});
\r
74 public void testLogThrowable() {
\r
75 Log4JLogTarget logObj = null;
\r
77 logObj = new Log4JLogTarget( null, Level.DEBUG);
\r
78 } catch (APIException e) {
\r
79 // TODO Auto-generated catch block
\r
80 e.printStackTrace();
\r
82 logObj.log(new Throwable("test exception"), new Object[] {"test","test2","",null});
\r
86 public void testPrintf() {
\r
87 Log4JLogTarget logObj = null;
\r
89 logObj = new Log4JLogTarget( "", level);
\r
90 } catch (APIException e) {
\r
91 // TODO Auto-generated catch block
\r
92 e.printStackTrace();
\r
94 logObj.printf("test", new Object[] {"test","test2",""});
\r
99 public void testSetEnv() {
\r
101 Log4JLogTarget.setLog4JEnv("test", Mockito.mock(BasicEnv.class));
\r
102 } catch (APIException e) {
\r
103 // TODO Auto-generated catch block
\r
104 e.printStackTrace();
\r