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=========================================================
22 import static org.junit.Assert.assertNotNull;
24 import java.io.IOException;
25 import java.io.InputStream;
28 import org.apache.commons.io.IOUtils;
29 import org.junit.BeforeClass;
30 import org.onap.aai.config.*;
31 import org.onap.aai.dbgraphmap.SearchGraph;
32 import org.onap.aai.edges.EdgeIngestor;
33 import org.onap.aai.introspection.LoaderFactory;
34 import org.onap.aai.nodes.NodeIngestor;
35 import org.onap.aai.rest.db.HttpEntry;
36 import org.onap.aai.rest.dsl.DslQueryProcessor;
37 import org.onap.aai.rest.search.GremlinServerSingleton;
38 import org.onap.aai.serialization.db.EdgeSerializer;
39 import org.onap.aai.setup.AAIConfigTranslator;
40 import org.onap.aai.setup.SchemaVersion;
41 import org.onap.aai.setup.SchemaVersions;
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.onap.aai.introspection.MoxyLoader;
46 import org.onap.aai.setup.SchemaLocationsBean;
47 import org.junit.ClassRule;
48 import org.junit.Rule;
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(classes = {
54 ConfigConfiguration.class,
55 AAIConfigTranslator.class,
59 SpringContextAware.class,
60 IntrospectionConfig.class ,
62 SearchConfiguration.class,
63 DslConfiguration.class,
64 GremlinServerSingleton.class
66 @TestPropertySource(properties = {
67 "schema.uri.base.path = /aai",
68 "schema.ingest.file = src/test/resources/application-test.properties"
70 public abstract class AAISetup {
72 protected NodeIngestor nodeIngestor;
75 protected LoaderFactory loaderFactory;
78 protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
81 protected HttpEntry traversalHttpEntry;
84 protected HttpEntry traversalUriHttpEntry;
87 protected SearchGraph searchGraph;
90 protected EdgeSerializer edgeSer;
93 protected EdgeIngestor edgeIngestor;
96 protected DslQueryProcessor dslQueryProcessor;
99 protected SchemaVersions schemaVersions;
102 protected GremlinServerSingleton gremlinServerSingleton;
104 @Value("${schema.uri.base.path}")
105 protected String basePath;
108 public static final SpringClassRule springClassRule = new SpringClassRule();
111 public final SpringMethodRule springMethodRule = new SpringMethodRule();
114 public static void setupBundleconfig() throws Exception {
115 System.setProperty("AJSC_HOME", "./");
116 System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
120 public String getPayload(String filename) throws IOException {
122 InputStream inputStream = getClass()
124 .getResourceAsStream(filename);
126 String message = String.format("Unable to find the %s in src/test/resources", filename);
127 assertNotNull(message, inputStream);
129 String resource = IOUtils.toString(inputStream);