From 158248d9e2006e8e5f5c181f07b5aac57cb9ddd0 Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Tue, 4 Aug 2020 12:56:12 +0200 Subject: Migrate from java 8 to java 11 Change-Id: If146dc0d99541a8a14ecc5e504c49a5c433a262f Issue-ID: VNFSDK-631 Signed-off-by: Zebek Bogumil --- csarvalidation/pom.xml | 95 ++++--- .../org/onap/validation/csar/CsarValidator.java | 25 +- .../onap/validation/csar/CsarValidatorTest.java | 291 +++++++++++++++++++++ .../validation/csar/ValidationExceptionTest.java | 50 ++++ .../csarvalidationtest/CsarValidatorTest.java | 239 ----------------- .../ValidationExceptionTest.java | 49 ---- deployment/pom.xml | 8 +- pom.xml | 13 +- 8 files changed, 431 insertions(+), 339 deletions(-) create mode 100644 csarvalidation/src/test/java/org/onap/validation/csar/CsarValidatorTest.java create mode 100644 csarvalidation/src/test/java/org/onap/validation/csar/ValidationExceptionTest.java delete mode 100644 csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java delete mode 100644 csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java diff --git a/csarvalidation/pom.xml b/csarvalidation/pom.xml index 12250c2..0e8cfd4 100644 --- a/csarvalidation/pom.xml +++ b/csarvalidation/pom.xml @@ -34,11 +34,29 @@ + + 2.13.0 + 1.26 + 2.9.4 + 4.12 + 3.2.1 + 2.5 + 1.61 + 5.0.3 + 5.0.2 + 3.11.1 + 1.18.2 + 3.2.2 + 2.6 + 3.0.0 + 3.5.0 + + org.apache.logging.log4j log4j-slf4j-impl - 2.13.0 + ${log4j-slf4j-impl.version} org.slf4j @@ -49,42 +67,37 @@ org.yaml snakeyaml - 1.26 + ${snakeyaml.version} com.fasterxml.jackson.core jackson-core - 2.9.4 + ${jackson-core.version} com.google.guava guava - - junit - junit - 4.12 - test - + org.apache.commons commons-lang3 - 3.2.1 + ${commons-lang3.version} commons-io commons-io - 2.5 + ${commons-io.version} org.bouncycastle bcpkix-jdk15on - 1.61 + ${bcpkix-jdk15on.version} org.onap.cli cli-framework - 5.0.3 + ${cli-framework.version} commons-codec @@ -97,32 +110,42 @@ commons-codec 1.14 + + org.projectlombok + lombok + ${lombok.version} + + + commons-collections + commons-collections + ${commons-collections.version} + + - org.onap.cli - cli-main - 5.0.2 + junit + junit + ${junit.version} test - - org.assertj - assertj-core - 3.11.1 + org.mockito + mockito-core + ${mockito-core.version} test - - org.projectlombok - lombok - 1.18.2 + org.onap.cli + cli-main + ${cli-main.version} + test - commons-collections - commons-collections - 3.2.2 + org.assertj + assertj-core + ${assertj-core.version} + test - @@ -135,7 +158,6 @@ - ${project.artifactId}-${project.version} @@ -143,7 +165,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + ${maven-jar-plugin.version} @@ -153,20 +175,11 @@ - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.8 - 1.8 - - org.apache.maven.plugins maven-dependency-plugin - 3.0.0 + ${maven-dependency-plugin.version} copy-artifact @@ -205,7 +218,7 @@ maven-war-plugin - 2.6 + ${maven-war-plugin.version} false diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java index 86952b1..0478758 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java @@ -97,16 +97,35 @@ public class CsarValidator { } } + static class CsarValidatorSeam { + public String validateCsarMeta() { + return CsarValidator.validateCsarMeta(); + } + + public String validateAndScanToscaMeta(){ + return CsarValidator.validateAndScanToscaMeta(); + } + + public String validateMainService() { + return CsarValidator.validateMainService(); + } + + } + /** * @return true if all validations are successful */ public static String validateCsar() { + return CsarValidator.validateCsarContent(new CsarValidatorSeam()); + } + + static String validateCsarContent(CsarValidatorSeam csarValidatorSeam) { - String vsm = validateCsarMeta(); + String vsm = csarValidatorSeam.validateCsarMeta(); - String vtm = validateAndScanToscaMeta(); + String vtm = csarValidatorSeam.validateAndScanToscaMeta(); - String vms = validateMainService(); + String vms = csarValidatorSeam.validateMainService(); //String r02454 = r02454(); diff --git a/csarvalidation/src/test/java/org/onap/validation/csar/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csar/CsarValidatorTest.java new file mode 100644 index 0000000..bd363fc --- /dev/null +++ b/csarvalidation/src/test/java/org/onap/validation/csar/CsarValidatorTest.java @@ -0,0 +1,291 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * Copyright 2020 Nokia + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.onap.validation.csar; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + + +@RunWith(MockitoJUnitRunner.class) +public class CsarValidatorTest { + + String regex = "^\\/[a-zA-Z]\\:\\/"; + + ClassLoader classLoader = getClass().getClassLoader(); + + Pattern pattern = Pattern.compile(regex); + + private String csarFile = classLoader.getResource("enterprise2DC.csar").getFile(); + + Matcher matcher = pattern.matcher(csarFile); + + String sample1 = System.getProperty("file.separator") + csarFile.substring(1); + + String packageId = UUID.randomUUID().toString(); + + private String csarFile2 = classLoader.getResource("vEPC_NS.csar").getFile(); + + String sample2 = System.getProperty("file.separator") + csarFile2.substring(1); + + String packageId2 = UUID.randomUUID().toString(); + + private String cf = classLoader.getResource("testR02454.csar").getFile(); + + String sample = System.getProperty("file.separator") + cf.substring(1); + + String pkgid = UUID.randomUUID().toString(); + + private String csarFile3 = classLoader.getResource("vIMS_NS.csar").getFile(); + + String sample3 = System.getProperty("file.separator") + csarFile3.substring(1); + + String packageId3 = UUID.randomUUID().toString(); + + private String csarFile4 = classLoader.getResource("VoLTE.csar").getFile(); + + String sample4 = System.getProperty("file.separator") + csarFile4.substring(1); + + String packageId4 = UUID.randomUUID().toString(); + + private String csarFile5 = classLoader.getResource("sample2.csar").getFile(); + + String sample5 = System.getProperty("file.separator") + csarFile5.substring(1); + + String packageId5 = UUID.randomUUID().toString(); + + @Test + public void testAll() throws IOException, InterruptedException { + CsarValidator csarValidator = new CsarValidator(packageId, sample1); + testValidateCsar(csarValidator); + CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2); + testValidateCsar(csarValidator2); + CsarValidator csarValidator3 = new CsarValidator(packageId3, sample3); + testValidateCsar(csarValidator3); + CsarValidator csarValidator4 = new CsarValidator(packageId4, sample4); + testValidateCsar(csarValidator4); + CsarValidator csarValidator5 = new CsarValidator(packageId5, sample5); + testValidateCsar(csarValidator5); + String sample1Dir = sample1.replace(".csar", ""); + String sample2Dir = sample2.replace(".csar", ""); + String sample3Dir = sample3.replace(".csar", ""); + String sample4Dir = sample4.replace(".csar", ""); + String sample5Dir = sample5.replace(".csar", ""); + boolean result = FileUtil.deleteDirectory(sample1Dir); + boolean result1 = FileUtil.deleteDirectory(sample2Dir); + boolean result2 = FileUtil.deleteDirectory(sample3Dir); + boolean result3 = FileUtil.deleteDirectory(sample4Dir); + boolean result4 = FileUtil.deleteDirectory(sample5Dir); + assertEquals(true, result == true && result1 == true && result2 == true && result3 == true && result4 == true); + } + + @Test + public void testIndividual() throws IOException, InterruptedException { + CsarValidator csarValidator = new CsarValidator(packageId, sample1); + testValidateCsarMeta(csarValidator); + testValidateCsarIntegrity(csarValidator); + testValidateToscaMeta(csarValidator); + + CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2); + testValidateCsarIntegrity(csarValidator2); + testValidateToscaMeta(csarValidator2); + testValidateMainService(csarValidator2); + + CsarValidator csarValidator3 = new CsarValidator(packageId3, sample3); + testValidateCsarIntegrity(csarValidator3); + testValidateToscaMeta(csarValidator3); + testValidateMainService(csarValidator3); + + CsarValidator csarValidator4 = new CsarValidator(packageId4, sample4); + testValidateCsarIntegrity(csarValidator4); + testValidateToscaMeta(csarValidator4); + testValidateMainService(csarValidator4); + + CsarValidator csarValidator5 = new CsarValidator(packageId5, sample5); + testValidateCsarIntegrity(csarValidator5); + testValidateToscaMeta(csarValidator5); + testValidateMainService(csarValidator5); + + CsarValidator csarValidator6 = new CsarValidator(pkgid, sample); + testValidateCsarIntegrity(csarValidator6); + testValidateToscaMeta(csarValidator6); + testValidateMainService(csarValidator6); + testR02454(csarValidator6); + // Rel1 specific test case + String sample1Dir = sample1.replace(".csar", ""); + String sample2Dir = sample2.replace(".csar", ""); + String sample3Dir = sample3.replace(".csar", ""); + String sample4Dir = sample4.replace(".csar", ""); + String sample5Dir = sample5.replace(".csar", ""); + String sampleDir = sample.replace(".csar", ""); + boolean result = FileUtil.deleteDirectory(sample1Dir); + boolean result1 = FileUtil.deleteDirectory(sample2Dir); + boolean result2 = FileUtil.deleteDirectory(sample3Dir); + boolean result3 = FileUtil.deleteDirectory(sample4Dir); + boolean result4 = FileUtil.deleteDirectory(sample5Dir); + boolean result5 = FileUtil.deleteDirectory(sampleDir); + assertEquals(true, result == true && result1 == true && result2 == true && result3 == true && result4 == true); + } + + @Test + public void testCloseInputStreamForNonExistingDirectory() { + InputStream dir = null; + FileUtil.closeInputStream(dir); + assertTrue(true); + } + + @Test(expected = ValidationException.class) + public void testCloseInputStream() throws IOException { + InputStream inputStream = mock(InputStream.class); + Mockito.doThrow(new IOException()).when(inputStream).close(); + FileUtil.closeInputStream(inputStream); + assertTrue(true); + } + + @Test + public void testCloseZipFile() throws ZipException, IOException { + File file = new File(sample1); + ZipFile dir1 = new ZipFile(file); + FileUtil.closeZipFile(dir1); + assertTrue(true); + } + + @Test(expected = IOException.class) + public void testCloseFileStream() throws IOException { + FileInputStream dir3 = new FileInputStream(sample1); + FileUtil.closeFileStream(dir3); + dir3.available(); + + } + + @Test(expected = ValidationException.class) + public void testCloseFileStream_reportErrorWhenIOExceptionOccurs() throws IOException { + FileInputStream fileInputStream = mock(FileInputStream.class); + Mockito.doThrow(new IOException()).when(fileInputStream).close(); + FileUtil.closeFileStream(fileInputStream); + } + + @Test + public void testCloseOutptutStream() { + OutputStream dir4 = new OutputStream() { + + @Override + public void write(int number) throws IOException { + + } + }; + FileUtil.closeOutputStream(dir4); + assertTrue(true); + } + + @Test(expected = ValidationException.class) + public void testCloseOutptutStream_reportErrorWhenIOExceptionOccurs() throws IOException { + OutputStream outputStream = mock(OutputStream.class); + Mockito.doThrow(new IOException()).when(outputStream).close(); + FileUtil.closeOutputStream(outputStream); + } + + private void testValidateCsarMeta(CsarValidator cv) { + String result = CsarValidator.validateCsarMeta(); + assertEquals(true, result == CommonConstants.SUCCESS_STR); + } + + private void testValidateCsarIntegrity(CsarValidator cv) { + boolean result = CsarValidator.validateCsarIntegrity(sample1); + assertEquals(true, result == true); + } + + private void testValidateToscaMeta(CsarValidator cv) { + String result = CsarValidator.validateAndScanToscaMeta(); + assertEquals(true, result == CommonConstants.SUCCESS_STR); + } + + private void testValidateMainService(CsarValidator cv) { + + String result = CsarValidator.validateMainService(); + assertEquals(true, result == CommonConstants.SUCCESS_STR); + } + + private void testValidateCsar(CsarValidator cv) { + + String result = CsarValidator.validateCsar(); + assertEquals(true, result == CommonConstants.SUCCESS_STR); + } + + private void testR02454(CsarValidator cv) { + String result = CsarValidator.r02454(); + assertEquals(true, result == CommonConstants.SUCCESS_STR); + } + + @Test + public void testValidateCsar_csarMetaFailed() { + CsarValidator.CsarValidatorSeam csarValidatorSeam = mock(CsarValidator.CsarValidatorSeam.class); + Mockito.when(csarValidatorSeam.validateCsarMeta()).thenReturn("FAIL"); + Mockito.when(csarValidatorSeam.validateAndScanToscaMeta()).thenReturn("SUCCESS"); + Mockito.when(csarValidatorSeam.validateMainService()).thenReturn("FAIL"); + + + String res=CsarValidator.validateCsarContent(csarValidatorSeam); + assertEquals("FAIL OR FAIL",res); + + } + + @Test + public void testValidateCsar_toscaMetaFailed() { + CsarValidator.CsarValidatorSeam csarValidatorSeam = mock(CsarValidator.CsarValidatorSeam.class); + Mockito.when(csarValidatorSeam.validateCsarMeta()).thenReturn("SUCCESS"); + Mockito.when(csarValidatorSeam.validateAndScanToscaMeta()).thenReturn("FAIL"); + Mockito.when(csarValidatorSeam.validateMainService()).thenReturn("SUCCESS"); + + + String res=CsarValidator.validateCsarContent(csarValidatorSeam); + assertEquals("FAIL",res); + } + + @Test + public void testDeleteDir(){ + String dstPath = "./dstPathForTest1"; + File dst = new File(dstPath); + dst.mkdir(); + assertTrue(FileUtil.deleteFile(dstPath)); + } + + @Test + public void testCreateDirectory() { + String dirPath = "src//test//resources//TestDirectory"; + boolean res = FileUtil.createDirectory(dirPath); + assertTrue(res); + } +} diff --git a/csarvalidation/src/test/java/org/onap/validation/csar/ValidationExceptionTest.java b/csarvalidation/src/test/java/org/onap/validation/csar/ValidationExceptionTest.java new file mode 100644 index 0000000..fcbc439 --- /dev/null +++ b/csarvalidation/src/test/java/org/onap/validation/csar/ValidationExceptionTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2020 Nokia + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.onap.validation.csar; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import org.junit.Test; +import org.onap.validation.csar.ErrorCodes; +import org.onap.validation.csar.ValidationException; + +public class ValidationExceptionTest { + ValidationException validationException = new ValidationException(); + + @Test + public void testWrappedInfoThrowableErrorCodes() { + Throwable ex = new IOException(); + ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO); + assertTrue(true); + } + + @Test + public void testWrappedInfoThrowableErrorCodes1() { + Throwable ex = new ValidationException(); + ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO); + assertTrue(true); + } + + @Test + public void testWrappedInfoThrowableErrorCodes2() { + Throwable ex = new ValidationException(); + ValidationException.wrappedInfo(ex, null); + assertTrue(true); + } +} diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java deleted file mode 100644 index 2fe3640..0000000 --- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * Copyright 2017 Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.validation.csarvalidationtest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -import org.junit.Test; -import org.onap.validation.csar.CommonConstants; -import org.onap.validation.csar.CsarValidator; -import org.onap.validation.csar.FileUtil; - -public class CsarValidatorTest { - - String regex = "^\\/[a-zA-Z]\\:\\/"; - - ClassLoader classLoader = getClass().getClassLoader(); - - Pattern pattern = Pattern.compile(regex); - - private String csarFile = classLoader.getResource("enterprise2DC.csar").getFile(); - - Matcher matcher = pattern.matcher(csarFile); - - String sample1 = System.getProperty("file.separator") + csarFile.substring(1); - - String packageId = UUID.randomUUID().toString(); - - private String csarFile2 = classLoader.getResource("vEPC_NS.csar").getFile(); - - String sample2 = System.getProperty("file.separator") + csarFile2.substring(1); - - String packageId2 = UUID.randomUUID().toString(); - - private String cf = classLoader.getResource("testR02454.csar").getFile(); - - String sample = System.getProperty("file.separator") + cf.substring(1); - - String pkgid = UUID.randomUUID().toString(); - - private String csarFile3 = classLoader.getResource("vIMS_NS.csar").getFile(); - - String sample3 = System.getProperty("file.separator") + csarFile3.substring(1); - - String packageId3 = UUID.randomUUID().toString(); - - private String csarFile4 = classLoader.getResource("VoLTE.csar").getFile(); - - String sample4 = System.getProperty("file.separator") + csarFile4.substring(1); - - String packageId4 = UUID.randomUUID().toString(); - - private String csarFile5 = classLoader.getResource("sample2.csar").getFile(); - - String sample5 = System.getProperty("file.separator") + csarFile5.substring(1); - - String packageId5 = UUID.randomUUID().toString(); - - @Test - public void testAll() throws IOException, InterruptedException { - CsarValidator csarValidator = new CsarValidator(packageId, sample1); - testValidateCsar(csarValidator); - CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2); - testValidateCsar(csarValidator2); - CsarValidator csarValidator3 = new CsarValidator(packageId3, sample3); - testValidateCsar(csarValidator3); - CsarValidator csarValidator4 = new CsarValidator(packageId4, sample4); - testValidateCsar(csarValidator4); - CsarValidator csarValidator5 = new CsarValidator(packageId5, sample5); - testValidateCsar(csarValidator5); - String sample1Dir = sample1.replace(".csar", ""); - String sample2Dir = sample2.replace(".csar", ""); - String sample3Dir = sample3.replace(".csar", ""); - String sample4Dir = sample4.replace(".csar", ""); - String sample5Dir = sample5.replace(".csar", ""); - boolean result = FileUtil.deleteDirectory(sample1Dir); - boolean result1 = FileUtil.deleteDirectory(sample2Dir); - boolean result2 = FileUtil.deleteDirectory(sample3Dir); - boolean result3 = FileUtil.deleteDirectory(sample4Dir); - boolean result4 = FileUtil.deleteDirectory(sample5Dir); - assertEquals(true, result == true && result1 == true && result2 == true && result3 == true && result4 == true); - } - - @Test - public void testIndividual() throws IOException, InterruptedException { - CsarValidator csarValidator = new CsarValidator(packageId, sample1); - testValidateCsarMeta(csarValidator); - testValidateCsarIntegrity(csarValidator); - testValidateToscaMeta(csarValidator); - - CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2); - testValidateCsarIntegrity(csarValidator2); - testValidateToscaMeta(csarValidator2); - testValidateMainService(csarValidator2); - - CsarValidator csarValidator3 = new CsarValidator(packageId3, sample3); - testValidateCsarIntegrity(csarValidator3); - testValidateToscaMeta(csarValidator3); - testValidateMainService(csarValidator3); - - CsarValidator csarValidator4 = new CsarValidator(packageId4, sample4); - testValidateCsarIntegrity(csarValidator4); - testValidateToscaMeta(csarValidator4); - testValidateMainService(csarValidator4); - - CsarValidator csarValidator5 = new CsarValidator(packageId5, sample5); - testValidateCsarIntegrity(csarValidator5); - testValidateToscaMeta(csarValidator5); - testValidateMainService(csarValidator5); - - CsarValidator csarValidator6 = new CsarValidator(pkgid, sample); - testValidateCsarIntegrity(csarValidator6); - testValidateToscaMeta(csarValidator6); - testValidateMainService(csarValidator6); - testR02454(csarValidator6); - // Rel1 specific test case - String sample1Dir = sample1.replace(".csar", ""); - String sample2Dir = sample2.replace(".csar", ""); - String sample3Dir = sample3.replace(".csar", ""); - String sample4Dir = sample4.replace(".csar", ""); - String sample5Dir = sample5.replace(".csar", ""); - String sampleDir = sample.replace(".csar", ""); - boolean result = FileUtil.deleteDirectory(sample1Dir); - boolean result1 = FileUtil.deleteDirectory(sample2Dir); - boolean result2 = FileUtil.deleteDirectory(sample3Dir); - boolean result3 = FileUtil.deleteDirectory(sample4Dir); - boolean result4 = FileUtil.deleteDirectory(sample5Dir); - boolean result5 = FileUtil.deleteDirectory(sampleDir); - assertEquals(true, result == true && result1 == true && result2 == true && result3 == true && result4 == true); - } - - @Test - public void testCloseInputStream() { - InputStream dir = null; - FileUtil.closeInputStream(dir); - assertTrue(true); - } - - @Test - public void testCloseZipFile() throws ZipException, IOException { - File file = new File(sample1); - ZipFile dir1 = new ZipFile(file); - FileUtil.closeZipFile(dir1); - assertTrue(true); - } - - @Test(expected = IOException.class) - public void testCloseFileStream() throws IOException { - FileInputStream dir3 = new FileInputStream(sample1); - FileUtil.closeFileStream(dir3); - dir3.available(); - - } - - @Test - public void testCloseOutptutStream() { - OutputStream dir4 = new OutputStream() { - - @Override - public void write(int number) throws IOException { - - } - }; - FileUtil.closeOutputStream(dir4); - assertTrue(true); - } - - private void testValidateCsarMeta(CsarValidator cv) { - String result = CsarValidator.validateCsarMeta(); - assertEquals(true, result == CommonConstants.SUCCESS_STR); - } - - private void testValidateCsarIntegrity(CsarValidator cv) { - boolean result = CsarValidator.validateCsarIntegrity(sample1); - assertEquals(true, result == true); - } - - private void testValidateToscaMeta(CsarValidator cv) { - String result = CsarValidator.validateAndScanToscaMeta(); - assertEquals(true, result == CommonConstants.SUCCESS_STR); - } - - private void testValidateMainService(CsarValidator cv) { - - String result = CsarValidator.validateMainService(); - assertEquals(true, result == CommonConstants.SUCCESS_STR); - } - - private void testValidateCsar(CsarValidator cv) { - - String result = CsarValidator.validateCsar(); - assertEquals(true, result == CommonConstants.SUCCESS_STR); - } - - private void testR02454(CsarValidator cv) { - String result = CsarValidator.r02454(); - assertEquals(true, result == CommonConstants.SUCCESS_STR); - } - - @Test - public void testDeleteDir(){ - String dstPath = "./dstPathForTest1"; - File dst = new File(dstPath); - dst.mkdir(); - assertTrue(FileUtil.deleteFile(dstPath)); - } - - @Test - public void testCreateDirectory() { - String dirPath = "src//test//resources//TestDirectory"; - boolean res = FileUtil.createDirectory(dirPath); - assertTrue(res); - } -} diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java deleted file mode 100644 index 8ab498e..0000000 --- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2017 Huawei Technologies Co., Ltd. - *

- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.validation.csarvalidationtest; - -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import org.junit.Test; -import org.onap.validation.csar.ErrorCodes; -import org.onap.validation.csar.ValidationException; - -public class ValidationExceptionTest { - ValidationException validationException = new ValidationException(); - - @Test - public void testWrappedInfoThrowableErrorCodes() { - Throwable ex = new IOException(); - ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO); - assertTrue(true); - } - - @Test - public void testWrappedInfoThrowableErrorCodes1() { - Throwable ex = new ValidationException(); - ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO); - assertTrue(true); - } - - @Test - public void testWrappedInfoThrowableErrorCodes2() { - Throwable ex = new ValidationException(); - ValidationException.wrappedInfo(ex, null); - assertTrue(true); - } -} diff --git a/deployment/pom.xml b/deployment/pom.xml index 6e21474..bb56d3a 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -16,6 +16,10 @@ --> 4.0.0 + + 2.0 + 1.5 + org.onap.vnfsdk.validation @@ -33,7 +37,7 @@ org.codehaus.gmaven groovy-maven-plugin - 2.0 + ${groovy-maven-plugin.version} @@ -41,7 +45,7 @@ org.codehaus.gmaven gmaven-plugin - 1.5 + ${gmaven-plugin.version} CSAR validator diff --git a/pom.xml b/pom.xml index 616ce5f..b07c75b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ pom + 11 UTF-8 java ${project.build.directory}/surefire-reports @@ -22,8 +23,10 @@ true ${project.version} reuseReports + 3.8.0 + 3.0.2 - + HEAD @@ -40,7 +43,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + ${maven-jar-plugin.version} @@ -56,10 +59,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + ${maven-compiler-plugin.version} - 1.8 - 1.8 + ${java.version} + ${java.version} -- cgit 1.2.3-korg