summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/test/java/org
diff options
context:
space:
mode:
authorAvinashS <avinash.s@huawei.com>2017-10-13 15:12:29 +0530
committerAvinashS <avinash.s@huawei.com>2017-10-13 15:12:29 +0530
commit0cd1abfbaf9ab74d294be36d863d6813f0243489 (patch)
treeab43a581c3b24ba1fef8d5d1f1ea0c184b0a407b /csarvalidation/src/test/java/org
parent20b01aa1fb3d83ccaf7c0918cd722da4b26c038f (diff)
Code cleanup
Change-Id: I02bac5f387273965a622723654895a27202f1182 IssueId: VNFSDK-108 Signed-off-by: AvinashS <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation/src/test/java/org')
-rw-r--r--csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java153
-rw-r--r--csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java20
2 files changed, 87 insertions, 86 deletions
diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
index 782e521..826decb 100644
--- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
+++ b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/CsarValidatorTest.java
@@ -1,23 +1,23 @@
/**
* Copyright 2017 Huawei Technologies Co., Ltd.
- * <p>
+ *
* 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * 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 org.junit.Test;
-import org.onap.validation.csar.CsarValidator;
-import org.onap.validation.csar.FileUtil;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -30,9 +30,9 @@ 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 org.junit.Test;
+import org.onap.validation.csar.CsarValidator;
+import org.onap.validation.csar.FileUtil;
public class CsarValidatorTest {
@@ -59,30 +59,30 @@ public class CsarValidatorTest {
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);
- CsarValidator csarValidator2 = new CsarValidator(packageId2, sample2);
- CsarValidator csarValidator3 = new CsarValidator(packageId3, sample3);
- CsarValidator csarValidator4 = new CsarValidator(packageId4, sample4);
- CsarValidator csarValidator5 = new CsarValidator(packageId5, sample5);
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);
- System.out.println(result4);
- assertEquals(true, result == true && result1 ==true && result2 == true && result3 == true && result4 == true);
+ 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
@@ -113,79 +113,82 @@ public class CsarValidatorTest {
testValidateMainService(csarValidator5);
//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", "");
- 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);
+ 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 testCloseInputStream() {
+ InputStream dir = null;
+ FileUtil.closeInputStream(dir);
+ assertTrue(true);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testReadJsonDatafFromFile() {
+ FileUtil.readJsonDatafFromFile(sample1, null);
+ }
+
+ @Test
+ public void testCloseZipFile() throws ZipException, IOException {
+ File file = new File(sample1);
+ ZipFile dir1 = new ZipFile(file);
+ FileUtil.closeZipFile(dir1);
+ assertTrue(true);
}
+
+ @Test
+ public void testCloseFileStream() throws FileNotFoundException {
+ FileInputStream dir3 = new FileInputStream(sample1);
+ FileUtil.closeFileStream(dir3 );
+ }
+
@Test
- public void testCloseInputStream() {
- InputStream dir = null;
- FileUtil.closeInputStream(dir);
- assertTrue(true);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testReadJsonDatafFromFile() {
- FileUtil.readJsonDatafFromFile(sample1, null);
- }
-
- @Test
- public void testCloseZipFile() throws ZipException, IOException {
- File file = new File(sample1);
- ZipFile dir1 = new ZipFile(file);
- FileUtil.closeZipFile(dir1);
- assertTrue(true);
- }
- @Test
- public void testCloseFileStream() throws FileNotFoundException {
- FileInputStream dir3 = new FileInputStream(sample1);
- FileUtil.closeFileStream(dir3 );
- }
- @Test
- public void testCloseOutptutStream() {
- OutputStream dir4 = new OutputStream() {
-
- @Override
- public void write(int b) throws IOException {
-
- }
- };
- FileUtil.closeOutputStream(dir4);
- }
+ public void testCloseOutptutStream() {
+ OutputStream dir4 = new OutputStream() {
+
+ @Override
+ public void write(int number) throws IOException {
+
+ }
+ };
+ FileUtil.closeOutputStream(dir4);
+ }
private void testValidateCsarMeta(CsarValidator cv) {
- boolean result = cv.validateCsarMeta();
+ boolean result = CsarValidator.validateCsarMeta();
assertEquals(true, result == true);
}
private void testValidateCsarIntegrity(CsarValidator cv) {
- boolean result = cv.validateCsarIntegrity(sample1);
+ boolean result = CsarValidator.validateCsarIntegrity(sample1);
assertEquals(true, result == true);
- }
+ }
private void testValidateToscaMeta(CsarValidator cv) {
- boolean result = cv.validateToscaMeta();
+ boolean result = CsarValidator.validateToscaMeta();
assertEquals(true, result == true);
}
private void testValidateMainService(CsarValidator cv) {
- boolean result = cv.validateMainService();
+ boolean result = CsarValidator.validateMainService();
assertEquals(true, result == true);
}
private void testValidateCsar(CsarValidator cv) {
- boolean result = cv.validateCsar();
+ boolean result = CsarValidator.validateCsar();
assertEquals(true, result == true);
}
}
diff --git a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java
index 61ea3ee..8ab498e 100644
--- a/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java
+++ b/csarvalidation/src/test/java/org/onap/validation/csarvalidationtest/ValidationExceptionTest.java
@@ -1,51 +1,49 @@
/**
* Copyright 2017 Huawei Technologies Co., Ltd.
- *
+ * <p>
* 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
- *
+ * <p>
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
* 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.*;
+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;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
public class ValidationExceptionTest {
- ValidationException validationException = new ValidationException();
+ ValidationException validationException = new ValidationException();
@Test
public void testWrappedInfoThrowableErrorCodes() {
Throwable ex = new IOException();
- ValidationException result = validationException.wrappedInfo(ex, ErrorCodes.FILE_IO);
+ ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO);
assertTrue(true);
}
@Test
public void testWrappedInfoThrowableErrorCodes1() {
Throwable ex = new ValidationException();
- ValidationException result = validationException.wrappedInfo(ex, ErrorCodes.FILE_IO);
+ ValidationException.wrappedInfo(ex, ErrorCodes.FILE_IO);
assertTrue(true);
}
@Test
public void testWrappedInfoThrowableErrorCodes2() {
Throwable ex = new ValidationException();
- ValidationException result = validationException.wrappedInfo(ex, null);
+ ValidationException.wrappedInfo(ex, null);
assertTrue(true);
}
}