/*
* 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 4173528 5068772
* @summary Unit tests for java.util.UUID
*/
public class UUIDTest {
containsTest();
stringTest();
versionTest();
variantTest();
nodeTest();
compareTo();
}
// Verify that list.contains detects UUID collisons
throw new Exception("contains test did not work as expected");
}
for (int i=0; i<100; i++) {
throw new Exception("bad version");
}
throw new Exception("bad variant");
}
throw new Exception("random UUID collision very unlikely");
}
}
byte[] someBytes = new byte[12];
for (int i=0; i<100; i++) {
throw new Exception("bad version");
}
throw new Exception("bad variant");
}
throw new Exception("byte UUID collision very unlikely");
}
}
for (int i=0; i<100; i++) {
throw new Exception("UUID -> string -> UUID failed");
}
}
throw new Exception("randomUUID not type 4");
byte[] someBytes = new byte[12];
throw new Exception("nameUUIDFromBytes not type 3");
throw new Exception("wrong version fromString 1");
throw new Exception("wrong version fromString 2");
throw new Exception("wrong version fromString 3");
throw new Exception("wrong version fromString 4");
throw new Exception("wrong version from bit set to 1");
throw new Exception("wrong version from bit set to 2");
throw new Exception("wrong version from bit set to 3");
throw new Exception("wrong version from bit set to 4");
}
throw new Exception("randomUUID not variant 2");
byte[] someBytes = new byte[12];
throw new Exception("nameUUIDFromBytes not variant 2");
throw new Exception("wrong variant from bit set to 0");
throw new Exception("wrong variant from bit set to 2");
throw new Exception("wrong variant from bit set to 6");
throw new Exception("wrong variant from bit set to 7");
}
try {
throw new Exception("Expected exception not thrown");
} catch (UnsupportedOperationException uoe) {
// Correct result
}
throw new Exception("Incorrect timestamp");
throw new Exception("Incorrect timestamp");
throw new Exception("Incorrect timestamp");
}
try {
throw new Exception("Expected exception not thrown");
} catch (UnsupportedOperationException uoe) {
// Correct result
}
throw new Exception("Incorrect sequence");
throw new Exception("Incorrect sequence");
throw new Exception("Incorrect sequence");
throw new Exception("Incorrect sequence");
}
try {
throw new Exception("Expected exception not thrown");
} catch (UnsupportedOperationException uoe) {
// Correct result
}
throw new Exception("Incorrect node");
throw new Exception("Incorrect node");
}
// If two UUIDs are equal they must have the same hashCode
for (int i=0; i<100; i++) {
throw new Exception("Equal UUIDs with different hashcodes");
}
// Test equality of UUIDs with tampered bits
for (int i=0; i<1000; i++) {
l = l ^ (1L << position);
throw new Exception("UUIDs with different bits equal");
}
}
throw new RuntimeException("compareTo failure");
throw new RuntimeException("compareTo failure");
throw new RuntimeException("compareTo failure");
}
}