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