KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > components > TestUUID


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 /**
18  *
19  * UUIDGen adopted from the juddi project
20  * (http://sourceforge.net/projects/juddi/)
21  *
22  */

23
24 package test.components;
25
26 import junit.framework.Test;
27 import junit.framework.TestCase;
28 import junit.framework.TestSuite;
29 import org.apache.axis.components.uuid.UUIDGen;
30 import org.apache.axis.components.uuid.UUIDGenFactory;
31
32 public class TestUUID extends TestCase {
33
34     public TestUUID(String JavaDoc name) {
35         super(name);
36     }
37
38     public static Test suite() {
39         return new TestSuite(TestUUID.class);
40     }
41
42     public void testUUID() {
43         long startTime = 0;
44         long endTime = 0;
45         UUIDGen uuidgen = null;
46
47         uuidgen = UUIDGenFactory.getUUIDGen();
48         startTime = System.currentTimeMillis();
49         for (int i = 1; i <= 10; ++i) {
50             String JavaDoc u = uuidgen.nextUUID();
51             System.out.println(i + ": " + u);
52         }
53         endTime = System.currentTimeMillis();
54         System.out.println("UUIDGen took " + (endTime - startTime) + " milliseconds");
55     }
56 }
57
Popular Tags