diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java')
-rw-r--r-- | openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java index 4d025e1540..66dda12b4b 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java @@ -41,7 +41,7 @@ import java.util.zip.ZipFile; public class ToscaFileOutputServiceCsarImplTest { - private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl = + private final ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl = new ToscaFileOutputServiceCsarImpl(); @Test @@ -112,21 +112,22 @@ public class ToscaFileOutputServiceCsarImplTest { String resultFileName = "resultFile.zip"; File file = new File(resultFileName); - FileOutputStream fos = new FileOutputStream(file); - fos.write(csarFile); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(csarFile); + } - ZipFile zipFile = new ZipFile(resultFileName); + try (ZipFile zipFile = new ZipFile(resultFileName)) { - Enumeration<? extends ZipEntry> entries = zipFile.entries(); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); - int count = 0; - while (entries.hasMoreElements()) { - count++; - entries.nextElement(); + int count = 0; + while (entries.hasMoreElements()) { + count++; + entries.nextElement(); + } + Assert.assertEquals(7, count); } - Assert.assertEquals(7, count); - zipFile.close(); + Files.delete(Paths.get(file.getPath())); } @@ -150,21 +151,22 @@ public class ToscaFileOutputServiceCsarImplTest { String resultFileName = "resultFile.zip"; File file = new File(resultFileName); - FileOutputStream fos = new FileOutputStream(file); - fos.write(csarFile); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(csarFile); + } - ZipFile zipFile = new ZipFile(resultFileName); + try (ZipFile zipFile = new ZipFile(resultFileName)) { - Enumeration<? extends ZipEntry> entries = zipFile.entries(); + Enumeration<? extends ZipEntry> entries = zipFile.entries(); - int count = 0; - while (entries.hasMoreElements()) { - count++; - entries.nextElement(); + int count = 0; + while (entries.hasMoreElements()) { + count++; + entries.nextElement(); + } + Assert.assertEquals(2, count); } - Assert.assertEquals(2, count); - zipFile.close(); + Files.delete(Paths.get(file.getPath())); } } |