2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.queries;
22 import org.apache.commons.io.IOUtils;
23 import org.junit.BeforeClass;
24 import org.junit.ClassRule;
25 import org.junit.Rule;
26 import org.onap.aai.config.IntrospectionConfig;
27 import org.onap.aai.config.RestBeanConfig;
28 import org.onap.aai.config.SpringContextAware;
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.rest.db.HttpEntry;
34 import org.onap.aai.serialization.db.EdgeSerializer;
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.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.beans.factory.annotation.Value;
41 import org.springframework.test.context.ContextConfiguration;
42 import org.springframework.test.context.TestPropertySource;
43 import org.springframework.test.context.junit4.rules.SpringClassRule;
44 import org.springframework.test.context.junit4.rules.SpringMethodRule;
46 import java.io.IOException;
47 import java.io.InputStream;
50 import static org.junit.Assert.assertNotNull;
52 @ContextConfiguration(classes = {
53 SchemaLocationsBean.class,
55 AAIConfigTranslator.class,
59 SpringContextAware.class,
60 IntrospectionConfig.class ,
62 GremlinServerSingleton.class
64 @TestPropertySource(properties = {
65 "schema.uri.base.path = /aai",
66 "schema.ingest.file = src/test/resources/application-test.properties"
68 public abstract class AAISetup {
70 protected NodeIngestor nodeIngestor;
73 protected LoaderFactory loaderFactory;
76 protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
79 protected HttpEntry traversalHttpEntry;
82 protected HttpEntry traversalUriHttpEntry;
85 protected EdgeSerializer edgeSer;
88 protected EdgeIngestor edgeIngestor;
91 protected SchemaVersions schemaVersions;
94 protected GremlinServerSingleton gremlinServerSingleton;
96 @Value("${schema.uri.base.path}")
97 protected String basePath;
100 public static final SpringClassRule springClassRule = new SpringClassRule();
103 public final SpringMethodRule springMethodRule = new SpringMethodRule();
106 public static void setupBundleconfig() throws Exception {
107 System.setProperty("AJSC_HOME", "./");
108 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
112 public String getPayload(String filename) throws IOException {
114 InputStream inputStream = getClass()
116 .getResourceAsStream(filename);
118 String message = String.format("Unable to find the %s in src/test/resources", filename);
119 assertNotNull(message, inputStream);
121 String resource = IOUtils.toString(inputStream);