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