Debian Codegraph @

test/components/TestUUID.java

raw
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.FastUUIDGen;
30 import org.apache.axis.components.uuid.UUIDGen;
31 import org.apache.axis.components.uuid.UUIDGenFactory;
32
33 public class TestUUID extends TestCase {
34
35 public TestUUID(String name) {
36 super(name);
37 }
38
39 public static Test suite() {
40 return new TestSuite(TestUUID.class);
41 }
42
43 public void testUUID() {
44 long startTime = 0;
45 long endTime = 0;
46 UUIDGen uuidgen = null;
47
48 uuidgen = UUIDGenFactory.getUUIDGen();
49 startTime = System.currentTimeMillis();
50 for (int i = 1; i <= 10; ++i) {
51 String u = uuidgen.nextUUID();
52 System.out.println(i + ": " + u);
53 }
54 endTime = System.currentTimeMillis();
55 System.out.println("UUIDGen took " + (endTime - startTime) + " milliseconds");
56 }
57
58 public void testSequence() {
59 String current = null;
60 String prev = null;
61
62 FastUUIDGen g = new FastUUIDGen();
63 for (int i=0;i<1000;i++) {
64 current = g.nextUUID();
65 if (current.equals(prev)) {
66 fail("same uuid generated: " + current + " " + prev);
67 }
68 prev = current;
69 }
70 }
71 }