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