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