fix powermock issue
[msb/apigateway.git] / apiroute / apiroute-service / src / test / java / org / onap / msb / apiroute / wrapper / util / RegExpTestUtilTest.java
1 /*******************************************************************************
2  * Copyright 2016-2017 ZTE, Inc. and others.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  * 
7  * http://www.apache.org/licenses/LICENSE-2.0
8  * 
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  ******************************************************************************/
14 package org.onap.msb.apiroute.wrapper.util;
15
16 import org.junit.Assert;
17 import org.junit.Test;
18
19 public class RegExpTestUtilTest {
20
21     @Test
22     public void test_HostRegExpTest() {
23         Assert.assertTrue(RegExpTestUtil.hostRegExpTest("127.0.0.1:8080"));
24         Assert.assertFalse(RegExpTestUtil.hostRegExpTest("0.0.0.1:89"));
25     }
26
27
28
29     @Test
30     public void test_IpRegExpTest() {
31         Assert.assertTrue(RegExpTestUtil.ipRegExpTest("127.0.0.1"));
32         Assert.assertFalse(RegExpTestUtil.ipRegExpTest("127.0.0.1.5"));
33     }
34
35
36
37     @Test
38     public void test_PortRegExpTest() {
39         Assert.assertTrue(RegExpTestUtil.portRegExpTest("80"));
40         Assert.assertFalse(RegExpTestUtil.portRegExpTest("898989"));
41     }
42
43
44     @Test
45     public void test_VersionRegExpTest() {
46         Assert.assertTrue(RegExpTestUtil.versionRegExpTest("v1"));
47         Assert.assertFalse(RegExpTestUtil.versionRegExpTest("23"));
48     }
49
50
51
52     @Test
53     public void test_urlRegExpTest() {
54         Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/test"));
55         Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/"));
56         Assert.assertFalse(RegExpTestUtil.urlRegExpTest("test"));
57     }
58
59
60     @Test
61     public void test_apiRouteUrlRegExpTest() {
62         Assert.assertTrue(RegExpTestUtil.apiRouteUrlRegExpTest("/api/test/v1"));
63         Assert.assertFalse(RegExpTestUtil.apiRouteUrlRegExpTest("/test"));
64     }
65
66
67
68     @Test
69     public void test_iuiRouteUrlRegExpTest() {
70         Assert.assertTrue(RegExpTestUtil.iuiRouteUrlRegExpTest("/iui/test"));
71         Assert.assertFalse(RegExpTestUtil.iuiRouteUrlRegExpTest("/test"));
72     }
73
74     @Test
75     public void test_apiServiceNameMatch4URL() {
76         String[] apiServiceNameArray = {"testApiName", "v1"};
77         Assert.assertArrayEquals(apiServiceNameArray, RegExpTestUtil.apiServiceNameMatch4URL("/api/testApiName/v1"));
78
79         String[] apiServiceNameArray_noversion = {"testApiName", ""};
80         Assert.assertArrayEquals(apiServiceNameArray_noversion,
81                         RegExpTestUtil.apiServiceNameMatch4URL("/api/testApiName"));
82
83         Assert.assertNull(RegExpTestUtil.apiServiceNameMatch4URL("/apiw/name/v1"));
84     }
85
86     @Test
87     public void test_iuiServiceNameMatch4URL() {
88         String iuiServiceName = "testIuiName";
89         Assert.assertEquals(iuiServiceName, RegExpTestUtil.iuiServiceNameMatch4URL("/iui/testIuiName"));
90
91         Assert.assertNull(RegExpTestUtil.iuiServiceNameMatch4URL("/api/name/v1"));
92     }
93
94 }