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;
27 import java.nio.charset.Charset;
30 import org.apache.commons.io.IOUtils;
31 import org.junit.BeforeClass;
32 import org.junit.ClassRule;
33 import org.junit.Rule;
34 import org.onap.aai.config.IntrospectionConfig;
35 import org.onap.aai.config.RestBeanConfig;
36 import org.onap.aai.config.SpringContextAware;
37 import org.onap.aai.edges.EdgeIngestor;
38 import org.onap.aai.introspection.LoaderFactory;
39 import org.onap.aai.introspection.MoxyLoader;
40 import org.onap.aai.nodes.NodeIngestor;
41 import org.onap.aai.rest.db.HttpEntry;
42 import org.onap.aai.serialization.db.EdgeSerializer;
43 import org.onap.aai.setup.AAIConfigTranslator;
44 import org.onap.aai.setup.SchemaLocationsBean;
45 import org.onap.aai.setup.SchemaVersion;
46 import org.onap.aai.setup.SchemaVersions;
47 import org.springframework.beans.factory.annotation.Autowired;
48 import org.springframework.beans.factory.annotation.Value;
49 import org.springframework.test.context.ContextConfiguration;
50 import org.springframework.test.context.TestPropertySource;
51 import org.springframework.test.context.junit4.rules.SpringClassRule;
52 import org.springframework.test.context.junit4.rules.SpringMethodRule;
54 @ContextConfiguration(
55 classes = {SchemaLocationsBean.class, SchemaVersions.class, AAIConfigTranslator.class,
56 EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class,
57 IntrospectionConfig.class, RestBeanConfig.class, GremlinServerSingleton.class})
59 properties = {"schema.uri.base.path = /aai",
60 "schema.ingest.file = src/test/resources/application-test.properties"})
61 public abstract class AAISetup {
63 protected NodeIngestor nodeIngestor;
66 protected LoaderFactory loaderFactory;
69 protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
72 protected HttpEntry traversalHttpEntry;
75 protected HttpEntry traversalUriHttpEntry;
78 protected EdgeSerializer edgeSer;
81 protected EdgeIngestor edgeIngestor;
84 protected SchemaVersions schemaVersions;
87 protected GremlinServerSingleton gremlinServerSingleton;
89 @Value("${schema.uri.base.path}")
90 protected String basePath;
93 public static final SpringClassRule springClassRule = new SpringClassRule();
96 public final SpringMethodRule springMethodRule = new SpringMethodRule();
99 public static void setupBundleconfig() throws Exception {
100 System.setProperty("AJSC_HOME", "./");
101 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
105 public String getPayload(String filename) throws IOException {
107 InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
109 String message = String.format("Unable to find the %s in src/test/resources", filename);
110 assertNotNull(message, inputStream);
112 String resource = IOUtils.toString(inputStream, Charset.defaultCharset());