summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-05-21 19:03:55 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-05-26 15:44:54 (GMT)
commit9416cec9c245e8998f29071635be4e416946e1a4 (patch)
tree81c8afa547cba07485ba451711a2a3ca3529f308 /test
parent4022d740676be12229e375b6fc8246a6d93aac45 (diff)
downloadstroke-9416cec9c245e8998f29071635be4e416946e1a4.zip
stroke-9416cec9c245e8998f29071635be4e416946e1a4.tar.bz2
Add functionality for UUID Generator.
Adds the Simple ID Generator as well as Random ID Generator. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for both IDGenerator and SimpleIDGenerator which passes. Change-Id: I9bce3a172774effead3ada695bcceb0b0f81b851
Diffstat (limited to 'test')
-rw-r--r--test/com/isode/stroke/base/IDGeneratorTest.java49
-rw-r--r--test/com/isode/stroke/base/SimpleIDGeneratorTest.java49
2 files changed, 98 insertions, 0 deletions
diff --git a/test/com/isode/stroke/base/IDGeneratorTest.java b/test/com/isode/stroke/base/IDGeneratorTest.java
new file mode 100644
index 0000000..34d8cc3
--- /dev/null
+++ b/test/com/isode/stroke/base/IDGeneratorTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.base;
+
+import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import com.isode.stroke.base.IDGenerator;
+import java.util.*;
+
+public class IDGeneratorTest {
+
+ private Set<String> generatedIDs_ = new HashSet<String>();
+
+ /**
+ * Constructor
+ */
+ public IDGeneratorTest() {
+
+ }
+
+ /**
+ * Clears the set generatedIDs_.
+ */
+ void setUp() {
+ generatedIDs_.clear();
+ }
+
+ /**
+ * Tests randomly generated UUID functionality
+ */
+ @Test
+ public void testGenerate() {
+ IDGenerator testling = new IDGenerator();
+ for(int i = 0; i < 26*4; ++i) {
+ String id = testling.generateID();
+ assertTrue(generatedIDs_.add(id));
+ }
+ }
+} \ No newline at end of file
diff --git a/test/com/isode/stroke/base/SimpleIDGeneratorTest.java b/test/com/isode/stroke/base/SimpleIDGeneratorTest.java
new file mode 100644
index 0000000..d4c021d
--- /dev/null
+++ b/test/com/isode/stroke/base/SimpleIDGeneratorTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.base;
+
+import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import com.isode.stroke.base.SimpleIDGenerator;
+import java.util.*;
+
+public class SimpleIDGeneratorTest {
+
+ private Set<String> generatedIDs_ = new HashSet<String>();
+
+ /**
+ * Constructor
+ */
+ public SimpleIDGeneratorTest() {
+
+ }
+
+ /**
+ * Clears the set generatedIDs_.
+ */
+ void setUp() {
+ generatedIDs_.clear();
+ }
+
+ /**
+ * Tests randomly generated UUID functionality
+ */
+ @Test
+ public void testGenerate() {
+ SimpleIDGenerator testling = new SimpleIDGenerator();
+ for(int i = 0; i < 26*4; ++i) {
+ String id = testling.generateID();
+ assertTrue(generatedIDs_.add(id));
+ }
+ }
+} \ No newline at end of file