diff options
author | j180240 <jiaxiangli@huawei.com> | 2016-09-14 15:00:54 +0800 |
---|---|---|
committer | j180240 <jiaxiangli@huawei.com> | 2016-09-14 15:00:54 +0800 |
commit | d089cf2631c2d647b97977bff905a2bdbff93986 (patch) | |
tree | 50bc400d59665099b1c137c009ac6a77c3e88b13 /servicegateway/service/src/test | |
parent | fd3c0d4674628bdb922984838803dbac5161e400 (diff) |
upload the servicegateway code .
Change-Id: I3fa83416412e9ef282bd03f45e011133965367c5
Signed-off-by: jiaxiangli <jiaxiangli@huawei.com>
Diffstat (limited to 'servicegateway/service/src/test')
4 files changed, 268 insertions, 0 deletions
diff --git a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/ErrorCodeTest.java b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/ErrorCodeTest.java new file mode 100644 index 00000000..422c5e41 --- /dev/null +++ b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/ErrorCodeTest.java @@ -0,0 +1,39 @@ +/*
+ * Copyright (c) 2016, 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.gso.gui.servicegateway.exception;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+/**
+ * Test Constant class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version GSO 0.5 2016/8/4
+ */
+public class ErrorCodeTest {
+
+ @Test
+ public void test() {
+ assertEquals("servicemgr.mysql.oper_mysql_db_error", ErrorCode.SVCMGR_OPER_MYSQL_DB_ERROR);
+ assertEquals("servicemgr.bad_param", ErrorCode.SVCMGR_SERVICEMGR_BAD_PARAM);
+ }
+
+}
diff --git a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/HttpCodeTest.java b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/HttpCodeTest.java new file mode 100644 index 00000000..cefdb50b --- /dev/null +++ b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/exception/HttpCodeTest.java @@ -0,0 +1,47 @@ +/*
+ * Copyright (c) 2016, 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.gso.gui.servicegateway.exception;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Test Constant class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version GSO 0.5 2016/8/4
+ */
+public class HttpCodeTest {
+
+ @Test
+ public void test() {
+ assertEquals(400, HttpCode.BAD_REQUEST);
+ assertEquals(500, HttpCode.INTERNAL_SERVER_ERROR);
+ assertEquals(406, HttpCode.NOT_ACCEPTABLE);
+ assertEquals(404, HttpCode.NOT_FOUND);
+ assertEquals(202, HttpCode.RESPOND_ACCEPTED);
+ assertEquals(200, HttpCode.RESPOND_OK);
+ assertTrue(HttpCode.isSucess(200));
+ assertFalse(HttpCode.isSucess(400));
+ }
+
+}
diff --git a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImplTest.java b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImplTest.java new file mode 100644 index 00000000..8b5c6c67 --- /dev/null +++ b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/roa/impl/ServiceGatewayRoaModuleImplTest.java @@ -0,0 +1,109 @@ +/*
+ * Copyright (c) 2016, 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.gso.gui.servicegateway.roa.impl;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.ibatis.io.Resources;
+import org.apache.ibatis.jdbc.ScriptRunner;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.gso.gui.servicegateway.service.impl.ServiceGatewayImpl;
+
+/**
+ * Test ServicemgrRoaModuleImpl class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version GSO 0.5 2016/8/3
+ */
+public class ServiceGatewayRoaModuleImplTest {
+
+ /**
+ * Service ROA.
+ */
+ ServiceGatewayRoaModuleImpl serviceRoa = new ServiceGatewayRoaModuleImpl();
+
+ /**
+ * Service manager.
+ */
+ ServiceGatewayImpl serviceManager = new ServiceGatewayImpl();
+
+
+ /**
+ * Http request.
+ */
+ HttpServletRequest httpRequest;
+
+ /**
+ * Before executing UT, start sql.<br/>
+ *
+ * @since GSO 0.5
+ */
+ @Before
+ public void start() throws IOException, SQLException {
+
+ }
+
+
+
+ /**
+ * After executing UT, close session<br/>
+ *
+ * @since GSO 0.5
+ */
+ @After
+ public void stop() {
+
+ }
+
+ /**
+ * Test create service.<br/>
+ *
+ * @throws ServiceException when fail to operate database or parameter is wrong.
+ * @since GSO 0.5
+ */
+ @Test
+ public void testCreateService() throws ServiceException {
+
+ }
+
+ /**
+ * Test delete service.<br/>
+ *
+ * @throws ServiceException when fail to operate database or parameter is wrong.
+ * @since GSO 0.5
+ */
+ @Test
+ public void testTeleteService() throws ServiceException {
+ serviceRoa.deleteService("1", httpRequest);
+ }
+
+}
diff --git a/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java new file mode 100644 index 00000000..734add90 --- /dev/null +++ b/servicegateway/service/src/test/java/org/openo/gso/gui/servicegateway/service/impl/ServiceGatewayImplTest.java @@ -0,0 +1,73 @@ +/*
+ * Copyright (c) 2016, 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.gso.gui.servicegateway.service.impl;
+
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+/**
+ * Test ServiceGatewayImpl Class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version GSO 0.5 2016/8/3
+ */
+public class ServiceGatewayImplTest {
+
+ /**
+ * Service manager.
+ */
+ ServiceGatewayImpl serviceManager = new ServiceGatewayImpl();
+
+
+ /**
+ * Http request.
+ */
+ HttpServletRequest httpRequest;
+
+ @Before
+ public void start() {
+ }
+
+ /**
+ * Invalid parameter.<br/>
+ *
+ * @throws ServiceException when parameter is wrong.
+ * @since GSO 0.5
+ */
+ @Test(expected = ServiceException.class)
+ public void testCreateServiceFail() throws ServiceException {
+ serviceManager.createService(null, httpRequest);
+ }
+
+ /**
+ * Invalid parameter.<br/>
+ *
+ * @throws ServiceException when parameter is wrong.
+ * @since GSO 0.5
+ */
+ @Test(expected = ServiceException.class)
+ public void testDeleteServiceFail() throws ServiceException {
+ serviceManager.deleteService(null, httpRequest);
+ }
+
+}
|