From d469ce9749074ceaa8d815947cb3f87a4817869e Mon Sep 17 00:00:00 2001 From: Murali-P Date: Tue, 14 Feb 2017 17:41:22 +0530 Subject: UT Test cases Resolved:VNFSDK-21 Function test base code Change-Id: I1e7d41f917e21b2e8753898b727609cb37290c0c Signed-off-by: Murali-P --- .../entity/ServiceRegisterEntityTest.java | 42 ++++++++++++++ .../msb/MicroserviceBusConsumerTest.java | 40 ++++++++++++++ .../functest/resource/CommonManagerTest.java | 61 +++++++++++++++++++++ .../vnfsdk/functests/VnfSdkFuncTestAppTest.java | 25 +++++++++ .../src/test/resources/RobotScript.zip | Bin 0 -> 970 bytes 5 files changed, 168 insertions(+) create mode 100644 vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java create mode 100644 vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java create mode 100644 vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java create mode 100644 vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java create mode 100644 vnf-sdk-function-test/src/test/resources/RobotScript.zip (limited to 'vnf-sdk-function-test/src/test') 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 new file mode 100644 index 0000000..17b37a7 --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/entity/ServiceRegisterEntityTest.java @@ -0,0 +1,42 @@ +/* + * 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.externalservice.entity; + +import org.junit.Before; +import org.junit.Test; + +public class ServiceRegisterEntityTest { + + private ServiceRegisterEntity serviceRegistry; + + @Before + public void setUp() { + serviceRegistry = new ServiceRegisterEntity(); + } + + @Test + public void testSetSingleNode() { + serviceRegistry.setSingleNode("127.0.0.1", "80", 10); + } + + @Test + public void testSetServiceName() { + serviceRegistry.setServiceName("nfvo"); + + } + +} diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.java new file mode 100644 index 0000000..b047633 --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/externalservice/msb/MicroserviceBusConsumerTest.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.externalservice.msb; + +import org.glassfish.jersey.client.ClientConfig; +import org.junit.Test; +import org.mockito.Mockito; +import org.openo.vnfsdk.functest.externalservice.entity.ServiceRegisterEntity; +import org.openo.vnfsdk.functest.externalservice.msb.MicroserviceBusConsumer; +import org.openo.vnfsdk.functest.externalservice.msb.MicroserviceBusRest; +import org.powermock.api.mockito.PowerMockito; + +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; + +public class MicroserviceBusConsumerTest { + + @Test + public void testRegisterService() { + ServiceRegisterEntity entity = Mockito.mock(ServiceRegisterEntity.class); + Mockito.mock(MicroserviceBusRest.class); + Mockito.mock(ClientConfig.class); + PowerMockito.mockStatic(ConsumerFactory.class); + PowerMockito.mockStatic(MicroserviceBusConsumer.class); + MicroserviceBusConsumer.registerService(entity); + } +} diff --git a/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java new file mode 100644 index 0000000..97432b0 --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functest/resource/CommonManagerTest.java @@ -0,0 +1,61 @@ +/* + * 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.resource; + +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +import javax.ws.rs.core.Response; + +import org.junit.Before; +import org.junit.Test; + +public class CommonManagerTest { + + private CommonManager commonManger; + + private String instanceId = "1234567"; + + @Before + public void setUp() { + commonManger = new CommonManager(); + } + + @Test + public void testexecuteFunc() throws FileNotFoundException { + InputStream mockInputStream = new FileInputStream(new File("src//test//resources//RobotScript.zip")); + Response response = commonManger.executeFuncTest(mockInputStream); + instanceId = response.getEntity().toString(); + assertNotNull(instanceId); + } + + @Test + public void testQueryResultWhenInstanceIdPresent() { + Response response = commonManger.queryResultByFuncTest(instanceId); + assertNotNull(response); + } + + @Test + public void testQueryResultWhenInstanceIdAbsent() { + Response response = commonManger.queryResultByFuncTest("1234567"); + assertNotNull(response); + } +} 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 new file mode 100644 index 0000000..b149812 --- /dev/null +++ b/vnf-sdk-function-test/src/test/java/org/openo/vnfsdk/functests/VnfSdkFuncTestAppTest.java @@ -0,0 +1,25 @@ +/* + * 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 org.openo.vnfsdk.functest.VnfSdkFuncTestApp; + +public class VnfSdkFuncTestAppTest { + + VnfSdkFuncTestApp vnfSdkFuncTestApp; + +} diff --git a/vnf-sdk-function-test/src/test/resources/RobotScript.zip b/vnf-sdk-function-test/src/test/resources/RobotScript.zip new file mode 100644 index 0000000..8b7b820 Binary files /dev/null and b/vnf-sdk-function-test/src/test/resources/RobotScript.zip differ -- cgit 1.2.3-korg