/* * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 4509255 5055567 6176318 7090844 * @summary Tests consistencies of time zone IDs.
*/
System.out.println("Total: " + tzs.length + " time zone IDs"); for (String id : tzs) {
ids.add(id);
TimeZone tz = TimeZone.getTimeZone(id);
Integer offset = tz.getRawOffset();
Set<String> s = tree.get(offset); if (s == null) {
s = new HashSet<>();
tree.put(offset, s);
}
s.add(id);
}
for (Integer key : tree.keySet()) {
Set<String> s1 = tree.get(key);
// Make sure no duplicates in the other sets for (Integer k : tree.keySet()) { if (k.equals(key)) { continue;
}
Set<String> s2 = new HashSet<>(tree.get(k));
s2.retainAll(s1); if (!s2.isEmpty()) { thrownew RuntimeException("s1 included in the subset for " + (k.intValue()/60000) + " (" + s2 + " shouldn't be in s1)");
}
}
// Check the getAvailableIDs(int) call to return the same // set of IDs int offset = key.intValue();
tzs = TimeZone.getAvailableIDs(offset);
tzs2 = TimeZone.getAvailableIDs(offset); if (!Arrays.equals(tzs, tzs2)) { thrownew RuntimeException("inconsistent tzs from getAvailableIDs("+offset+")");
}
Set<String> s2 = new HashSet<>();
s2.addAll(Arrays.asList(tzs)); if (!s1.equals(s2)) { thrownew RuntimeException("s1 != s2 for " + offset/60000 + " (diff=" + getDiff(s1, s2) + ")");
} if (!ids.containsAll(s2)) { thrownew RuntimeException("s2 isn't a subset of ids (" + getDiff(s2, ids) + " not in ids)");
}
}
for (Integer key : tree.keySet()) {
Set<String> s1 = tree.get(key);
ids.removeAll(s1);
} if (!ids.isEmpty()) { thrownew RuntimeException("ids didn't become empty. (" + ids + ")");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.