Spring-boot 3.1 update
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / AAISetup.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 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.onap.aai;
22
23 import java.lang.reflect.Field;
24 import java.util.Map;
25
26 import org.junit.BeforeClass;
27 import org.junit.ClassRule;
28 import org.junit.Rule;
29 import org.onap.aai.config.*;
30 import org.onap.aai.edges.EdgeIngestor;
31 import org.onap.aai.introspection.LoaderFactory;
32 import org.onap.aai.introspection.MoxyLoader;
33 import org.onap.aai.nodes.NodeIngestor;
34 import org.onap.aai.prevalidation.ValidationConfiguration;
35 import org.onap.aai.prevalidation.ValidationService;
36 import org.onap.aai.rest.db.HttpEntry;
37 import org.onap.aai.rest.notification.NotificationService;
38 import org.onap.aai.serialization.db.EdgeSerializer;
39 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
40 import org.onap.aai.setup.AAIConfigTranslator;
41 import org.onap.aai.setup.SchemaVersion;
42 import org.onap.aai.setup.SchemaVersions;
43 import org.onap.aai.util.AAIConstants;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.beans.factory.annotation.Value;
46 import org.springframework.test.context.ContextConfiguration;
47 import org.springframework.test.context.TestPropertySource;
48 import org.springframework.test.context.junit4.rules.SpringClassRule;
49 import org.springframework.test.context.junit4.rules.SpringMethodRule;
50 import org.springframework.test.context.web.WebAppConfiguration;
51
52 @WebAppConfiguration
53 @ContextConfiguration(
54         classes = {ConfigConfiguration.class, AAIConfigTranslator.class, EdgeIngestor.class, EdgeSerializer.class,
55                 NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, RestBeanConfig.class,
56                 XmlFormatTransformerConfiguration.class, ValidationService.class, ValidationConfiguration.class,
57                 KafkaConfig.class, LoaderFactory.class, NotificationService.class})
58 @TestPropertySource(
59         properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.translator.list=config",
60                 "schema.nodes.location=src/test/resources/onap/oxm",
61                 "schema.edges.location=src/test/resources/onap/dbedgerules",
62                 "aai.notifications.enabled=false"})
63 public abstract class AAISetup {
64
65     @ClassRule
66     public static final SpringClassRule springClassRule = new SpringClassRule();
67
68     @Rule
69     public final SpringMethodRule springMethodRule = new SpringMethodRule();
70
71     @Autowired
72     protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
73
74     @Autowired
75     protected HttpEntry traversalHttpEntry;
76
77     @Autowired
78     protected HttpEntry traversalUriHttpEntry;
79
80     @Autowired
81     protected NodeIngestor nodeIngestor;
82
83     @Autowired
84     protected LoaderFactory loaderFactory;
85
86     @Autowired
87     protected SchemaVersions schemaVersions;
88
89     @Value("${schema.uri.base.path}")
90     protected String basePath;
91
92     @Value("${schema.xsd.maxoccurs}")
93     protected String maxOccurs;
94
95     protected static final String SERVICE_NAME = "JUNIT";
96
97     @BeforeClass
98     public static void setupBundleconfig() throws Exception {
99         System.setProperty("AJSC_HOME", ".");
100         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
101         System.setProperty("aai.service.name", SERVICE_NAME);
102         // Field etcHomeField = AAIConstants.class.getField("AAI_HOME_ETC_OXM");
103         // QueryFormatTestHelper.setFinalStatic(etcHomeField,
104         //         "src/test/resources/bundleconfig-local/etc/oxm/");
105     }
106
107 }