3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * Copyright (c) 2020 Nokia. All rights reserved.
8 * * ================================================================================
9 * * Licensed under the Apache License, Version 2.0 (the "License");
10 * * you may not use this file except in compliance with the License.
11 * * You may obtain a copy of the License at
13 * * http://www.apache.org/licenses/LICENSE-2.0
15 * * Unless required by applicable law or agreed to in writing, software
16 * * distributed under the License is distributed on an "AS IS" BASIS,
17 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * * See the License for the specific language governing permissions and
19 * * limitations under the License.
20 * * ============LICENSE_END=========================================================
25 package org.onap.blueprintgenerator;
28 import java.io.IOException;
29 import java.nio.file.Paths;
30 import org.apache.commons.io.FileUtils;
31 import org.junit.AfterClass;
32 import org.junit.Assert;
33 import org.junit.BeforeClass;
34 import org.junit.FixMethodOrder;
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.junit.runners.MethodSorters;
40 * @author : Ravi Mantena
41 * @date 10/16/2020 Application: ONAP - Blueprint Generator ONAP Bueprint Jar Comparision with Previos version to make
42 * sure Bps are not broken with new changes
45 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
46 public class BlueprintJarComparatorTest {
48 private static final String ves = "ves.json";
49 private static final String testImports = "testImports.yaml";
50 private static final String previousJarVersion = "1.7.0-SNAPSHOT";
51 private static final String latestJarVersion = "1.7.1-SNAPSHOT";
52 private static final String previousVersion = "0_1";
53 private static final String latestVersion = "1_0";
54 private static final String latestJarPath = buildPathAsString("target");
55 private static final String previousJarPath = buildPathAsString("src", "test", "resources", "archives");
56 private static final String inputPath = buildPathAsString("src", "test", "resources", "componentspecs");
57 private static final String outputPath = buildPathAsString("src", "test", "resources", "outputfiles");
58 private static final String previousJar = "blueprint-generator-onap-executable-" + previousJarVersion + ".jar";
59 private static final String latestJar = "blueprint-generator-onap-executable-" + latestJarVersion + ".jar";
63 public static void filesCleanup() throws IOException {
64 FileUtils.deleteDirectory(new File(outputPath));
67 private static String buildPathAsString(String first, String... more) {
68 return Paths.get(first, more).toAbsolutePath().toString() + File.separator;
72 public void jarTestVeswithDmaapK8s() throws IOException, InterruptedException {
73 String inputFileName = ves;
74 String outputFileName = "dcae-ves-collector-dmaap-";
75 String inputImportsFileName = testImports;
77 Process process = runBpgenWithDmaap(inputFileName, outputFileName, inputImportsFileName, previousJarPath,
78 previousJar, previousVersion);
80 Process process1 = runBpgenWithDmaap(inputFileName, outputFileName, inputImportsFileName, latestJarPath,
81 latestJar, latestVersion);
87 "The BluePrint files (" + outputFileName + ") for " + inputFileName + " with -m option don't match!",
88 FileUtils.readFileToString(new File(outputPath + outputFileName + previousVersion + ".yaml"), "utf-8"),
89 FileUtils.readFileToString(new File(outputPath + outputFileName + latestVersion + ".yaml"), "utf-8"));
93 public void jarTestVeswithoutDmaapK8s() throws IOException, InterruptedException {
94 String inputFileName = ves;
95 String outputFileName = "dcae-ves-collector-";
96 String inputImportsFileName = testImports;
98 Process process = runBpgenWithoutDmaap(inputFileName, outputFileName, inputImportsFileName, previousJarPath,
99 previousJar, previousVersion);
101 Process process1 = runBpgenWithoutDmaap(inputFileName, outputFileName, inputImportsFileName, latestJarPath,
102 latestJar, latestVersion);
108 "The BluePrint files (" + outputFileName + ") for " + inputFileName + " with -m option dont match!",
109 FileUtils.readFileToString(new File(outputPath + outputFileName + previousVersion + ".yaml"), "utf-8"),
110 FileUtils.readFileToString(new File(outputPath + outputFileName + latestVersion + ".yaml"), "utf-8"));
113 private Process runBpgenWithoutDmaap(String inputFileName, String outputFileName, String inputImportsFileName,
114 String jarPath, String jarName, String outputFileVersion) throws IOException {
115 String jarCommand = "java -jar " + jarPath + jarName + " app ONAP -i " + inputPath + inputFileName + " -p " +
116 outputPath + " -n " + outputFileName + outputFileVersion + " -t " + inputPath + inputImportsFileName;
117 return Runtime.getRuntime().exec(jarCommand);
120 private Process runBpgenWithDmaap(String inputFileName, String outputFileName, String inputImportsFileName,
121 String jarPath, String jarName, String outputFileVersion) throws IOException {
122 String jarCommand = "java -jar " + jarPath + jarName + " app ONAP -i " + inputPath + inputFileName + " -p " +
123 outputPath + " -n " + outputFileName + outputFileVersion + " -t " + inputPath + inputImportsFileName
125 return Runtime.getRuntime().exec(jarCommand);