Reduce log noise/warnings format to conventions
[so.git] / packages / arquillian-unit-tests / src / test / java / org / openecomp / mso / global_tests / logging / LogsCheckerITCase.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.global_tests.logging;
22
23 import static org.junit.Assert.*;
24
25 import java.io.File;
26 import java.io.IOException;
27
28
29 import org.jboss.arquillian.container.test.api.Deployment;
30 import org.jboss.arquillian.container.test.api.OperateOnDeployment;
31 import org.jboss.arquillian.container.test.api.RunAsClient;
32 import org.jboss.arquillian.container.test.api.Testable;
33 import org.jboss.arquillian.junit.Arquillian;
34 import org.jboss.shrinkwrap.api.Archive;
35 import org.jboss.shrinkwrap.api.ShrinkWrap;
36 import org.jboss.shrinkwrap.api.spec.JavaArchive;
37 import org.jboss.shrinkwrap.api.spec.WebArchive;
38 import org.junit.After;
39 import org.junit.Before;
40 import org.junit.BeforeClass;
41 import org.junit.Test;
42 import org.junit.runner.RunWith;
43
44 import org.openecomp.mso.filesearching.LogFileSearching;
45 import org.openecomp.mso.global_tests.ArquillianPackagerForITCases;
46
47 @RunWith(Arquillian.class)
48 public class LogsCheckerITCase {
49
50
51     @BeforeClass
52     public static void waitBeforeStart() throws InterruptedException {
53         System.out.println("Executing " + LogsCheckerITCase.class.getName());
54
55     }
56
57     @Deployment(name = "log-check", testable = true)
58     public static Archive<?> createAsdcControllerWarDeployment() throws Exception {
59         // Any war could be used here, we just take that one randomly
60         // Be careful some WAR does not work when being injected in JBOSS, probably due to Servlet conflict
61         System.out.println("Deploying ASDC Controller WAR for log checker");
62         WebArchive warArchive = (WebArchive) ArquillianPackagerForITCases.createPackageFromExistingOne("../../asdc-controller/target/", "asdc-controller*.war", "asdc-controller.war");
63
64         JavaArchive testclasses = ShrinkWrap.create(JavaArchive.class, "testClasses.jar");
65
66         testclasses.addPackage("org.openecomp.mso.filesearching");
67
68         warArchive.addAsLibraries(testclasses);
69
70         Testable.archiveToTest(warArchive);
71         return warArchive;
72     }
73
74     @Before
75     public void beforeEachTest() {
76         LogFileSearching.initFile("/tmp/mso-log-checker.log");
77     }
78
79     @After
80     public void afterEachTest() {
81         LogFileSearching.closeFile();
82     }
83
84     @Test
85     @OperateOnDeployment("log-check")
86     public void testJbossServerLog() throws IOException {
87
88         File serverLogs = new File("/opt/jboss/standalone/log");
89         //File serverLogs = new File("/tmp/jbosslogs/server.log");
90
91         assertFalse(LogFileSearching.searchInDirectoryForCommonIssues(null, serverLogs));
92
93     }
94
95     @Test
96     @OperateOnDeployment("log-check")
97     public void testMSOLog() throws IOException {
98         //File serverLogs = new File("/opt/app/mso/jboss-eap-6.2/standalone/log/server.log");
99         File msoLogs = new File("/var/log/ecomp/MSO");
100
101         assertFalse(LogFileSearching.searchInDirectoryForCommonIssues(null, msoLogs));
102
103     }
104
105
106 }