Unit test for MSB JAVA SDK
[msb/java-sdk.git] / src / test / java / org / onap / msb / sdk / discovery / 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
15 package org.onap.msb.sdk.discovery.util;
16
17 import org.junit.Assert;
18 import org.junit.Test;
19
20
21
22 public class RegExpTestUtilTest {
23
24     @Test
25     public void testhostRegExpTest() {
26         Assert.assertTrue(RegExpTestUtil.hostRegExpTest("127.0.0.1:8080"));
27
28         Assert.assertFalse(RegExpTestUtil.hostRegExpTest("0.0.0.1:89"));
29     }
30
31     @Test
32     public void testipRegExpTest() {
33
34         Assert.assertTrue(RegExpTestUtil.ipRegExpTest("10.74.151.26"));
35
36         Assert.assertFalse(RegExpTestUtil.ipRegExpTest("0.74.0.26"));
37     }
38
39     @Test
40     public void testportRegExpTest() {
41         Assert.assertTrue(RegExpTestUtil.portRegExpTest("8989"));
42         Assert.assertFalse(RegExpTestUtil.portRegExpTest("99999"));
43     }
44
45     @Test
46     public void testversionRegExpTest() {
47
48         Assert.assertTrue(RegExpTestUtil.versionRegExpTest("v1"));
49
50         Assert.assertFalse(RegExpTestUtil.versionRegExpTest("vv2"));
51     }
52
53     @Test
54     public void testurlRegExpTest() {
55
56         Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/test/v1"));
57
58         Assert.assertTrue(RegExpTestUtil.urlRegExpTest("/"));
59
60         Assert.assertFalse(RegExpTestUtil.urlRegExpTest("test/#?qwe"));
61     }
62
63     @Test
64     public void testserviceNameRegExpTest() {
65
66         Assert.assertTrue(RegExpTestUtil.serviceNameRegExpTest("servive_1"));
67
68
69         Assert.assertFalse(RegExpTestUtil.serviceNameRegExpTest("servive%_1"));
70     }
71 }