/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 4245809
* @summary Basic test for LinkedHashMap. (Based on MapBash)
*/
public class Basic {
int numItr = 500;
int mapSize = 500;
// Linked List test
for (int i=0; i<numItr; i++) {
Map m = new LinkedHashMap();
for (int j=0; j<mapSize; j++) {
do {
} while (m.containsKey(newHead));
}
throw new Exception("Size not as expected.");
throw new Exception("Incorrect hashCode computation.");
throw new Exception("Collection views test failed.");
int j=0;
if (!m.containsKey(head))
throw new Exception("Linked list doesn't contain a link.");
throw new Exception("Could not retrieve a link.");
j++;
}
if (!m.isEmpty())
throw new Exception("Map nonempty after removing all links.");
if (j != mapSize)
throw new Exception("Linked list size not as expected.");
}
Map m = new LinkedHashMap();
for (int i=0; i<mapSize; i++)
throw new Exception("put returns non-null value erroenously.");
throw new Exception("contains value "+i);
throw new Exception("put returns a null value erroenously.");
throw new Exception("Clone not equal to original. (1)");
throw new Exception("Clone not equal to original. (2)");
throw new Exception("Clone not equal to original. (3)");
throw new Exception("Clone not equal to original. (4)");
if (!s.containsAll(s2))
throw new Exception("Original doesn't contain clone!");
if (!s2.containsAll(s))
throw new Exception("Clone doesn't contain original!");
throw new Exception("Serialize Clone not equal to original. (1)");
throw new Exception("Serialize Clone not equal to original. (2)");
throw new Exception("Serialize Clone not equal to original. (3)");
throw new Exception("Serialize Clone not equal to original. (4)");
if (!s.containsAll(s2))
throw new Exception("Original doesn't contain Serialize clone!");
if (!s2.containsAll(s))
throw new Exception("Serialize Clone doesn't contain original!");
throw new Exception("entrySet().removeAll failed.");
throw new Exception("clear failed.");
}
if (!m.isEmpty())
throw new Exception("Iterator.remove() failed");
// Test ordering properties with insert order
m = new LinkedHashMap();
for (int i=0; i<mapSize; i++) {
m.put(x, x);
l.add(x);
}
throw new Exception("Insertion order not preserved.");
}
throw new Exception("Insertion order not preserved after read.");
m.put(x, x);
}
throw new Exception("Insert order not preserved after reinsert.");
throw new Exception("Insert-order Map != clone.");
for (int i=0; i<mapSize; i++) {
}
throw new Exception("Clone: altered by read.");
// Test ordering properties with access order
for (int i=0; i<mapSize; i++) {
m.put(x, x);
}
throw new Exception("Insertion order not properly preserved.");
for (int i=0; i<mapSize; i++) {
}
throw new Exception("Insert order not properly altered by read.");
for (int i=0; i<mapSize; i++) {
m.put(x, x);
}
throw new Exception("Insertion order not altered by reinsert.");
throw new Exception("Access-order Map != clone.");
for (int i=0; i<mapSize; i++) {
}
throw new Exception("Clone: order not properly altered by read.");
}
try {
// Serialize
out.writeObject(m);
// Deserialize
} catch(Exception e) {
e.printStackTrace();
}
return result;
}
}