3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Licensed under the Apache License, Version 2.0 (the "License");
9 * * you may not use this file except in compliance with the License.
10 * * You may obtain a copy of the License at
12 * * http://www.apache.org/licenses/LICENSE-2.0
14 * * Unless required by applicable law or agreed to in writing, software
15 * * distributed under the License is distributed on an "AS IS" BASIS,
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * * See the License for the specific language governing permissions and
18 * * limitations under the License.
19 * * ============LICENSE_END=========================================================
25 package org.onap.blueprintgenerator.test;
27 import org.apache.commons.io.FileUtils;
28 import org.junit.Assert;
29 import org.junit.FixMethodOrder;
30 import org.junit.Ignore;
31 import org.junit.Test;
32 import org.junit.jupiter.api.Order;
33 import org.junit.runners.MethodSorters;
34 import org.onap.blueprintgenerator.test.BlueprintGeneratorTests;
37 import java.io.IOException;
38 import java.nio.file.Paths;
42 * @author : Ravi Mantena
44 * Application: ONAP - Blueprint Generator
45 * ONAP Bueprint Jar Comparision with Previos version to make sure Bps are not broken with new changes
50 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
51 public class BlueprintJarComparatorTest extends BlueprintGeneratorTests {
53 private String previousJarVersion = "0.1";
54 private String latestJarVersion = "1.0";
55 private String previousVersion = "0_1";
56 private String latestVersion = "1_0";
57 private String latestJarPath = Paths.get("target").toAbsolutePath().toString() + "\\";
58 private String previousJarPath = Paths.get("src", "test", "resources", "archives").toAbsolutePath().toString() + "\\";
59 private String inputPath = Paths.get("src", "test", "resources", "componentspecs").toAbsolutePath().toString() + "\\";
60 private String inputPolicyPath = Paths.get("src", "test", "resources", "policyjson").toAbsolutePath().toString() + "\\";
61 private String outputPath = Paths.get("src", "test", "resources", "outputfiles").toAbsolutePath().toString() + "\\";
62 private String previousJar = "onap-blueprint-generator-" + previousJarVersion + ".jar";
63 private String latestJar = "onap-blueprint-generator-" + latestJarVersion + ".jar";
67 public void filesCleanup() throws IOException {
68 FileUtils.deleteDirectory(new File(outputPath));
72 public void jarTestVeswithDmaapK8s() throws IOException, InterruptedException {
73 String inputFileName = ves;
74 String outputFileName = "dcae-ves-collector-dmaap-";
75 String inputImportsFileName = testImports;
77 String previousJarCommand = "java -jar " + previousJarPath + previousJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath +
78 " -n " + outputFileName + previousVersion + " -t " + inputPath + inputImportsFileName + " -d";
79 Runtime.getRuntime().exec(previousJarCommand);
81 String latestJarCommand = "java -jar " + latestJarPath + latestJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath +
82 " -n " + outputFileName + latestVersion + " -t " + inputPath + inputImportsFileName + " -d";
83 Runtime.getRuntime().exec(latestJarCommand);
87 Assert.assertEquals("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 String previousJarCommand = "java -jar " + previousJarPath + previousJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath +
99 " -n " + outputFileName + previousVersion + " -t " + inputPath + inputImportsFileName ;
100 Runtime.getRuntime().exec(previousJarCommand);
102 String latestJarCommand = "java -jar " + latestJarPath + latestJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath +
103 " -n " + outputFileName + latestVersion + " -t " + inputPath + inputImportsFileName ;
104 Runtime.getRuntime().exec(latestJarCommand);
108 Assert.assertEquals("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"));