08a7793a1f1e14811edd5424d3b63b569a502413
[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 package org.onap.aai;
21
22 import java.util.Map;
23
24 import org.junit.BeforeClass;
25
26 import org.junit.ClassRule;
27 import org.junit.Rule;
28 import org.onap.aai.config.SpringContextAware;
29 import org.onap.aai.edges.EdgeIngestor;
30 import org.onap.aai.config.IntrospectionConfig;
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.config.RestBeanConfig;
35 import org.onap.aai.rest.db.HttpEntry;
36 import org.onap.aai.setup.AAIConfigTranslator;
37 import org.onap.aai.serialization.db.EdgeSerializer;
38 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
39 import org.onap.aai.setup.SchemaLocationsBean;
40 import org.onap.aai.setup.SchemaVersion;
41 import org.onap.aai.setup.SchemaVersions;
42 import org.onap.aai.util.AAIConstants;
43 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.beans.factory.annotation.Value;
45 import org.springframework.test.context.ContextConfiguration;
46 import org.springframework.test.context.TestPropertySource;
47 import org.springframework.test.context.junit4.rules.SpringClassRule;
48 import org.springframework.test.context.junit4.rules.SpringMethodRule;
49
50
51 @ContextConfiguration(classes = {
52         SchemaLocationsBean.class,
53         SchemaVersions.class,
54         AAIConfigTranslator.class,
55         EdgeIngestor.class,
56         EdgeSerializer.class,
57         NodeIngestor.class,
58         SpringContextAware.class,
59         IntrospectionConfig.class,  
60         RestBeanConfig.class
61 })
62 @TestPropertySource(properties = { "schema.uri.base.path = /aai" })
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     protected static final String SERVICE_NAME = "JUNIT";
93
94     @BeforeClass
95     public static void setupBundleconfig() throws Exception {
96         System.setProperty("AJSC_HOME", ".");
97         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
98         System.setProperty("aai.service.name", SERVICE_NAME);
99         QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
100     }
101         
102         
103         
104 }