1 /* 2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import javax.naming.Binding; 25 import javax.naming.NamingEnumeration; 26 import javax.naming.NamingException; 27 28 /** 29 * Abstract test base for Fed list related test, this class extends DNSTestBase. 30 * 31 * @see DNSTestBase 32 * @see TestBase 33 */ 34 abstract class ListFedBase extends DNSTestBase { 35 private String key; 36 37 public ListFedBase() { 38 // set default test data 39 setKey("host1"); 40 } 41 42 /** 43 * Verify given NamingEnumeration match expected count. 44 * 45 * @param enumObj given NamingEnumeration instance 46 * @param expectedCount given expected count 47 * @throws NamingException 48 */ 49 public void verifyNamingEnumeration(NamingEnumeration<?> enumObj, 50 int expectedCount) throws NamingException { 51 DNSTestUtils.debug("Enum is: " + enumObj); 52 53 int count = 0; 54 Binding res; 55 56 while (enumObj.hasMore()) { 57 res = (Binding) enumObj.next(); 58 DNSTestUtils.debug(res); 59 ++count; 60 } 61 62 if (count != expectedCount) { 63 throw new RuntimeException( 64 "Expecting " + expectedCount + " entries but got " + count); 65 } 66 } 67 68 public String getKey() { 69 return key; 70 } 71 72 public void setKey(String key) { 73 this.key = key; 74 } 75 }