0138f329243b4c0420efd1a9d47304bb9d049abf
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / DataLinkSetup.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 org.junit.BeforeClass;
23 import org.junit.ClassRule;
24 import org.junit.Rule;
25 import org.onap.aai.config.IntrospectionConfig;
26 import org.onap.aai.config.RestBeanConfig;
27 import org.onap.aai.config.SpringContextAware;
28 import org.onap.aai.edges.EdgeIngestor;
29 import org.onap.aai.introspection.LoaderFactory;
30 import org.onap.aai.introspection.MoxyLoader;
31 import org.onap.aai.nodes.NodeIngestor;
32 import org.onap.aai.rest.db.HttpEntry;
33 import org.onap.aai.serialization.db.EdgeSerializer;
34 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
35 import org.onap.aai.setup.AAIConfigTranslator;
36 import org.onap.aai.setup.SchemaLocationsBean;
37 import org.onap.aai.setup.SchemaVersion;
38 import org.onap.aai.setup.SchemaVersions;
39 import org.onap.aai.testutils.TestUtilConfigTranslatorforDataLink;
40 import org.onap.aai.util.AAIConstants;
41 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.beans.factory.annotation.Value;
43 import org.springframework.test.annotation.DirtiesContext;
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
49 import java.util.Map;
50
51
52 @ContextConfiguration(classes = {
53         SchemaLocationsBean.class,
54         SchemaVersions.class,
55                 TestUtilConfigTranslatorforDataLink.class,
56         EdgeIngestor.class,
57         EdgeSerializer.class,
58         NodeIngestor.class,
59         SpringContextAware.class,
60         IntrospectionConfig.class,  
61         RestBeanConfig.class
62 })
63 @TestPropertySource(properties = {
64                 "schema.uri.base.path = /aai",
65                 "schema.xsd.maxoccurs = 5000",
66                 "schema.version.api.default = v4",
67                 "schema.version.edge.label.start = v4",
68                 "schema.version.depth.start = v3",
69                 "schema.version.app.root.start = v4",
70                 "schema.version.related.link.start = v4",
71                 "schema.version.namespace.change.start = v4",
72                 "schema.version.list = v1,v2,v3,v4",
73         "schema.translator.list = config"
74 })
75 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
76 public abstract class DataLinkSetup {
77
78     @ClassRule
79     public static final SpringClassRule springClassRule = new SpringClassRule();
80
81     @Rule
82     public final SpringMethodRule springMethodRule = new SpringMethodRule();
83
84     @Autowired
85         protected  Map<SchemaVersion, MoxyLoader>  moxyLoaderInstance;
86         
87         @Autowired
88         protected HttpEntry traversalHttpEntry;
89         
90         @Autowired
91         protected HttpEntry traversalUriHttpEntry;
92         
93         @Autowired
94         protected NodeIngestor nodeIngestor;
95         
96         @Autowired
97         protected LoaderFactory loaderFactory;
98
99         @Autowired
100         protected SchemaVersions schemaVersions;
101
102         @Value("${schema.uri.base.path}")
103         protected String basePath;
104
105         @Value("${schema.xsd.maxoccurs}")
106         protected String maxOccurs;     
107         
108     protected static final String SERVICE_NAME = "JUNIT";
109
110     @BeforeClass
111     public static void setupBundleconfig() throws Exception {
112         System.setProperty("AJSC_HOME", ".");
113         System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local");
114         System.setProperty("aai.service.name", SERVICE_NAME);
115         QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/bundleconfig-local/etc/oxm/");
116     }
117         
118         
119         
120 }