diff options
Diffstat (limited to 'msb-core/apiroute/apiroute-service/src/test/java/org/openo')
7 files changed, 784 insertions, 784 deletions
diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/ApiRouteServiceWrapperTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/ApiRouteServiceWrapperTest.java index ad5e744..5b0867c 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/ApiRouteServiceWrapperTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/ApiRouteServiceWrapperTest.java @@ -1,164 +1,164 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openo.msb.api.ApiRouteInfo;
-import org.openo.msb.api.RouteServer;
-import org.openo.msb.api.exception.ExtendedInternalServerErrorException;
-import org.openo.msb.api.exception.ExtendedNotFoundException;
-
-public class ApiRouteServiceWrapperTest {
- private static ApiRouteServiceWrapper apiRouteServiceWrapper;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- apiRouteServiceWrapper=ApiRouteServiceWrapper.getInstance();
- }
-
- @Before
- public void setUp() {
- ApiRouteInfo apiRouteInfo=new ApiRouteInfo();
- apiRouteInfo.setServiceName("testForJunit");
- apiRouteInfo.setVersion("v1");
- apiRouteInfo.setUrl("/api/test/v1");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- apiRouteInfo.setServers(servers);
- try {
- apiRouteServiceWrapper.saveApiRouteInstance(apiRouteInfo, "");
- }
- catch(ExtendedInternalServerErrorException e){
- }
- catch (Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- try {
- apiRouteServiceWrapper.deleteApiRoute("testForJunit", "v1", "*", "");
- }
- catch(ExtendedInternalServerErrorException e){
-
- }catch (Exception e) {
- Assert.fail("Exception" + e.getMessage());
- }
- }
-
- @Test
- public void testGetAllApiRouteInstances(){
- try {
- ApiRouteInfo[] apiRouteInfoList=apiRouteServiceWrapper.getAllApiRouteInstances();
- Assert.assertTrue(apiRouteInfoList.length >= 0);
- }
- catch(ExtendedInternalServerErrorException e){
-
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testGetApiRouteInstance_not_exist(){
- ApiRouteInfo apiRouteInfo = null;
- try {
- apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("testForJunit", "v2");
- Assert.assertNotNull(apiRouteInfo);
- }
- catch(ExtendedInternalServerErrorException e){
-
- }
- catch(ExtendedNotFoundException e){
- Assert.assertNull(apiRouteInfo);
- }
-
- }
-
- @Test
- public void testGetApiRouteInstance_exist(){
- try {
- ApiRouteInfo apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("testForJunit", "v1");
- Assert.assertNotNull(apiRouteInfo);
- }
- catch(ExtendedInternalServerErrorException e){
-
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testUpdateApiRouteInstance(){
- try {
-
- ApiRouteInfo apiRouteInfo=new ApiRouteInfo();
- apiRouteInfo.setServiceName("testForJunit");
- apiRouteInfo.setVersion("v1");
- apiRouteInfo.setUrl("/api/test_update/v1");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- apiRouteInfo.setServers(servers);
-
- ApiRouteInfo new_apiRouteInfo= apiRouteServiceWrapper.updateApiRouteInstance("testForJunit", "v1", apiRouteInfo, "");
- Assert.assertEquals("/api/test_update/v1", new_apiRouteInfo.getUrl());
- }
- catch(ExtendedInternalServerErrorException e){
-
- }
- catch(Exception e){
- Assert.assertEquals("Get Jedis from pool failed!",e.getMessage());
-
-// Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
- @Test
- public void testUpdateApiRouteStatus(){
- try {
- ApiRouteInfo new_apiRouteInfo= apiRouteServiceWrapper.updateApiRouteStatus("testForJunit", "v1", "0");
- Assert.assertEquals("0",new_apiRouteInfo.getStatus());
- }
- catch(ExtendedInternalServerErrorException e){
-
- }catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
- @Test
- public void testGetApiGatewayPort(){
- try {
- String port= apiRouteServiceWrapper.getApiGatewayPort();
- Assert.assertEquals("10080",port);
- }catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
-
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openo.msb.api.ApiRouteInfo; +import org.openo.msb.api.RouteServer; +import org.openo.msb.api.exception.ExtendedInternalServerErrorException; +import org.openo.msb.api.exception.ExtendedNotFoundException; + +public class ApiRouteServiceWrapperTest { + private static ApiRouteServiceWrapper apiRouteServiceWrapper; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + apiRouteServiceWrapper=ApiRouteServiceWrapper.getInstance(); + } + + @Before + public void setUp() { + ApiRouteInfo apiRouteInfo=new ApiRouteInfo(); + apiRouteInfo.setServiceName("testForJunit"); + apiRouteInfo.setVersion("v1"); + apiRouteInfo.setUrl("/api/test/v1"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + apiRouteInfo.setServers(servers); + try { + apiRouteServiceWrapper.saveApiRouteInstance(apiRouteInfo, ""); + } + catch(ExtendedInternalServerErrorException e){ + } + catch (Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @After + public void tearDown() { + try { + apiRouteServiceWrapper.deleteApiRoute("testForJunit", "v1", "*", ""); + } + catch(ExtendedInternalServerErrorException e){ + + }catch (Exception e) { + Assert.fail("Exception" + e.getMessage()); + } + } + + @Test + public void testGetAllApiRouteInstances(){ + try { + ApiRouteInfo[] apiRouteInfoList=apiRouteServiceWrapper.getAllApiRouteInstances(); + Assert.assertTrue(apiRouteInfoList.length >= 0); + } + catch(ExtendedInternalServerErrorException e){ + + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testGetApiRouteInstance_not_exist(){ + ApiRouteInfo apiRouteInfo = null; + try { + apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("testForJunit", "v2"); + Assert.assertNotNull(apiRouteInfo); + } + catch(ExtendedInternalServerErrorException e){ + + } + catch(ExtendedNotFoundException e){ + Assert.assertNull(apiRouteInfo); + } + + } + + @Test + public void testGetApiRouteInstance_exist(){ + try { + ApiRouteInfo apiRouteInfo=apiRouteServiceWrapper.getApiRouteInstance("testForJunit", "v1"); + Assert.assertNotNull(apiRouteInfo); + } + catch(ExtendedInternalServerErrorException e){ + + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testUpdateApiRouteInstance(){ + try { + + ApiRouteInfo apiRouteInfo=new ApiRouteInfo(); + apiRouteInfo.setServiceName("testForJunit"); + apiRouteInfo.setVersion("v1"); + apiRouteInfo.setUrl("/api/test_update/v1"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + apiRouteInfo.setServers(servers); + + ApiRouteInfo new_apiRouteInfo= apiRouteServiceWrapper.updateApiRouteInstance("testForJunit", "v1", apiRouteInfo, ""); + Assert.assertEquals("/api/test_update/v1", new_apiRouteInfo.getUrl()); + } + catch(ExtendedInternalServerErrorException e){ + + } + catch(Exception e){ + Assert.assertEquals("Get Jedis from pool failed!",e.getMessage()); + +// Assert.fail("Exception" + e.getMessage()); + + } + } + + @Test + public void testUpdateApiRouteStatus(){ + try { + ApiRouteInfo new_apiRouteInfo= apiRouteServiceWrapper.updateApiRouteStatus("testForJunit", "v1", "0"); + Assert.assertEquals("0",new_apiRouteInfo.getStatus()); + } + catch(ExtendedInternalServerErrorException e){ + + }catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + @Test + public void testGetApiGatewayPort(){ + try { + String port= apiRouteServiceWrapper.getApiGatewayPort(); + Assert.assertEquals("10080",port); + }catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/CustomRouteServiceWrapperTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/CustomRouteServiceWrapperTest.java index 0bbcd25..09935a0 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/CustomRouteServiceWrapperTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/CustomRouteServiceWrapperTest.java @@ -1,137 +1,137 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openo.msb.api.CustomRouteInfo;
-import org.openo.msb.api.RouteServer;
-import org.openo.msb.api.exception.ExtendedInternalServerErrorException;
-import org.openo.msb.api.exception.ExtendedNotFoundException;
-
-public class CustomRouteServiceWrapperTest {
-
- private static CustomRouteServiceWrapper customRouteServiceWrapper;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- customRouteServiceWrapper=CustomRouteServiceWrapper.getInstance();
- }
-
- @Before
- public void setUp() {
- CustomRouteInfo customRouteInfo=new CustomRouteInfo();
- customRouteInfo.setServiceName("/testForJunit");
- customRouteInfo.setUrl("/test");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- customRouteInfo.setServers(servers);
- try {
- customRouteServiceWrapper.saveCustomRouteInstance(customRouteInfo,"");
- }
- catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- try {
- customRouteServiceWrapper.deleteCustomRoute("/testForJunit", "*","");
- }
- catch(ExtendedInternalServerErrorException e){
- }catch (Exception e) {
- Assert.fail("Exception" + e.getMessage());
- }
- }
-
- @Test
- public void testGetAllCustomRouteInstances(){
- try {
- CustomRouteInfo[] customRouteInfoList=customRouteServiceWrapper.getAllCustomRouteInstances();
- Assert.assertTrue(customRouteInfoList.length >= 0);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testGetCustomRouteInstance_not_exist(){
- CustomRouteInfo customRouteInfo = null;
- try {
- customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/testForJunit2");
- Assert.assertNotNull(customRouteInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(ExtendedNotFoundException e){
- Assert.assertNull(customRouteInfo);
- }
-
- }
-
- @Test
- public void testGetCustomRouteInstance_exist(){
- try {
- CustomRouteInfo customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/testForJunit");
- Assert.assertNotNull(customRouteInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testUpdateCustomRouteInstance(){
- try {
-
- CustomRouteInfo customRouteInfo=new CustomRouteInfo();
- customRouteInfo.setServiceName("/testForJunit");
- customRouteInfo.setUrl("/test_update");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- customRouteInfo.setServers(servers);
-
- CustomRouteInfo new_customRouteInfo= customRouteServiceWrapper.updateCustomRouteInstance("/testForJunit", customRouteInfo,"");
- Assert.assertEquals("/test_update", new_customRouteInfo.getUrl());
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
- @Test
- public void testUpdateCustomRouteStatus(){
- try {
- CustomRouteInfo new_CustomRouteInfo= customRouteServiceWrapper.updateCustomRouteStatus("/testForJunit", "0");
- Assert.assertEquals("0",new_CustomRouteInfo.getStatus());
- }catch(ExtendedInternalServerErrorException e){
- }catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openo.msb.api.CustomRouteInfo; +import org.openo.msb.api.RouteServer; +import org.openo.msb.api.exception.ExtendedInternalServerErrorException; +import org.openo.msb.api.exception.ExtendedNotFoundException; + +public class CustomRouteServiceWrapperTest { + + private static CustomRouteServiceWrapper customRouteServiceWrapper; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + customRouteServiceWrapper=CustomRouteServiceWrapper.getInstance(); + } + + @Before + public void setUp() { + CustomRouteInfo customRouteInfo=new CustomRouteInfo(); + customRouteInfo.setServiceName("/testForJunit"); + customRouteInfo.setUrl("/test"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + customRouteInfo.setServers(servers); + try { + customRouteServiceWrapper.saveCustomRouteInstance(customRouteInfo,""); + } + catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @After + public void tearDown() { + try { + customRouteServiceWrapper.deleteCustomRoute("/testForJunit", "*",""); + } + catch(ExtendedInternalServerErrorException e){ + }catch (Exception e) { + Assert.fail("Exception" + e.getMessage()); + } + } + + @Test + public void testGetAllCustomRouteInstances(){ + try { + CustomRouteInfo[] customRouteInfoList=customRouteServiceWrapper.getAllCustomRouteInstances(); + Assert.assertTrue(customRouteInfoList.length >= 0); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testGetCustomRouteInstance_not_exist(){ + CustomRouteInfo customRouteInfo = null; + try { + customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/testForJunit2"); + Assert.assertNotNull(customRouteInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(ExtendedNotFoundException e){ + Assert.assertNull(customRouteInfo); + } + + } + + @Test + public void testGetCustomRouteInstance_exist(){ + try { + CustomRouteInfo customRouteInfo=customRouteServiceWrapper.getCustomRouteInstance("/testForJunit"); + Assert.assertNotNull(customRouteInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testUpdateCustomRouteInstance(){ + try { + + CustomRouteInfo customRouteInfo=new CustomRouteInfo(); + customRouteInfo.setServiceName("/testForJunit"); + customRouteInfo.setUrl("/test_update"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + customRouteInfo.setServers(servers); + + CustomRouteInfo new_customRouteInfo= customRouteServiceWrapper.updateCustomRouteInstance("/testForJunit", customRouteInfo,""); + Assert.assertEquals("/test_update", new_customRouteInfo.getUrl()); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + @Test + public void testUpdateCustomRouteStatus(){ + try { + CustomRouteInfo new_CustomRouteInfo= customRouteServiceWrapper.updateCustomRouteStatus("/testForJunit", "0"); + Assert.assertEquals("0",new_CustomRouteInfo.getStatus()); + }catch(ExtendedInternalServerErrorException e){ + }catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/IuiRouteServiceWrapperTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/IuiRouteServiceWrapperTest.java index a1d561a..33dc01c 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/IuiRouteServiceWrapperTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/IuiRouteServiceWrapperTest.java @@ -1,137 +1,137 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openo.msb.api.IuiRouteInfo;
-import org.openo.msb.api.RouteServer;
-import org.openo.msb.api.exception.ExtendedInternalServerErrorException;
-import org.openo.msb.api.exception.ExtendedNotFoundException;
-
-public class IuiRouteServiceWrapperTest {
- private static IuiRouteServiceWrapper iuiRouteServiceWrapper;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance();
- }
-
- @Before
- public void setUp() {
- IuiRouteInfo iuiRouteInfo=new IuiRouteInfo();
- iuiRouteInfo.setServiceName("testForJunit");
- iuiRouteInfo.setUrl("/iui/test");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- iuiRouteInfo.setServers(servers);
- try {
- iuiRouteServiceWrapper.saveIuiRouteInstance(iuiRouteInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- try {
- iuiRouteServiceWrapper.deleteIuiRoute("testForJunit", "*");
- }catch(ExtendedInternalServerErrorException e){
- } catch (Exception e) {
- Assert.fail("Exception" + e.getMessage());
- }
- }
-
- @Test
- public void testGetAllIuiRouteInstances(){
- try {
- IuiRouteInfo[] iuiRouteInfoList=iuiRouteServiceWrapper.getAllIuiRouteInstances();
- Assert.assertTrue(iuiRouteInfoList.length >= 0);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testGetIuiRouteInstance_not_exist(){
- IuiRouteInfo iuiRouteInfo = null;
- try {
- iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit2");
- Assert.assertNotNull(iuiRouteInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(ExtendedNotFoundException e){
- Assert.assertNull(iuiRouteInfo);
- }
-
- }
-
- @Test
- public void testGetIuiRouteInstance_exist(){
- try {
- IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit");
- Assert.assertNotNull(iuiRouteInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testUpdateIuiRouteInstance(){
- try {
-
- IuiRouteInfo iuiRouteInfo=new IuiRouteInfo();
- iuiRouteInfo.setServiceName("testForJunit");
- iuiRouteInfo.setUrl("/iui/test_update");
- RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")};
- iuiRouteInfo.setServers(servers);
-
- IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteInstance("testForJunit", iuiRouteInfo);
- Assert.assertEquals("/iui/test_update", new_iuiRouteInfo.getUrl());
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
- @Test
- public void testUpdateIuiRouteStatus(){
- try {
- IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteStatus("testForJunit", "0");
- Assert.assertEquals("0",new_iuiRouteInfo.getStatus());
- }catch(ExtendedInternalServerErrorException e){
- }catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
-
-
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openo.msb.api.IuiRouteInfo; +import org.openo.msb.api.RouteServer; +import org.openo.msb.api.exception.ExtendedInternalServerErrorException; +import org.openo.msb.api.exception.ExtendedNotFoundException; + +public class IuiRouteServiceWrapperTest { + private static IuiRouteServiceWrapper iuiRouteServiceWrapper; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + iuiRouteServiceWrapper=IuiRouteServiceWrapper.getInstance(); + } + + @Before + public void setUp() { + IuiRouteInfo iuiRouteInfo=new IuiRouteInfo(); + iuiRouteInfo.setServiceName("testForJunit"); + iuiRouteInfo.setUrl("/iui/test"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + iuiRouteInfo.setServers(servers); + try { + iuiRouteServiceWrapper.saveIuiRouteInstance(iuiRouteInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @After + public void tearDown() { + try { + iuiRouteServiceWrapper.deleteIuiRoute("testForJunit", "*"); + }catch(ExtendedInternalServerErrorException e){ + } catch (Exception e) { + Assert.fail("Exception" + e.getMessage()); + } + } + + @Test + public void testGetAllIuiRouteInstances(){ + try { + IuiRouteInfo[] iuiRouteInfoList=iuiRouteServiceWrapper.getAllIuiRouteInstances(); + Assert.assertTrue(iuiRouteInfoList.length >= 0); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testGetIuiRouteInstance_not_exist(){ + IuiRouteInfo iuiRouteInfo = null; + try { + iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit2"); + Assert.assertNotNull(iuiRouteInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(ExtendedNotFoundException e){ + Assert.assertNull(iuiRouteInfo); + } + + } + + @Test + public void testGetIuiRouteInstance_exist(){ + try { + IuiRouteInfo iuiRouteInfo=iuiRouteServiceWrapper.getIuiRouteInstance("testForJunit"); + Assert.assertNotNull(iuiRouteInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testUpdateIuiRouteInstance(){ + try { + + IuiRouteInfo iuiRouteInfo=new IuiRouteInfo(); + iuiRouteInfo.setServiceName("testForJunit"); + iuiRouteInfo.setUrl("/iui/test_update"); + RouteServer[] servers=new RouteServer[]{new RouteServer("127.0.0.1","80")}; + iuiRouteInfo.setServers(servers); + + IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteInstance("testForJunit", iuiRouteInfo); + Assert.assertEquals("/iui/test_update", new_iuiRouteInfo.getUrl()); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + @Test + public void testUpdateIuiRouteStatus(){ + try { + IuiRouteInfo new_iuiRouteInfo= iuiRouteServiceWrapper.updateIuiRouteStatus("testForJunit", "0"); + Assert.assertEquals("0",new_iuiRouteInfo.getStatus()); + }catch(ExtendedInternalServerErrorException e){ + }catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + + +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/MicroServiceWrapperTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/MicroServiceWrapperTest.java index 3b05960..3832bd0 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/MicroServiceWrapperTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/MicroServiceWrapperTest.java @@ -1,148 +1,148 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openo.msb.api.MicroServiceFullInfo;
-import org.openo.msb.api.MicroServiceInfo;
-import org.openo.msb.api.Node;
-import org.openo.msb.api.exception.ExtendedInternalServerErrorException;
-import org.openo.msb.api.exception.ExtendedNotFoundException;
-
-public class MicroServiceWrapperTest {
- private static MicroServiceWrapper microServiceWrapper;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- microServiceWrapper=microServiceWrapper.getInstance();
- }
-
- @Before
- public void setUp() {
- MicroServiceInfo microServiceInfo=new MicroServiceInfo();
- microServiceInfo.setServiceName("testForJunit");
- microServiceInfo.setVersion("v1");
- microServiceInfo.setUrl("/api/test/v1");
- microServiceInfo.setProtocol("REST");
- microServiceInfo.setVisualRange("0");
- Set<Node> nodes=new HashSet<Node>();
- nodes.add(new Node("127.0.0.1","8080",0));
- microServiceInfo.setNodes(nodes);
- try {
- microServiceWrapper.saveMicroServiceInstance(microServiceInfo,true,"","");
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- try {
- microServiceWrapper.deleteMicroService("testForJunit", "v1", "");
- }catch(ExtendedInternalServerErrorException e){
- } catch (Exception e) {
- Assert.fail("Exception" + e.getMessage());
- }
- }
-
- @Test
- public void testGetAllMicroServiceInstances(){
- try {
- MicroServiceFullInfo[] MicroServiceInfoList=microServiceWrapper.getAllMicroServiceInstances();
- Assert.assertTrue(MicroServiceInfoList.length >= 0);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testGetMicroServiceInstance_not_exist(){
- MicroServiceFullInfo microServiceInfo = null;
- try {
- microServiceInfo=microServiceWrapper.getMicroServiceInstance("testForJunit", "v2","");
- Assert.assertNotNull(microServiceInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(ExtendedNotFoundException e){
- Assert.assertNull(microServiceInfo);
- }
-
- }
-
- @Test
- public void testGetMicroServiceInstance_exist(){
- try {
- MicroServiceFullInfo microServiceInfo=microServiceWrapper.getMicroServiceInstance("testForJunit", "v1","");
- Assert.assertNotNull(microServiceInfo);
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
-
- }
-
- @Test
- public void testUpdateMicroServiceInstance(){
- try {
-
- MicroServiceInfo microServiceInfo=new MicroServiceInfo();
- microServiceInfo.setServiceName("testForJunit");
- microServiceInfo.setVersion("v1");
- microServiceInfo.setUrl("/api/test2/v1");
- microServiceInfo.setProtocol("REST");
- microServiceInfo.setVisualRange("0");
- Set<Node> nodes=new HashSet<Node>();
- nodes.add(new Node("127.0.0.1","8080",0));
- microServiceInfo.setNodes(nodes);
-
- MicroServiceFullInfo new_MicroServiceInfo= microServiceWrapper.updateMicroServiceInstance("testForJunit", "v1", microServiceInfo);
- Assert.assertEquals("/api/test2/v1", new_MicroServiceInfo.getUrl());
- }catch(ExtendedInternalServerErrorException e){
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
- @Test
- public void testUpdateMicroServiceStatus(){
- try {
- MicroServiceFullInfo new_MicroServiceInfo= microServiceWrapper.updateMicroServiceStatus("testForJunit", "v1", "0");
- Assert.assertEquals("0",new_MicroServiceInfo.getStatus());
- }catch(ExtendedInternalServerErrorException e){
- }catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
-
- }
- }
-
-
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openo.msb.api.MicroServiceFullInfo; +import org.openo.msb.api.MicroServiceInfo; +import org.openo.msb.api.Node; +import org.openo.msb.api.exception.ExtendedInternalServerErrorException; +import org.openo.msb.api.exception.ExtendedNotFoundException; + +public class MicroServiceWrapperTest { + private static MicroServiceWrapper microServiceWrapper; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + microServiceWrapper=microServiceWrapper.getInstance(); + } + + @Before + public void setUp() { + MicroServiceInfo microServiceInfo=new MicroServiceInfo(); + microServiceInfo.setServiceName("testForJunit"); + microServiceInfo.setVersion("v1"); + microServiceInfo.setUrl("/api/test/v1"); + microServiceInfo.setProtocol("REST"); + microServiceInfo.setVisualRange("0"); + Set<Node> nodes=new HashSet<Node>(); + nodes.add(new Node("127.0.0.1","8080",0)); + microServiceInfo.setNodes(nodes); + try { + microServiceWrapper.saveMicroServiceInstance(microServiceInfo,true,"",""); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @After + public void tearDown() { + try { + microServiceWrapper.deleteMicroService("testForJunit", "v1", ""); + }catch(ExtendedInternalServerErrorException e){ + } catch (Exception e) { + Assert.fail("Exception" + e.getMessage()); + } + } + + @Test + public void testGetAllMicroServiceInstances(){ + try { + MicroServiceFullInfo[] MicroServiceInfoList=microServiceWrapper.getAllMicroServiceInstances(); + Assert.assertTrue(MicroServiceInfoList.length >= 0); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testGetMicroServiceInstance_not_exist(){ + MicroServiceFullInfo microServiceInfo = null; + try { + microServiceInfo=microServiceWrapper.getMicroServiceInstance("testForJunit", "v2",""); + Assert.assertNotNull(microServiceInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(ExtendedNotFoundException e){ + Assert.assertNull(microServiceInfo); + } + + } + + @Test + public void testGetMicroServiceInstance_exist(){ + try { + MicroServiceFullInfo microServiceInfo=microServiceWrapper.getMicroServiceInstance("testForJunit", "v1",""); + Assert.assertNotNull(microServiceInfo); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + + } + + @Test + public void testUpdateMicroServiceInstance(){ + try { + + MicroServiceInfo microServiceInfo=new MicroServiceInfo(); + microServiceInfo.setServiceName("testForJunit"); + microServiceInfo.setVersion("v1"); + microServiceInfo.setUrl("/api/test2/v1"); + microServiceInfo.setProtocol("REST"); + microServiceInfo.setVisualRange("0"); + Set<Node> nodes=new HashSet<Node>(); + nodes.add(new Node("127.0.0.1","8080",0)); + microServiceInfo.setNodes(nodes); + + MicroServiceFullInfo new_MicroServiceInfo= microServiceWrapper.updateMicroServiceInstance("testForJunit", "v1", microServiceInfo); + Assert.assertEquals("/api/test2/v1", new_MicroServiceInfo.getUrl()); + }catch(ExtendedInternalServerErrorException e){ + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + @Test + public void testUpdateMicroServiceStatus(){ + try { + MicroServiceFullInfo new_MicroServiceInfo= microServiceWrapper.updateMicroServiceStatus("testForJunit", "v1", "0"); + Assert.assertEquals("0",new_MicroServiceInfo.getStatus()); + }catch(ExtendedInternalServerErrorException e){ + }catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + + } + } + + +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/JacksonJsonUtilTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/JacksonJsonUtilTest.java index d2c383d..255cc77 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/JacksonJsonUtilTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/JacksonJsonUtilTest.java @@ -1,48 +1,48 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openo.msb.api.RouteServer;
-
-
-public class JacksonJsonUtilTest {
- @Test
- public void testBeanToJson(){
- try{
- RouteServer server=new RouteServer("127.0.0.1","80");
- String json=JacksonJsonUtil.beanToJson(server);
- Assert.assertEquals("{\"ip\":\"127.0.0.1\",\"port\":\"80\",\"weight\":0}",json);
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
- }
-
- @Test
- public void testJsonToBean(){
- try{
- String json="{\"ip\":\"127.0.0.1\",\"port\":\"80\",\"weight\":0}";
- RouteServer server=(RouteServer) JacksonJsonUtil.jsonToBean(json, RouteServer.class);
- Assert.assertEquals("127.0.0.1",server.getIp());
- Assert.assertEquals("80",server.getPort());
- }
- catch(Exception e){
- Assert.fail("Exception" + e.getMessage());
- }
- }
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper.util; + +import org.junit.Assert; +import org.junit.Test; +import org.openo.msb.api.RouteServer; + + +public class JacksonJsonUtilTest { + @Test + public void testBeanToJson(){ + try{ + RouteServer server=new RouteServer("127.0.0.1","80"); + String json=JacksonJsonUtil.beanToJson(server); + Assert.assertEquals("{\"ip\":\"127.0.0.1\",\"port\":\"80\",\"weight\":0}",json); + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + } + + @Test + public void testJsonToBean(){ + try{ + String json="{\"ip\":\"127.0.0.1\",\"port\":\"80\",\"weight\":0}"; + RouteServer server=(RouteServer) JacksonJsonUtil.jsonToBean(json, RouteServer.class); + Assert.assertEquals("127.0.0.1",server.getIp()); + Assert.assertEquals("80",server.getPort()); + } + catch(Exception e){ + Assert.fail("Exception" + e.getMessage()); + } + } +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RegExpTestUtilTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RegExpTestUtilTest.java index f53da23..c744026 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RegExpTestUtilTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RegExpTestUtilTest.java @@ -1,86 +1,86 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper.util;
-
-import org.junit.Assert;
-
-import org.junit.Test;
-
-public class RegExpTestUtilTest {
-
- @Test
- public void testHostRegExpTest(){
- boolean result=RegExpTestUtil.hostRegExpTest("127.0.0.1:8080");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.hostRegExpTest("0.0.0.1:89");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testIpRegExpTest(){
- boolean result=RegExpTestUtil.ipRegExpTest("127.0.0.1");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.ipRegExpTest("127.0.0.1.5");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testPortRegExpTest(){
- boolean result=RegExpTestUtil.portRegExpTest("80");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.portRegExpTest("898989");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testVersionRegExpTest(){
- boolean result=RegExpTestUtil.versionRegExpTest("v1");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.versionRegExpTest("23");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testurlRegExpTest(){
- boolean result=RegExpTestUtil.urlRegExpTest("/test");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.urlRegExpTest("test");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testapiRouteUrlRegExpTest(){
- boolean result=RegExpTestUtil.apiRouteUrlRegExpTest("/api/test/v1");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.apiRouteUrlRegExpTest("/test");
- Assert.assertFalse(err_result);
- }
-
- @Test
- public void testiuiRouteUrlRegExpTest(){
- boolean result=RegExpTestUtil.iuiRouteUrlRegExpTest("/iui/test");
- Assert.assertTrue(result);
-
- boolean err_result=RegExpTestUtil.iuiRouteUrlRegExpTest("/test");
- Assert.assertFalse(err_result);
- }
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper.util; + +import org.junit.Assert; + +import org.junit.Test; + +public class RegExpTestUtilTest { + + @Test + public void testHostRegExpTest(){ + boolean result=RegExpTestUtil.hostRegExpTest("127.0.0.1:8080"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.hostRegExpTest("0.0.0.1:89"); + Assert.assertFalse(err_result); + } + + @Test + public void testIpRegExpTest(){ + boolean result=RegExpTestUtil.ipRegExpTest("127.0.0.1"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.ipRegExpTest("127.0.0.1.5"); + Assert.assertFalse(err_result); + } + + @Test + public void testPortRegExpTest(){ + boolean result=RegExpTestUtil.portRegExpTest("80"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.portRegExpTest("898989"); + Assert.assertFalse(err_result); + } + + @Test + public void testVersionRegExpTest(){ + boolean result=RegExpTestUtil.versionRegExpTest("v1"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.versionRegExpTest("23"); + Assert.assertFalse(err_result); + } + + @Test + public void testurlRegExpTest(){ + boolean result=RegExpTestUtil.urlRegExpTest("/test"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.urlRegExpTest("test"); + Assert.assertFalse(err_result); + } + + @Test + public void testapiRouteUrlRegExpTest(){ + boolean result=RegExpTestUtil.apiRouteUrlRegExpTest("/api/test/v1"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.apiRouteUrlRegExpTest("/test"); + Assert.assertFalse(err_result); + } + + @Test + public void testiuiRouteUrlRegExpTest(){ + boolean result=RegExpTestUtil.iuiRouteUrlRegExpTest("/iui/test"); + Assert.assertTrue(result); + + boolean err_result=RegExpTestUtil.iuiRouteUrlRegExpTest("/test"); + Assert.assertFalse(err_result); + } +} diff --git a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RouteUtilTest.java b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RouteUtilTest.java index 0cb4d48..af5c28b 100644 --- a/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RouteUtilTest.java +++ b/msb-core/apiroute/apiroute-service/src/test/java/org/openo/msb/wrapper/util/RouteUtilTest.java @@ -1,64 +1,64 @@ -/**
- * Copyright 2016 ZTE, Inc. and others.
- *
- * 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.msb.wrapper.util;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class RouteUtilTest {
-
- @Test
- public void testGetPrefixedKey(){
- String path=RouteUtil.getPrefixedKey("","test","v1");
- Assert.assertEquals("msb:routing:test:v1",path);
- }
-
- @Test
- public void testConcat(){
- Object[] str1=new String[]{"test1","test2"};
- Object[] str2=new String[]{"test3"};
- Object[] str3=RouteUtil.concat(str1, str2);
-
- Assert.assertEquals(3,str3.length);
- }
-
- @Test
- public void testContainStr(){
- String value="1";
- String array[]={"1","2"};
- boolean result=RouteUtil.contain(array, value);
- Assert.assertTrue(result);
- }
-
- @Test
- public void testContainArray(){
- String value[]={"0"};
- String array[]={"1","2"};
- boolean result=RouteUtil.contain(array, value);
- Assert.assertFalse(result);
-
- }
-
- @Test
- public void testShow(){
- String array[]={"1","2"};
- String result=RouteUtil.show(array);
- Assert.assertEquals("1|2",result);
-
- }
-
-}
+/** + * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved. + * + * 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.msb.wrapper.util; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +public class RouteUtilTest { + + @Test + public void testGetPrefixedKey(){ + String path=RouteUtil.getPrefixedKey("","test","v1"); + Assert.assertEquals("msb:routing:test:v1",path); + } + + @Test + public void testConcat(){ + Object[] str1=new String[]{"test1","test2"}; + Object[] str2=new String[]{"test3"}; + Object[] str3=RouteUtil.concat(str1, str2); + + Assert.assertEquals(3,str3.length); + } + + @Test + public void testContainStr(){ + String value="1"; + String array[]={"1","2"}; + boolean result=RouteUtil.contain(array, value); + Assert.assertTrue(result); + } + + @Test + public void testContainArray(){ + String value[]={"0"}; + String array[]={"1","2"}; + boolean result=RouteUtil.contain(array, value); + Assert.assertFalse(result); + + } + + @Test + public void testShow(){ + String array[]={"1","2"}; + String result=RouteUtil.show(array); + Assert.assertEquals("1|2",result); + + } + +} |