diff options
3 files changed, 58 insertions, 10 deletions
diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/DownloadCsarManagerTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/DownloadCsarManagerTest.java index 533e081..75dd4a4 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/DownloadCsarManagerTest.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/DownloadCsarManagerTest.java @@ -13,26 +13,34 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.StatusLine; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.DownloadCsarManager; public class DownloadCsarManagerTest { + DownloadCsarManager mgr; + @Test public void test() { - String url=""; - String filepath=""; + String url = ""; + String filepath = ""; mgr.download(url); mgr.download(url, filepath); mgr.getRandomFileName(); } + @Test public void testPrivateConstructor() throws Exception { Constructor constructor = DownloadCsarManager.class.getDeclaredConstructor(); @@ -40,4 +48,35 @@ public class DownloadCsarManagerTest { constructor.setAccessible(true); constructor.newInstance(); } + + @Test + public void getFileNameTest() { + ProtocolVersion version = new ProtocolVersion("HTTP", 1, 1); + StatusLine sl = new BasicStatusLine(version, 200, "success"); + HttpResponse response = new BasicHttpResponse(sl); + response.setHeader("Content-Disposition", "filename"); + DownloadCsarManager.getFileName(response); + } + + @Test + public void downloadTest() { + DownloadCsarManager.download("http://www.baidu.com"); + DownloadCsarManager.download("http://www.baidu.com", "/opt"); + DownloadCsarManager.getRandomFileName(); + } + + @Test + public void getFilePath() { + ProtocolVersion version = new ProtocolVersion("HTTP", 1, 1); + StatusLine sl = new BasicStatusLine(version, 200, "success"); + HttpResponse response = new BasicHttpResponse(sl); + response.setHeader("Content-Disposition", "filename"); + DownloadCsarManager.getFilePath(response); + } + + @Test + public void testUnzip() { + DownloadCsarManager.unzipCSAR("test.zip", "/opt"); + } + } diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtilTest.java b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtilTest.java index 7bcbd14..e98f058 100644 --- a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtilTest.java +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/java/org/onap/vfc/nfvo/vnfm/gvnfm/jujuvnfmadapter/common/YamlUtilTest.java @@ -20,13 +20,13 @@ import java.io.File; import org.junit.Before; import org.junit.Test; -import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.YamlUtil; import org.onap.vfc.nfvo.vnfm.gvnfm.jujuvnfmadapter.common.restclient.ServiceException; import org.yaml.snakeyaml.Yaml; import net.sf.json.JSON; public class YamlUtilTest { + YamlUtil yaml; @Before @@ -38,12 +38,18 @@ public class YamlUtilTest { @Test public void test() throws ServiceException { String yamlName = "src/test/resources/test.yaml"; + String arrayName = "src/test/resources/testArray.yaml"; + JSON json = yaml.yamlToJson(yamlName); + yaml.yamlToJson(arrayName); + String S = yaml.loadYaml(yamlName); + Yaml yaml = new Yaml(); + File file = new File(yamlName); + } - JSON json=yaml.yamlToJson(yamlName); - - String S=yaml.loadYaml(yamlName); - Yaml yaml = new Yaml(); - File file =new File(yamlName); + @Test + public void testFileNotFoundException() throws ServiceException { + yaml.yamlToJson("src/test/resources/abc.yaml"); + yaml.loadYaml("src/test/resources/abc.yaml"); } } diff --git a/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/testArray.yaml b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/testArray.yaml new file mode 100644 index 0000000..d08d0bd --- /dev/null +++ b/juju/juju-vnfmadapter/Juju-vnfmadapterService/service/src/test/resources/testArray.yaml @@ -0,0 +1,3 @@ +- Cat
+- Dog
+- Goldfish
\ No newline at end of file |