Skip to main content
summaryrefslogtreecommitdiffstats
blob: ee821d3e073793a95cfd0cffa42520913c932c4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.framework.jdk.core.test.util;

import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.junit.Assert;

/**
 * @author Roberto E. Escobar
 */
public class GUIDTest {

   @org.junit.Test
   public void testInvalidGuids() {
      final String[] invalidHrids =
         {
            "short",
            "AAABDBYPet4AGJyrc_LONG_",
            "AAABGumk_InvalidChar!",
            "AAABGumk_InvalidChar#",
            "AAABGumk_InvalidChar@",
            "AAABGumk_InvalidChar^"};
      for (String invalid : invalidHrids) {
         Assert.assertFalse("Invalid HRID " + invalid + " passes validity test", GUID.isValid(invalid));
      }
   }

   @org.junit.Test
   public void testValidGeneration() {
      for (int i = 0; i < 50000; i++) {
         String guid = GUID.create();
         Assert.assertTrue("Generated GUID " + guid + " fails validity test", GUID.isValid(guid));
      }
   }

   @org.junit.Test
   public void testValidGuids() {
      final String[] validGuids =
         {
            "AAABDBYPet4AGJyrc9dY1w",
            "AAABGumk_y8AFBnQMxZ58g",
            "AAABGyedHw8AphA8L4XexQ",
            "AAABDBYtCDsAVk2xBsTGzQ",
            "AAABF_Ss2Q0AR8+yEx51WQ",
            "AAABHUWIY34B7y_TEmEslg",
            "AAABHZzkLCgBebkFSon4wA",
            "AAABGuAX6cAB0Si2OIQ+YQ",
            "AAABGassf08BOe_BF6k6vA",
            "AAABHGv_u1gBGrilXclyUA",
            "AAABDBYsngcAVk2xSlMcyw",
            "AAABGm+v1uEA389GY8zirw",
            "AAABDBYrxw4AVk2xHBRmhQ",
            "AAABHbBGWuQA_ArKWeHLrg",
            "AAABDBYs7Z8AVk2xTZPPSg",
            "AAABGixOs5kA2KG7aom9Pw",
            "AAABFjQ_MYIBEQV7BF3j7Q",
            "AAABDBYs9AcAVk2xTOjhPQ",
            "AAABDBYr7KcAVk2xDNCqew",
            "AAABHHEPXpYBzfAhPukxiQ",
            "AAABDBYsYBMAVk2xN5jSVA",
            "AAABDBYsS3IAVk2xSRpaS="};
      for (String guid : validGuids) {
         Assert.assertTrue(GUID.isValid(guid));
      }
   }
}

Back to the top