springboot 2.7 upgrade
[aai/babel.git] / src / test / java / org / onap / aai / babel / TestApplication.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Copyright (c) 2017-2019 European Software Marketing Ltd.
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.aai.babel;
23
24 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
25 import static org.junit.jupiter.api.Assertions.assertThrows;
26 import static org.junit.jupiter.api.Assertions.assertTrue;
27
28 import org.junit.jupiter.api.BeforeEach;
29 import org.junit.jupiter.api.Test;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.test.context.ActiveProfiles;
32 import org.springframework.test.context.TestPropertySource;
33
34 @SpringBootTest(
35     classes = BabelApplication.class,
36     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
37 )
38 @ActiveProfiles("test")
39 @TestPropertySource(properties = {
40     "APP_HOME=.",
41     "CONFIG_HOME=src/test/resources"
42 })
43 public class TestApplication {
44
45     @BeforeEach
46     public void init() {
47         System.setProperty("APP_HOME", ".");
48         System.setProperty("CONFIG_HOME", "src/test/resources");
49     }
50
51     @Test
52     public void testApplicationStarts() {
53         assertDoesNotThrow(() -> {
54             BabelApplication.main(new String[] {});
55             BabelApplication.exit();
56         });
57     }
58
59     @Test
60     public void testApplicationStartsWithObfuscatedPassword() {
61         assertDoesNotThrow(() -> {
62             BabelApplication.main(new String[] {});
63             BabelApplication.exit();
64         });
65     }
66
67     @Test
68     public void testApplicationWithNullArgs() {
69         Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
70             BabelApplication.main(null);
71         });
72         assertTrue(exception.getMessage().contains("Args must not be null"));
73     }
74
75 }