summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java
index 37292e5..8f55fa4 100644
--- a/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java
+++ b/src/test/java/org/openecomp/sdc/toscaparser/api/JToscaMetadataParse.java
@@ -5,12 +5,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.util.Collection;
import java.util.LinkedHashMap;
import org.junit.Test;
import org.openecomp.sdc.toscaparser.api.common.JToscaException;
-import org.openecomp.sdc.toscaparser.api.common.JToscaValidationIssue;
+import org.openecomp.sdc.toscaparser.api.utils.JToscaErrorCodes;
import org.openecomp.sdc.toscaparser.api.utils.ThreadLocalsHolder;
public class JToscaMetadataParse {
@@ -29,11 +28,34 @@ public class JToscaMetadataParse {
@Test
public void noWarningsAfterParse() throws JToscaException {
- String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/tmpCSAR_Huawei_vSPGW_fixed.csar.csar").getFile();
+ String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/tmpCSAR_Huawei_vSPGW_fixed.csar").getFile();
File file = new File(fileStr);
ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
int validationIssuesCaught = ThreadLocalsHolder.getCollector().validationIssuesCaught();
assertTrue(validationIssuesCaught == 0 );
}
-
+
+ @Test
+ public void testEmptyCsar() throws JToscaException {
+ String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("csars/emptyCsar.csar").getFile();
+ File file = new File(fileStr);
+ try {
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ } catch (JToscaException e) {
+ assertTrue(e.getCode().equals(JToscaErrorCodes.INVALID_CSAR_FORMAT.getValue()));
+ }
+ int validationIssuesCaught = ThreadLocalsHolder.getCollector().validationIssuesCaught();
+ assertTrue(validationIssuesCaught == 0 );
+ }
+
+ @Test
+ public void testEmptyPath() throws JToscaException {
+ String fileStr = JToscaMetadataParse.class.getClassLoader().getResource("").getFile();
+ File file = new File(fileStr);
+ try {
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ }catch (JToscaException e) {
+ assertTrue(e.getCode().equals(JToscaErrorCodes.PATH_NOT_VALID.getValue()));
+ }
+ }
}