[jira] [Commented] (SANDBOX-307) UUID URN version 5 generation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-307) UUID URN version 5 generation

David Mollitor (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13226206#comment-13226206 ]

Guillaume Gardey commented on SANDBOX-307:
------------------------------------------

We've encountered the same problem when handling uuids generated by different libraries/languages.
If that can help, we're using this patched version https://github.com/glinmac/commons-id/commit/446d08e5e354b5469205672b388a6709bdf8968d

               

> UUID URN version 5 generation
> -----------------------------
>
>                 Key: SANDBOX-307
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-307
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: Id
>    Affects Versions: Nightly Builds
>         Environment: Linux Ubuntu 8.10
> JDK 1.6.10
>            Reporter: Davide Ling
>
> The following test fail with the message:
> org.junit.ComparisonFailure:
>       expected:<...:uuid:be6a1b75-9a58-[5]4a8-972e-791dfdd8815...> but was:<...:uuid:be6a1b75-9a58-[3]4a8-972e-791dfdd8815...>
> at org.junit.Assert.assertEquals(Assert.java:123)
> at org.junit.Assert.assertEquals(Assert.java:145)
> at org.davideling.provauuid.ProvaUUIDTest.testUUID(ProvaUUIDTest.java:25)
> public class UUIDVersion5Test {
> // Linux generated URN using the uuid command:
> //   davide@mydebian:~$ uuid -v 5 6ba7b811-9dad-11d1-80b4-00c04fd430c8 http://davideling.org/miaApp/2
> //   davide@mydebian:~$ be6a1b75-9a58-54a8-972e-791dfdd8815b
> private static final String LINUX_GENERATED_URN = "urn:uuid:be6a1b75-9a58-54a8-972e-791dfdd8815b";
>
> // URL UUID namespace
> private static final UUID NAMESPACE = new UUID("6ba7b811-9dad-11d1-80b4-00c04fd430c8");
>
> // Name
> private static final String NAME = "http://davideling.org/miaApp/2";
>
> @Test
> public void testUUID() throws Exception {
>
> UUID uuid = UUID.nameUUIDFromString(NAME, NAMESPACE, UUID.SHA1_ENCODING);
> assertEquals(LINUX_GENERATED_URN, uuid.toUrn() );
> }
>
> }
> When using the SHA1 algorithm with UUID.nameUUIDFromString the version field have to be 5 (?) as the
> Linux uuid generated URN?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira