Issue-id: OCS-9
[msb/apigateway.git] / msb-core / apiroute / apiroute-service / src / test / java / org / openo / msb / wrapper / util / RegExpTestUtilTest.java
1 /**
2  * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.openo.msb.wrapper.util;
17
18 import org.junit.Assert;
19
20 import org.junit.Test;
21
22 public class RegExpTestUtilTest {
23
24     @Test
25     public void testHostRegExpTest(){
26         boolean result=RegExpTestUtil.hostRegExpTest("127.0.0.1:8080");
27         Assert.assertTrue(result);
28         
29         boolean err_result=RegExpTestUtil.hostRegExpTest("0.0.0.1:89");
30         Assert.assertFalse(err_result);
31     }
32     
33     @Test
34     public void testIpRegExpTest(){
35         boolean result=RegExpTestUtil.ipRegExpTest("127.0.0.1");
36         Assert.assertTrue(result);
37         
38         boolean err_result=RegExpTestUtil.ipRegExpTest("127.0.0.1.5");
39         Assert.assertFalse(err_result);
40     }
41     
42     @Test
43     public void testPortRegExpTest(){
44         boolean result=RegExpTestUtil.portRegExpTest("80");
45         Assert.assertTrue(result);
46         
47         boolean err_result=RegExpTestUtil.portRegExpTest("898989");
48         Assert.assertFalse(err_result);
49     }
50     
51     @Test
52     public void testVersionRegExpTest(){
53         boolean result=RegExpTestUtil.versionRegExpTest("v1");
54         Assert.assertTrue(result);
55         
56         boolean err_result=RegExpTestUtil.versionRegExpTest("23");
57         Assert.assertFalse(err_result);
58     }
59     
60     @Test
61     public void testurlRegExpTest(){
62         boolean result=RegExpTestUtil.urlRegExpTest("/test");
63         Assert.assertTrue(result);
64         
65         boolean err_result=RegExpTestUtil.urlRegExpTest("test");
66         Assert.assertFalse(err_result);
67     }
68     
69     @Test
70     public void testapiRouteUrlRegExpTest(){
71         boolean result=RegExpTestUtil.apiRouteUrlRegExpTest("/api/test/v1");
72         Assert.assertTrue(result);
73         
74         boolean err_result=RegExpTestUtil.apiRouteUrlRegExpTest("/test");
75         Assert.assertFalse(err_result);
76     }
77     
78     @Test
79     public void testiuiRouteUrlRegExpTest(){
80         boolean result=RegExpTestUtil.iuiRouteUrlRegExpTest("/iui/test");
81         Assert.assertTrue(result);
82         
83         boolean err_result=RegExpTestUtil.iuiRouteUrlRegExpTest("/test");
84         Assert.assertFalse(err_result);
85     }
86 }