summaryrefslogtreecommitdiffstats
path: root/vnfmarket-be
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket-be')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java12
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java14
2 files changed, 16 insertions, 10 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
index a080cb03..ce6ae72e 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
@@ -46,8 +46,6 @@ public final class FileUtil {
private static final int MAX_PACKAGE_SIZE = 50 * 1024 * 1024;
- private static final int TRY_COUNT = 3;
-
private FileUtil() {
//Empty constructor
}
@@ -61,17 +59,11 @@ public final class FileUtil {
*/
public static boolean createDirectory(String dir) {
File folder = new File(dir);
- int tryCount = 0;
- while (tryCount < TRY_COUNT) {
- tryCount++;
if (!folder.exists() && !folder.mkdirs()) {
- continue;
+ return false;
} else {
return true;
}
- }
-
- return folder.exists();
}
/**
@@ -128,7 +120,7 @@ public final class FileUtil {
}
try (InputStream input = zipFile.getInputStream(entry);
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));) {
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));) {
int length = 0;
while ((length = input.read(buffer)) != -1) {
bos.write(buffer, 0, length);
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
index 11cce8fb..0452e32d 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/resource/PackageResourceTest.java
@@ -1146,6 +1146,9 @@ public class PackageResourceTest {
onBoardResultObj.setOperStatus(1);
boolean res = FileUtil.writeJsonDatatoFile(filePath, onBoardResultObj);
assertEquals(res, true);
+ String filePath1 = "src//test//resources";
+ res = FileUtil.writeJsonDatatoFile(filePath1, onBoardResultObj);
+ assertEquals(res, false);
}
@@ -1163,6 +1166,10 @@ public class PackageResourceTest {
String dirPath = "src//test//resources//TestDirectory";
boolean res = FileUtil.deleteFile(dirPath);
assertEquals(res, true);
+ String dirPath1 = "src//test//resources11";
+ res = FileUtil.deleteFile(dirPath1);
+ assertEquals(res, true);
+
}
@Test
@@ -1345,6 +1352,13 @@ public class PackageResourceTest {
}
@Test
+ public void testvalidateFile() {
+ File fileData= null;
+ boolean res = FileUtil.validateFile(fileData);
+ assertEquals(res, false);
+ }
+
+ @Test
public void testGetPkgSize() {
long pkgSize = PackageWrapperUtil.getPacakgeSize("src/test/resources/Test.txt");
assertNotNull(pkgSize);