ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/jtreg/util/Hashtable/IllegalLoadFactor.java
(Generate patch)

Comparing jsr166/src/test/jtreg/util/Hashtable/IllegalLoadFactor.java (file contents):
Revision 1.1 by jsr166, Tue Sep 1 01:25:04 2009 UTC vs.
Revision 1.5 by jsr166, Sun Oct 11 00:58:42 2015 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright 1997-1998 Sun Microsystems, Inc.  All Rights Reserved.
2 > * Copyright (c) 1997, 1998, 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
# Line 16 | Line 16
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 < * CA 95054 USA or visit www.sun.com if you need additional information or
21 < * have any questions.
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   /* @test
# Line 26 | Line 26
26     @summary Test for an illegalargumentexception on loadFactor
27   */
28  
29
30
29   import java.util.*;
30  
31   /**
# Line 38 | Line 36 | public class IllegalLoadFactor {
36  
37        public static void main(String argv[]) throws Exception {
38            boolean testSucceeded = false;
39 <          try{
39 >          try {
40                // this should generate an IllegalArgumentException
41                Hashtable bad1 = new Hashtable(100, -3);
42            }
43            catch (IllegalArgumentException e1) {
44                testSucceeded = true;
45            }
46 <          if(!testSucceeded)
46 >          if (!testSucceeded)
47                throw new Exception("Hashtable, negative load factor");
48  
49            testSucceeded = false;
50 <          try{
50 >          try {
51                // this should generate an IllegalArgumentException
52                Hashtable bad1 = new Hashtable(100, Float.NaN);
53            }
54            catch (IllegalArgumentException e1) {
55                testSucceeded = true;
56            }
57 <          if(!testSucceeded)
57 >          if (!testSucceeded)
58                throw new Exception("Hashtable, NaN load factor");
59  
60            testSucceeded = false;
61 <          try{
61 >          try {
62                // this should generate an IllegalArgumentException
63                HashMap bad1 = new HashMap(100, -3);
64            }
65            catch (IllegalArgumentException e1) {
66                testSucceeded = true;
67            }
68 <          if(!testSucceeded)
68 >          if (!testSucceeded)
69                throw new Exception("HashMap, negative load factor");
70  
71            testSucceeded = false;
72 <          try{
72 >          try {
73                // this should generate an IllegalArgumentException
74                HashMap bad1 = new HashMap(100, Float.NaN);
75            }
76            catch (IllegalArgumentException e1) {
77                testSucceeded = true;
78            }
79 <          if(!testSucceeded)
79 >          if (!testSucceeded)
80                throw new Exception("HashMap, NaN load factor");
81  
82  
83            testSucceeded = false;
84 <          try{
84 >          try {
85                // this should generate an IllegalArgumentException
86                HashSet bad1 = new HashSet(100, -3);
87            }
88            catch (IllegalArgumentException e1) {
89                testSucceeded = true;
90            }
91 <          if(!testSucceeded)
91 >          if (!testSucceeded)
92                throw new Exception("HashSet, negative load factor");
93  
94            testSucceeded = false;
95 <          try{
95 >          try {
96                // this should generate an IllegalArgumentException
97                HashSet bad1 = new HashSet(100, Float.NaN);
98            }
99            catch (IllegalArgumentException e1) {
100                testSucceeded = true;
101            }
102 <          if(!testSucceeded)
102 >          if (!testSucceeded)
103                throw new Exception("HashSet, NaN load factor");
104  
105            testSucceeded = false;
106 <          try{
106 >          try {
107                // this should generate an IllegalArgumentException
108                WeakHashMap bad1 = new WeakHashMap(100, -3);
109            }
110            catch (IllegalArgumentException e1) {
111                testSucceeded = true;
112            }
113 <          if(!testSucceeded)
113 >          if (!testSucceeded)
114                throw new Exception("WeakHashMap, negative load factor");
115  
116            testSucceeded = false;
117 <          try{
117 >          try {
118                // this should generate an IllegalArgumentException
119                WeakHashMap bad1 = new WeakHashMap(100, Float.NaN);
120            }
121            catch (IllegalArgumentException e1) {
122                testSucceeded = true;
123            }
124 <          if(!testSucceeded)
124 >          if (!testSucceeded)
125                throw new Exception("WeakHashMap, NaN load factor");
126  
127            // Make sure that legal creates don't throw exceptions

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines