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=========================================================
21 package org.onap.aai.queries;
23 import static org.junit.Assert.assertNotNull;
25 import java.io.IOException;
26 import java.io.InputStream;
29 import org.apache.commons.io.IOUtils;
30 import org.junit.BeforeClass;
31 import org.junit.ClassRule;
32 import org.junit.Rule;
33 import org.onap.aai.config.IntrospectionConfig;
34 import org.onap.aai.config.RestBeanConfig;
35 import org.onap.aai.config.SpringContextAware;
36 import org.onap.aai.edges.EdgeIngestor;
37 import org.onap.aai.introspection.LoaderFactory;
38 import org.onap.aai.introspection.MoxyLoader;
39 import org.onap.aai.nodes.NodeIngestor;
40 import org.onap.aai.rest.db.HttpEntry;
41 import org.onap.aai.serialization.db.EdgeSerializer;
42 import org.onap.aai.setup.AAIConfigTranslator;
43 import org.onap.aai.setup.SchemaLocationsBean;
44 import org.onap.aai.setup.SchemaVersion;
45 import org.onap.aai.setup.SchemaVersions;
46 import org.springframework.beans.factory.annotation.Autowired;
47 import org.springframework.beans.factory.annotation.Value;
48 import org.springframework.test.context.ContextConfiguration;
49 import org.springframework.test.context.TestPropertySource;
50 import org.springframework.test.context.junit4.rules.SpringClassRule;
51 import org.springframework.test.context.junit4.rules.SpringMethodRule;
53 @ContextConfiguration(
54 classes = {SchemaLocationsBean.class, SchemaVersions.class, AAIConfigTranslator.class,
55 EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class,
56 IntrospectionConfig.class, RestBeanConfig.class, GremlinServerSingleton.class})
58 properties = {"schema.uri.base.path = /aai",
59 "schema.ingest.file = src/test/resources/application-test.properties"})
60 public abstract class AAISetup {
62 protected NodeIngestor nodeIngestor;
65 protected LoaderFactory loaderFactory;
68 protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
71 protected HttpEntry traversalHttpEntry;
74 protected HttpEntry traversalUriHttpEntry;
77 protected EdgeSerializer edgeSer;
80 protected EdgeIngestor edgeIngestor;
83 protected SchemaVersions schemaVersions;
86 protected GremlinServerSingleton gremlinServerSingleton;
88 @Value("${schema.uri.base.path}")
89 protected String basePath;
92 public static final SpringClassRule springClassRule = new SpringClassRule();
95 public final SpringMethodRule springMethodRule = new SpringMethodRule();
98 public static void setupBundleconfig() throws Exception {
99 System.setProperty("AJSC_HOME", "./");
100 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
104 public String getPayload(String filename) throws IOException {
106 InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
108 String message = String.format("Unable to find the %s in src/test/resources", filename);
109 assertNotNull(message, inputStream);
111 String resource = IOUtils.toString(inputStream);