diff options
Diffstat (limited to 'vnf-sdk-function-test')
6 files changed, 184 insertions, 2 deletions
diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java index 6b40ed2..317f957 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/util/RestResponseUtil.java @@ -35,7 +35,7 @@ public class RestResponseUtil { public static Response getErrorResponse(Object obj) { if(obj != null) { - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(GsonUtil.objectToString(obj)).build(); } else { return Response.serverError().build(); } diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestExceptionTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestExceptionTest.java new file mode 100644 index 0000000..a54247d --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/exception/VnfSdkFuncTestExceptionTest.java @@ -0,0 +1,41 @@ +/* + * 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.openo.vnfsdk.functest.exception; + +import org.junit.Before; +import org.junit.Test; + +public class VnfSdkFuncTestExceptionTest { + + private VnfSdkFuncTestException sdkFuncTestException; + + @Before + public void setup() { + sdkFuncTestException = new VnfSdkFuncTestException(); + } + + @Test + public void testSetErrorCode() { + sdkFuncTestException.setErrorCode("1001"); + } + + @Test + public void testSetErrorMsg() { + sdkFuncTestException.setErrorMsg("message"); + + } +} diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java index 17b37a7..3cb5823 100644 --- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java @@ -39,4 +39,21 @@ public class ServiceRegisterEntityTest { } + @Test + public void testSetVersion() { + serviceRegistry.setVersion("5.6"); + + } + + @Test + public void testSetProtocol() { + serviceRegistry.setProtocol("http"); + } + + @Test + public void testSetVisualRange() { + serviceRegistry.setVisualRange("range"); + + } + } diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java new file mode 100644 index 0000000..99fa46d --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/util/TestGsonUtil.java @@ -0,0 +1,40 @@ +/* + * 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.openo.vnfsdk.functest.util; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class TestGsonUtil { + + @Test + public void testGenerateId() { + assertNotNull(GsonUtil.generateId()); + } + + @Test + public void testIsNotEmpty() { + assertTrue(GsonUtil.isNotEmpty("junittestcase")); + } + + @Test + public void testGetNowTime() { + assertNotNull(GsonUtil.getNowTime()); + } +} diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java new file mode 100644 index 0000000..2124924 --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/FileUtilTest.java @@ -0,0 +1,68 @@ +/* + * 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.openo.vnfsdk.functests; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; + +import org.junit.Test; +import org.openo.vnfsdk.functest.FileUtil; + +public class FileUtilTest { + + private String createDirPath = "C:/Users/Administrator/Desktop/Unzip"; + + private String deleteDirPath = "D:/deletefolder"; + + private String zipFileName = "src/test/resources/RobotScript.zip"; + + private String extractZip = "D:/Test/AA"; + + private String getDirectory = "D:/Test/AA"; + + @Test + public void testCreateDirectory() { + assertTrue(FileUtil.createDirectory(createDirPath)); + } + + @Test + public void testDeleteFile() { + assertTrue(FileUtil.deleteFile(new File(deleteDirPath))); + } + + @Test + public void testUnzip() throws IOException { + ArrayList<String> files = FileUtil.unzip(zipFileName, extractZip); + assertNotNull(files); + } + + @Test + public void testGetDirectory() { + String[] getDirectories = FileUtil.getDirectory(getDirectory); + assertNotNull(getDirectories); + } + + @Test + public void testConvertZipFiletoByteArray() { + byte[] byteArrayFile = FileUtil.convertZipFiletoByteArray(zipFileName); + assertNotNull(byteArrayFile); + } +} diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java index b149812..e4873a1 100644 --- a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java @@ -16,10 +16,26 @@ package org.openo.vnfsdk.functests; +import org.junit.Before; +import org.mockito.Mock; import org.openo.vnfsdk.functest.VnfSdkFuncTestApp; +import org.openo.vnfsdk.functest.VnfSdkFuncTestAppConfiguration; + +import io.dropwizard.setup.Environment; public class VnfSdkFuncTestAppTest { - VnfSdkFuncTestApp vnfSdkFuncTestApp; + private VnfSdkFuncTestApp vnfSdkFuncTestApp; + + private Environment environment; + + @Mock + VnfSdkFuncTestAppConfiguration configuartion; + + @Before + public void setup() { + vnfSdkFuncTestApp = new VnfSdkFuncTestApp(); + + } } |