2 * Copyright 2016 ZTE, Inc. and others.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.msb.apiroute.wrapper.util;
18 import org.junit.Assert;
19 import org.junit.Test;
20 import org.onap.msb.apiroute.wrapper.util.RegExpTestUtil;
22 public class RegExpTestUtilTest {
25 public void test_HostRegExpTest(){
26 Assert.assertTrue(RegExpTestUtil.hostRegExpTest("127.0.0.1:8080"));
27 Assert.assertFalse(RegExpTestUtil.hostRegExpTest("0.0.0.1:89"));
33 public void test_IpRegExpTest(){
34 Assert.assertTrue(RegExpTestUtil.ipRegExpTest("127.0.0.1"));
35 Assert.assertFalse(RegExpTestUtil.ipRegExpTest("127.0.0.1.5"));
41 public void test_PortRegExpTest(){
42 Assert.assertTrue(RegExpTestUtil.portRegExpTest("80"));
43 Assert.assertFalse(RegExpTestUtil.portRegExpTest("898989"));
48 public void test_VersionRegExpTest(){
49 Assert.assertTrue(RegExpTestUtil.versionRegExpTest("v1"));
50 Assert.assertFalse(RegExpTestUtil.versionRegExpTest("23"));
56 public void test_urlRegExpTest(){
57 Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/test"));
58 Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/"));
59 Assert.assertFalse(RegExpTestUtil.urlRegExpTest("test"));
64 public void test_apiRouteUrlRegExpTest(){
65 Assert.assertTrue(RegExpTestUtil.apiRouteUrlRegExpTest("/api/test/v1"));
66 Assert.assertFalse(RegExpTestUtil.apiRouteUrlRegExpTest("/test"));
72 public void test_iuiRouteUrlRegExpTest(){
73 Assert.assertTrue(RegExpTestUtil.iuiRouteUrlRegExpTest("/iui/test"));
74 Assert.assertFalse(RegExpTestUtil.iuiRouteUrlRegExpTest("/test"));
78 public void test_apiServiceNameMatch4URL(){
79 String[] apiServiceNameArray={"testApiName","v1"};
80 Assert.assertArrayEquals(apiServiceNameArray, RegExpTestUtil.apiServiceNameMatch4URL("/api/testApiName/v1"));
82 String[] apiServiceNameArray_noversion={"testApiName",""};
83 Assert.assertArrayEquals(apiServiceNameArray_noversion, RegExpTestUtil.apiServiceNameMatch4URL("/api/testApiName"));
85 Assert.assertNull(RegExpTestUtil.apiServiceNameMatch4URL("/apiw/name/v1"));
89 public void test_iuiServiceNameMatch4URL(){
90 String iuiServiceName="testIuiName";
91 Assert.assertEquals(iuiServiceName, RegExpTestUtil.iuiServiceNameMatch4URL("/iui/testIuiName"));
93 Assert.assertNull(RegExpTestUtil.iuiServiceNameMatch4URL("/api/name/v1"));