1 23 24 package com.rift.coad.lib.common; 25 26 import com.rift.coad.lib.common.*; 27 import junit.framework.*; 28 import java.net.InetAddress ; 29 import java.net.UnknownHostException ; 30 import java.security.SecureRandom ; 31 import java.security.MessageDigest ; 32 33 37 public class RandomGuidTest extends TestCase { 38 39 public RandomGuidTest(String testName) { 40 super(testName); 41 } 42 43 protected void setUp() throws Exception { 44 } 45 46 protected void tearDown() throws Exception { 47 } 48 49 public static Test suite() { 50 TestSuite suite = new TestSuite(RandomGuidTest.class); 51 52 return suite; 53 } 54 55 56 59 public void testGetGuid() throws Exception { 60 System.out.println("getGuid"); 61 62 RandomGuid generator1 = RandomGuid.getInstance(); 63 RandomGuid generator2 = RandomGuid.getInstance(); 64 65 String id1 = generator1.getGuid(); 68 String id2 = generator2.getGuid(); 69 70 if (id1.equals(id2)) { 71 fail("The ids are the same"); 72 } 73 74 if (!id1.equals(generator1.toString())) { 76 fail("The generated ids from the same object instance are not the same"); 77 } 78 79 if (!id2.equals(generator2.toString())) { 80 fail("The generated ids from the same object instance are not the same"); 81 } 82 83 System.out.println("ID 1 [" + id1 + "] ID 2 [" + id2 + "]"); 85 } 86 87 88 } 89 | Popular Tags |