[AAF-21] Updated Copyright Headers for AAF
[aaf/cadi.git] / client / src / test / java / com / client / test / JU_PropertyLocator.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\r
4  * * ===========================================================================\r
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * * ===========================================================================\r
7  * * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * * you may not use this file except in compliance with the License.\r
9  * * You may obtain a copy of the License at\r
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \r
13  *  * Unless required by applicable law or agreed to in writing, software\r
14  * * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * * See the License for the specific language governing permissions and\r
17  * * limitations under the License.\r
18  * * ============LICENSE_END====================================================\r
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 package com.client.test;\r
24 \r
25 import java.net.URI;\r
26 \r
27 import org.junit.AfterClass;\r
28 import org.junit.Test;\r
29 \r
30 import static org.junit.Assert.*;\r
31 \r
32 import com.att.cadi.Locator.Item;\r
33 import com.att.cadi.locator.PropertyLocator;\r
34 \r
35 public class JU_PropertyLocator {\r
36 \r
37         @AfterClass\r
38         public static void tearDownAfterClass() throws Exception {\r
39         }\r
40 \r
41         @Test\r
42         public void test() throws Exception {\r
43                 PropertyLocator pl = new PropertyLocator("https://localhost:2345,https://fred.wilma.com:26444,https://tom.jerry.com:534");\r
44                 \r
45                 Item i;\r
46                 int count;\r
47                 boolean print = false;\r
48                 for(int j=0;j<900000;++j) {\r
49                         count = 0;\r
50                         for(i = pl.first();i!=null;i=pl.next(i)) {\r
51                                 URI loc = pl.get(i);\r
52                                 if(print)System.out.println(loc.toString());\r
53                                 ++count;\r
54                         }\r
55                         assertEquals(3,count);\r
56                         assertTrue(pl.hasItems());\r
57                         if(print)System.out.println("---");\r
58                         pl.invalidate(pl.best());\r
59                         \r
60                         count = 0;\r
61                         for(i = pl.first();i!=null;i=pl.next(i)) {\r
62                                 URI loc = pl.get(i);\r
63                                 if(print)System.out.println(loc.toString());\r
64                                 ++count;\r
65                         }\r
66         \r
67                         assertEquals(2,count);\r
68                         assertTrue(pl.hasItems());\r
69                         if(print)System.out.println("---");\r
70                         pl.invalidate(pl.best());\r
71                         \r
72                         count = 0;\r
73                         for(i = pl.first();i!=null;i=pl.next(i)) {\r
74                                 URI loc = pl.get(i);\r
75                                 if(print)System.out.println(loc.toString());\r
76                                 ++count;\r
77                         }\r
78         \r
79                         assertEquals(1,count);\r
80                         assertTrue(pl.hasItems());\r
81                         if(print)System.out.println("---");\r
82                         pl.invalidate(pl.best());\r
83                         \r
84                         count = 0;\r
85                         for(i = pl.first();i!=null;i=pl.next(i)) {\r
86                                 URI loc = pl.get(i);\r
87                                 if(print)System.out.println(loc.toString());\r
88                                 ++count;\r
89                         }\r
90         \r
91                         assertEquals(0,count);\r
92                         assertFalse(pl.hasItems());\r
93                         \r
94                         pl.refresh();\r
95                 }\r
96         }\r
97 \r
98 }\r