aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-heat-lib
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2017-10-24 11:20:03 +0300
committervempo <vitaliy.emporopulo@amdocs.com>2017-10-24 11:24:03 +0300
commit43645dccbaced7a45b37f9e05221186231c39d74 (patch)
tree4e503cc762adf04d95366e08955c5ba5bd4b8c59 /openecomp-be/lib/openecomp-heat-lib
parentaa61644704edc4b2ef231d75b537b38d0ae6d7c6 (diff)
Fixed resources not being closed in tests
Fixed static analysis violations in a few modules of SDC onboarding - high-severity issues like not releasing resources (e.g. FileInputStream). Did some minor code cleanup. Change-Id: I89a229ad6bc150951f1f3cc437b3a175a663e203 Issue-ID: SDC-291 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-heat-lib')
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java13
-rw-r--r--openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java12
2 files changed, 14 insertions, 11 deletions
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
index fc01e2e8b0..6312e5a575 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/EnvironmentTest.java
@@ -23,16 +23,18 @@ package org.openecomp.sdc.heat.datatypes.model;
import org.junit.Test;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import java.io.IOException;
import java.io.InputStream;
public class EnvironmentTest {
@Test
- public void testYamlToServiceTemplateObj() {
+ public void testYamlToServiceTemplateObj() throws IOException {
YamlUtil yamlUtil = new YamlUtil();
- InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/envSettings.env");
- Environment envVars = yamlUtil.yamlToObject(yamlFile, Environment.class);
- envVars.toString();
+ try (InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/envSettings.env")) {
+ Environment envVars = yamlUtil.yamlToObject(yamlFile, Environment.class);
+ envVars.toString();
+ }
}
@Test
@@ -46,9 +48,8 @@ public class EnvironmentTest {
if (heatResourceName.length() == lastIndexOfUnderscore) {
System.out.println(heatResourceName);
} else {
- String heatResourceNameSuffix = heatResourceName.substring(lastIndexOfUnderscore + 1);
+
try {
- int heatResourceNameSuffixInt = Integer.parseInt(heatResourceNameSuffix);
System.out.println(heatResourceName.substring(0, lastIndexOfUnderscore));
} catch (NumberFormatException ignored) {
System.out.println(heatResourceName);
diff --git a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
index 3715b0f999..dd8abdc0b9 100644
--- a/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
+++ b/openecomp-be/lib/openecomp-heat-lib/src/test/java/org/openecomp/sdc/heat/datatypes/model/HeatOrchestrationTemplateTest.java
@@ -26,6 +26,7 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.services.YamlUtil;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@@ -37,12 +38,13 @@ public class HeatOrchestrationTemplateTest {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@Test
- public void testYamlToServiceTemplateObj() {
+ public void testYamlToServiceTemplateObj() throws IOException {
YamlUtil yamlUtil = new YamlUtil();
- InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/testHeat.yml");
- HeatOrchestrationTemplate heatOrchestrationTemplate =
- yamlUtil.yamlToObject(yamlFile, HeatOrchestrationTemplate.class);
- heatOrchestrationTemplate.toString();
+ try (InputStream yamlFile = yamlUtil.loadYamlFileIs("/mock/model/testHeat.yml")) {
+ HeatOrchestrationTemplate heatOrchestrationTemplate =
+ yamlUtil.yamlToObject(yamlFile, HeatOrchestrationTemplate.class);
+ heatOrchestrationTemplate.toString();
+ }
}
@Test