{
// this test will attempt to check for reasonable behavior of the
// generateNameBasedUUID method
// we need a instance to use
NameBasedGenerator uuid_gen = Generators.nameBasedGenerator(NameBasedGenerator.NAMESPACE_URL);
UUID uuid_array[] = new UUID[SIZE_OF_TEST_ARRAY];
// now create the array of uuids
for (int i = 0; i < uuid_array.length; i++) {
uuid_array[i] = uuid_gen.generate("test name" + i);
}
// check that none of the UUIDs are null
checkUUIDArrayForNonNullUUIDs(uuid_array);
// check that all the uuids were correct variant and version
checkUUIDArrayForCorrectVariantAndVersion(uuid_array, UUIDType.NAME_BASED_SHA1);
// check that all uuids were unique
checkUUIDArrayForUniqueness(uuid_array);
// now create the array of uuids
for (int i = 0; i < uuid_array.length; i++) {
uuid_array[i] = uuid_gen.generate("test name" + i);
}
// check that none of the UUIDs are null
checkUUIDArrayForNonNullUUIDs(uuid_array);
// check that all the uuids were correct variant and version
checkUUIDArrayForCorrectVariantAndVersion(uuid_array, UUIDType.NAME_BASED_SHA1);
// check that all uuids were unique
checkUUIDArrayForUniqueness(uuid_array);
// now, lets make sure generating two sets of name based uuid with the
// same args always gives the same result
uuid_array = new UUID[SIZE_OF_TEST_ARRAY];
uuid_gen = Generators.nameBasedGenerator(NameBasedGenerator.NAMESPACE_URL);
// now create the array of uuids
for (int i = 0; i < uuid_array.length; i++) {
uuid_array[i] = uuid_gen.generate("test name" + i);
}
UUID uuid_array2[] = new UUID[SIZE_OF_TEST_ARRAY];
uuid_gen = Generators.nameBasedGenerator(NameBasedGenerator.NAMESPACE_URL);
// now create the array of uuids
for (int i = 0; i < uuid_array2.length; i++) {
uuid_array2[i] = uuid_gen.generate("test name" + i);
}
// check that none of the UUIDs are null
checkUUIDArrayForNonNullUUIDs(uuid_array);
checkUUIDArrayForNonNullUUIDs(uuid_array2);