]> source.dussan.org Git - gitblit.git/commitdiff
Unit testing
authorJames Moger <james.moger@gitblit.com>
Tue, 8 Nov 2011 02:21:28 +0000 (21:21 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 8 Nov 2011 02:21:28 +0000 (21:21 -0500)
src/com/gitblit/utils/TimeUtils.java
tests/com/gitblit/tests/Base64Test.java [new file with mode: 0644]
tests/com/gitblit/tests/FileUtilsTest.java
tests/com/gitblit/tests/GitBlitSuite.java
tests/com/gitblit/tests/GitBlitTest.java
tests/com/gitblit/tests/JsonUtilsTest.java [new file with mode: 0644]
tests/com/gitblit/tests/ObjectCacheTest.java [new file with mode: 0644]
tests/com/gitblit/tests/RpcTests.java
tests/com/gitblit/tests/SyndicationUtilsTest.java
tests/com/gitblit/tests/TimeUtilsTest.java

index 7ac1e79f6724e960ff45f21cec8244b90427a21c..ef8d428709b689154d79931298d4e2d2dbe9342a 100644 (file)
@@ -253,11 +253,9 @@ public class TimeUtils {
                int mins = 60;\r
                if (!StringUtils.isEmpty(frequency)) {\r
                        try {\r
-                               String str;\r
+                               String str = frequency.trim();\r
                                if (frequency.indexOf(' ') > -1) {\r
-                                       str = frequency.substring(0, frequency.indexOf(' ')).trim();\r
-                               } else {\r
-                                       str = frequency.trim();\r
+                                       str = str.substring(0, str.indexOf(' ')).trim();\r
                                }\r
                                mins = (int) Float.parseFloat(str);\r
                        } catch (NumberFormatException e) {\r
@@ -268,7 +266,7 @@ public class TimeUtils {
                }\r
                if (frequency.indexOf("day") > -1) {\r
                        // convert to minutes\r
-                       mins *= 24 * 60;\r
+                       mins *= 1440;\r
                } else if (frequency.indexOf("hour") > -1) {\r
                        // convert to minutes\r
                        mins *= 60;\r
diff --git a/tests/com/gitblit/tests/Base64Test.java b/tests/com/gitblit/tests/Base64Test.java
new file mode 100644 (file)
index 0000000..3127736
--- /dev/null
@@ -0,0 +1,31 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.tests;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import com.gitblit.utils.Base64;\r
+\r
+public class Base64Test extends TestCase {\r
+\r
+       public void testBase64() {\r
+               String source = "this is a test";               \r
+               String base64 = Base64.encodeBytes(source.getBytes());\r
+               assertEquals("dGhpcyBpcyBhIHRlc3Q=", base64);\r
+               String decoded = new String(Base64.decode(base64));\r
+               assertEquals(source, decoded);\r
+       }\r
+}
\ No newline at end of file
index 63d0f330f5313b5019d392ccbad166d458903431..025a2238e04abadc3de3bdf7cac891f9e5cb2733 100644 (file)
@@ -28,6 +28,14 @@ public class FileUtilsTest extends TestCase {
                String rawContent = FileUtils.readContent(new File(dir, "LICENSE"), "\n");\r
                assertTrue(rawContent.trim().startsWith("Apache License"));\r
        }\r
+       \r
+       public void testWriteContent() throws Exception {\r
+               String contentA = "this is a test";\r
+               File tmp = File.createTempFile("gitblit-", ".test");\r
+               FileUtils.writeContent(tmp, contentA);\r
+               String contentB = FileUtils.readContent(tmp, "\n").trim();\r
+               assertEquals(contentA, contentB);\r
+       }\r
 \r
        public void testFolderSize() throws Exception {\r
                assertEquals(-1, FileUtils.folderSize(null));\r
index 52a1d0bfca45228d0f7c0e3e8dae981d7e402f60..ad87cb0b93da0aede39a607a46f10150d1d530e6 100644 (file)
@@ -16,6 +16,7 @@
 package com.gitblit.tests;\r
 \r
 import java.io.File;\r
+import java.util.concurrent.Executors;\r
 \r
 import junit.extensions.TestSetup;\r
 import junit.framework.Test;\r
@@ -28,12 +29,21 @@ import com.gitblit.FileSettings;
 import com.gitblit.FileUserService;\r
 import com.gitblit.GitBlit;\r
 import com.gitblit.GitBlitException;\r
+import com.gitblit.GitBlitServer;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.utils.JGitUtils;\r
 \r
 public class GitBlitSuite extends TestSetup {\r
+\r
        public static final File REPOSITORIES = new File("git");\r
 \r
+       static int port = 8280;\r
+       static int shutdownPort = 8281;\r
+\r
+       public static String url = "http://localhost:" + port;\r
+       public static String account = "admin";\r
+       public static String password = "admin";\r
+\r
        private GitBlitSuite(TestSuite suite) {\r
                super(suite);\r
        }\r
@@ -43,7 +53,10 @@ public class GitBlitSuite extends TestSetup {
                suite.addTestSuite(FileUtilsTest.class);\r
                suite.addTestSuite(TimeUtilsTest.class);\r
                suite.addTestSuite(StringUtilsTest.class);\r
+               suite.addTestSuite(Base64Test.class);\r
+               suite.addTestSuite(JsonUtilsTest.class);\r
                suite.addTestSuite(ByteFormatTest.class);\r
+               suite.addTestSuite(ObjectCacheTest.class);\r
                suite.addTestSuite(MarkdownUtilsTest.class);\r
                suite.addTestSuite(JGitUtilsTest.class);\r
                suite.addTestSuite(SyndicationUtilsTest.class);\r
@@ -51,6 +64,7 @@ public class GitBlitSuite extends TestSetup {
                suite.addTestSuite(MetricUtilsTest.class);\r
                suite.addTestSuite(TicgitUtilsTest.class);\r
                suite.addTestSuite(GitBlitTest.class);\r
+               suite.addTestSuite(RpcTests.class);\r
                return new GitBlitSuite(suite);\r
        }\r
 \r
@@ -70,6 +84,29 @@ public class GitBlitSuite extends TestSetup {
                return new FileRepository(new File(REPOSITORIES, "test/bluez-gnome.git"));\r
        }\r
 \r
+       public static void startGitblit() throws Exception {\r
+               // Start a Gitblit instance\r
+               Executors.newSingleThreadExecutor().execute(new Runnable() {\r
+                       public void run() {\r
+                               GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
+                                               "" + shutdownPort, "--repositoriesFolder",\r
+                                               "\"" + GitBlitSuite.REPOSITORIES.getAbsolutePath() + "\"", "--userService",\r
+                                               "distrib/users.properties");\r
+                       }\r
+               });\r
+\r
+               // Wait a few seconds for it to be running\r
+               Thread.sleep(2500);\r
+       }\r
+\r
+       public static void stopGitblit() throws Exception {\r
+               // Stop Gitblit\r
+               GitBlitServer.main("--stop", "--shutdownPort", "" + shutdownPort);\r
+\r
+               // Wait a few seconds for it to be running\r
+               Thread.sleep(2500);\r
+       }\r
+\r
        @Override\r
        protected void setUp() throws Exception {\r
                FileSettings settings = new FileSettings("distrib/gitblit.properties");\r
@@ -90,6 +127,13 @@ public class GitBlitSuite extends TestSetup {
                        showRemoteBranches("ticgit.git");\r
                        showRemoteBranches("test/jgit.git");\r
                }\r
+\r
+               startGitblit();\r
+       }\r
+\r
+       @Override\r
+       protected void tearDown() throws Exception {\r
+               stopGitblit();\r
        }\r
 \r
        private void cloneOrFetch(String name, String fromUrl) throws Exception {\r
index 81616c3b193269a3f27046ac24d15875d873a2d8..1d20ced92e6de46ee44b0aa3d80dd83fe037ebc7 100644 (file)
@@ -111,13 +111,13 @@ public class GitBlitTest extends TestCase {
        public void testGitblitSettings() throws Exception {\r
                // These are already tested by above test method.\r
                assertTrue(GitBlit.getBoolean("missing", true));\r
-               assertTrue(GitBlit.getString("missing", "default").equals("default"));\r
-               assertTrue(GitBlit.getInteger("missing", 10) == 10);\r
-               assertTrue(GitBlit.getInteger("realm.userService", 5) == 5);\r
+               assertEquals("default", GitBlit.getString("missing", "default"));\r
+               assertEquals(10, GitBlit.getInteger("missing", 10));\r
+               assertEquals(5, GitBlit.getInteger("realm.userService", 5));\r
 \r
                assertTrue(GitBlit.getBoolean("git.enableGitServlet", false));\r
-               assertTrue(GitBlit.getString("realm.userService", null).equals("users.properties"));\r
-               assertTrue(GitBlit.getInteger("realm.minPasswordLength", 0) == 5);\r
+               assertEquals("distrib/users.properties", GitBlit.getString("realm.userService", null));\r
+               assertEquals(5, GitBlit.getInteger("realm.minPasswordLength", 0));\r
                List<String> mdExtensions = GitBlit.getStrings("web.markdownExtensions");\r
                assertTrue(mdExtensions.size() > 0);\r
                assertTrue(mdExtensions.contains("md"));\r
diff --git a/tests/com/gitblit/tests/JsonUtilsTest.java b/tests/com/gitblit/tests/JsonUtilsTest.java
new file mode 100644 (file)
index 0000000..e70bd8a
--- /dev/null
@@ -0,0 +1,58 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.tests;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import com.gitblit.utils.JsonUtils;\r
+import com.google.gson.reflect.TypeToken;\r
+\r
+public class JsonUtilsTest extends TestCase {\r
+\r
+       public void testSerialization() {\r
+               Map<String, String> map = new HashMap<String, String>();\r
+               map.put("a", "alligator");\r
+               map.put("b", "bear");\r
+               map.put("c", "caterpillar");\r
+               map.put("d", "dingo");\r
+               map.put("e", "eagle");\r
+               String json = JsonUtils.toJsonString(map);\r
+               assertEquals(\r
+                               "{\n  \"d\": \"dingo\",\n  \"e\": \"eagle\",\n  \"b\": \"bear\",\n  \"c\": \"caterpillar\",\n  \"a\": \"alligator\"\n}",\r
+                               json);\r
+               Map<String, String> map2 = JsonUtils.fromJsonString(json,\r
+                               new TypeToken<Map<String, String>>() {\r
+                               }.getType());\r
+               assertEquals(map, map2);\r
+\r
+               SomeJsonObject someJson = new SomeJsonObject();\r
+               json = JsonUtils.toJsonString(someJson);\r
+               SomeJsonObject someJson2 = JsonUtils.fromJsonString(json, SomeJsonObject.class);\r
+               assertEquals(someJson.name, someJson2.name);\r
+               SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd HHmmss");\r
+               assertEquals(df.format(someJson.date), df.format(someJson2.date));\r
+       }\r
+\r
+       private class SomeJsonObject {\r
+               Date date = new Date();\r
+               String name = "myJson";\r
+       }\r
+}
\ No newline at end of file
diff --git a/tests/com/gitblit/tests/ObjectCacheTest.java b/tests/com/gitblit/tests/ObjectCacheTest.java
new file mode 100644 (file)
index 0000000..054761f
--- /dev/null
@@ -0,0 +1,42 @@
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.tests;\r
+\r
+import java.util.Date;\r
+\r
+import junit.framework.TestCase;\r
+\r
+import com.gitblit.utils.ObjectCache;\r
+\r
+public class ObjectCacheTest extends TestCase {\r
+\r
+       public void testCache() throws Exception {\r
+               ObjectCache<String> cache = new ObjectCache<String>();\r
+               cache.updateObject("test", "alpha");\r
+               Date date = cache.getDate("test");\r
+               assertTrue("cache date is not working!", cache.hasCurrent("test", date));\r
+               // The cache is time-based (msecs) so we insert this artificial sleep to\r
+               // ensure that time (msecs) advances. The ObjectCache class is suitable\r
+               // for Gitblit's needs but may not be suitable for other needs.\r
+               Thread.sleep(10);\r
+               cache.updateObject("test", "beta");\r
+               assertFalse("update cache date is not working!", cache.hasCurrent("test", date));\r
+               assertEquals("unexpected cache object", cache.getObject("test"), "beta");\r
+               assertEquals("beta", cache.remove("test"));\r
+               assertEquals(null, cache.getObject("test"));\r
+               assertEquals(null, cache.remove("test"));\r
+       }\r
+}\r
index a64d1b8737af5572cf6ac649b722cf86240e190d..ab6a8b8a10435b9480d420cf0dd9010cf890f24c 100644 (file)
  */\r
 package com.gitblit.tests;\r
 \r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertTrue;\r
-\r
 import java.io.IOException;\r
 import java.util.Collection;\r
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
-import java.util.concurrent.Executors;\r
+\r
+import junit.framework.TestCase;\r
 \r
 import org.junit.AfterClass;\r
 import org.junit.BeforeClass;\r
@@ -31,7 +29,6 @@ import org.junit.Test;
 \r
 import com.gitblit.Constants.AccessRestrictionType;\r
 import com.gitblit.GitBlitException.UnauthorizedException;\r
-import com.gitblit.GitBlitServer;\r
 import com.gitblit.Keys;\r
 import com.gitblit.models.FederationModel;\r
 import com.gitblit.models.FederationProposal;\r
@@ -48,38 +45,21 @@ import com.gitblit.utils.RpcUtils;
  * @author James Moger\r
  * \r
  */\r
-public class RpcTests {\r
-\r
-       static int port = 8180;\r
-       static int shutdownPort = 8181;\r
-\r
-       String url = "http://localhost:" + port;\r
-       String account = "admin";\r
-       String password = "admin";\r
+public class RpcTests extends TestCase {\r
+       \r
+       String url = GitBlitSuite.url;\r
+       String account = GitBlitSuite.account;\r
+       String password = GitBlitSuite.password;\r
+       \r
 \r
        @BeforeClass\r
        public static void startGitblit() throws Exception {\r
-               // Start a Gitblit instance\r
-               Executors.newSingleThreadExecutor().execute(new Runnable() {\r
-                       public void run() {\r
-                               GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
-                                               "" + shutdownPort, "--repositoriesFolder",\r
-                                               "\"" + GitBlitSuite.REPOSITORIES.getAbsolutePath() + "\"", "--userService",\r
-                                               "distrib/users.properties");\r
-                       }\r
-               });\r
-\r
-               // Wait a few seconds for it to be running\r
-               Thread.sleep(2500);\r
+               GitBlitSuite.startGitblit();\r
        }\r
 \r
        @AfterClass\r
        public static void stopGitblit() throws Exception {\r
-               // Stop Gitblit\r
-               GitBlitServer.main("--stop", "--shutdownPort", "" + shutdownPort);\r
-\r
-               // Wait a few seconds for it to be running\r
-               Thread.sleep(2500);\r
+               GitBlitSuite.stopGitblit();\r
        }\r
 \r
        @Test\r
index e0a32bf3c34f8e1ce49ec1bddf2f6434f913d1cf..0746642c469f9a96a8144485f332749472ef6906 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Set;
 \r
 import junit.framework.TestCase;\r
 \r
+import com.gitblit.Constants.SearchType;\r
 import com.gitblit.models.SyndicatedEntryModel;\r
 import com.gitblit.utils.SyndicationUtils;\r
 \r
@@ -41,6 +42,11 @@ public class SyndicationUtilsTest extends TestCase {
                        entry.content = "Content " + i;\r
                        entry.repository = "Repository " + i;\r
                        entry.branch = "Branch " + i;\r
+                       List<String> tags = new ArrayList<String>();\r
+                       for (int j = 0; j < 5; j++) {\r
+                               tags.add("Tag " + j);\r
+                       }\r
+                       entry.tags = tags;\r
                        entries.add(entry);\r
                }\r
                ByteArrayOutputStream os = new ByteArrayOutputStream();\r
@@ -55,8 +61,9 @@ public class SyndicationUtilsTest extends TestCase {
        public void testFeedRead() throws Exception {\r
                Set<String> links = new HashSet<String>();\r
                for (int i = 0; i < 2; i++) {\r
-                       List<SyndicatedEntryModel> feed = SyndicationUtils.readFeed("https://localhost:8443",\r
-                                       "ticgit.git", "master", 5, i, "admin", "admin".toCharArray());\r
+                       List<SyndicatedEntryModel> feed = SyndicationUtils.readFeed(GitBlitSuite.url,\r
+                                       "ticgit.git", "master", 5, i, GitBlitSuite.account,\r
+                                       GitBlitSuite.password.toCharArray());\r
                        assertTrue(feed != null);\r
                        assertTrue(feed.size() > 0);\r
                        assertEquals(5, feed.size());\r
@@ -69,10 +76,16 @@ public class SyndicationUtilsTest extends TestCase {
        }\r
 \r
        public void testSearchFeedRead() throws Exception {\r
-               List<SyndicatedEntryModel> feed = SyndicationUtils.readSearchFeed("https://localhost:8443",\r
-                               "ticgit.git", null, "documentation", null, 5, 0, "admin", "admin".toCharArray());\r
+               List<SyndicatedEntryModel> feed = SyndicationUtils.readSearchFeed(GitBlitSuite.url,\r
+                               "ticgit.git", null, "test", null, 5, 0, GitBlitSuite.account,\r
+                               GitBlitSuite.password.toCharArray());\r
+               assertTrue(feed != null);\r
+               assertTrue(feed.size() > 0);\r
+               assertEquals(5, feed.size());\r
+               feed = SyndicationUtils.readSearchFeed(GitBlitSuite.url, "ticgit.git", "master", "test",\r
+                               SearchType.COMMIT, 5, 1, GitBlitSuite.account, GitBlitSuite.password.toCharArray());\r
                assertTrue(feed != null);\r
                assertTrue(feed.size() > 0);\r
-               assertEquals(2, feed.size());\r
+               assertEquals(5, feed.size());\r
        }\r
 }
\ No newline at end of file
index b2c819ff4f184338616a06f3bb381784dc01ad5b..07ed827c5fcafd8c0110f9b9f54d538827e6837e 100644 (file)
@@ -47,49 +47,55 @@ public class TimeUtilsTest extends TestCase {
        }\r
 \r
        public void testDurations() throws Exception {\r
-               assertTrue(TimeUtils.duration(1).equals("1 day"));\r
-               assertTrue(TimeUtils.duration(5).equals("5 days"));\r
-               assertTrue(TimeUtils.duration(75).equals("3 months"));\r
-               assertTrue(TimeUtils.duration(364).equals("12 months"));\r
-               assertTrue(TimeUtils.duration(365 + 0).equals("1 year"));\r
-               assertTrue(TimeUtils.duration(365 + 10).equals("1 year"));\r
-               assertTrue(TimeUtils.duration(365 + 15).equals("1 year, 1 month"));\r
-               assertTrue(TimeUtils.duration(365 + 30).equals("1 year, 1 month"));\r
-               assertTrue(TimeUtils.duration(365 + 44).equals("1 year, 1 month"));\r
-               assertTrue(TimeUtils.duration(365 + 45).equals("1 year, 2 months"));\r
-               assertTrue(TimeUtils.duration(365 + 60).equals("1 year, 2 months"));\r
+               assertEquals("1 day", TimeUtils.duration(1));\r
+               assertEquals("5 days", TimeUtils.duration(5));\r
+               assertEquals("3 months", TimeUtils.duration(75));\r
+               assertEquals("12 months", TimeUtils.duration(364));\r
+               assertEquals("1 year", TimeUtils.duration(365 + 0));\r
+               assertEquals("1 year", TimeUtils.duration(365 + 10));\r
+               assertEquals("1 year, 1 month", TimeUtils.duration(365 + 15));\r
+               assertEquals("1 year, 1 month", TimeUtils.duration(365 + 30));\r
+               assertEquals("1 year, 1 month", TimeUtils.duration(365 + 44));\r
+               assertEquals("1 year, 2 months", TimeUtils.duration(365 + 45));\r
+               assertEquals("1 year, 2 months", TimeUtils.duration(365 + 60));\r
 \r
-               assertTrue(TimeUtils.duration(2 * 365 + 0).equals("2 years"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 10).equals("2 years"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 15).equals("2 years, 1 month"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 30).equals("2 years, 1 month"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 44).equals("2 years, 1 month"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 45).equals("2 years, 2 months"));\r
-               assertTrue(TimeUtils.duration(2 * 365 + 60).equals("2 years, 2 months"));\r
+               assertEquals("2 years", TimeUtils.duration(2 * 365 + 0));\r
+               assertEquals("2 years", TimeUtils.duration(2 * 365 + 10));\r
+               assertEquals("2 years, 1 month", TimeUtils.duration(2 * 365 + 15));\r
+               assertEquals("2 years, 1 month", TimeUtils.duration(2 * 365 + 30));\r
+               assertEquals("2 years, 1 month", TimeUtils.duration(2 * 365 + 44));\r
+               assertEquals("2 years, 2 months", TimeUtils.duration(2 * 365 + 45));\r
+               assertEquals("2 years, 2 months", TimeUtils.duration(2 * 365 + 60));\r
        }\r
 \r
        public void testTimeAgo() throws Exception {\r
                // standard time ago tests\r
-               assertTrue(TimeUtils.timeAgo(offset(1 * TimeUtils.MIN)).equals("1 min ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(60 * TimeUtils.MIN)).equals("60 mins ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(120 * TimeUtils.MIN)).equals("2 hours ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(15 * TimeUtils.ONEHOUR)).equals("15 hours ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(24 * TimeUtils.ONEHOUR)).equals("yesterday"));\r
-               assertTrue(TimeUtils.timeAgo(offset(2 * TimeUtils.ONEDAY)).equals("2 days ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(35 * TimeUtils.ONEDAY)).equals("5 weeks ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(84 * TimeUtils.ONEDAY)).equals("3 months ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(95 * TimeUtils.ONEDAY)).equals("3 months ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(104 * TimeUtils.ONEDAY)).equals("4 months ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(365 * TimeUtils.ONEDAY)).equals("1 year ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset(395 * TimeUtils.ONEDAY)).equals("13 months ago"));\r
-               assertTrue(TimeUtils.timeAgo(offset((2 * 365 + 30) * TimeUtils.ONEDAY)).equals(\r
-                               "2 years ago"));\r
+               assertEquals("1 min ago", TimeUtils.timeAgo(offset(1 * TimeUtils.MIN)));\r
+               assertEquals("60 mins ago", TimeUtils.timeAgo(offset(60 * TimeUtils.MIN)));\r
+               assertEquals("2 hours ago", TimeUtils.timeAgo(offset(120 * TimeUtils.MIN)));\r
+               assertEquals("15 hours ago", TimeUtils.timeAgo(offset(15 * TimeUtils.ONEHOUR)));\r
+               assertEquals("yesterday", TimeUtils.timeAgo(offset(24 * TimeUtils.ONEHOUR)));\r
+               assertEquals("2 days ago", TimeUtils.timeAgo(offset(2 * TimeUtils.ONEDAY)));\r
+               assertEquals("5 weeks ago", TimeUtils.timeAgo(offset(35 * TimeUtils.ONEDAY)));\r
+               assertEquals("3 months ago", TimeUtils.timeAgo(offset(84 * TimeUtils.ONEDAY)));\r
+               assertEquals("3 months ago", TimeUtils.timeAgo(offset(95 * TimeUtils.ONEDAY)));\r
+               assertEquals("4 months ago", TimeUtils.timeAgo(offset(104 * TimeUtils.ONEDAY)));\r
+               assertEquals("1 year ago", TimeUtils.timeAgo(offset(365 * TimeUtils.ONEDAY)));\r
+               assertEquals("13 months ago", TimeUtils.timeAgo(offset(395 * TimeUtils.ONEDAY)));\r
+               assertEquals("2 years ago", TimeUtils.timeAgo(offset((2 * 365 + 30) * TimeUtils.ONEDAY)));\r
 \r
                // css class tests\r
-               assertTrue(TimeUtils.timeAgoCss(offset(1 * TimeUtils.MIN)).equals("age0"));\r
-               assertTrue(TimeUtils.timeAgoCss(offset(60 * TimeUtils.MIN)).equals("age0"));\r
-               assertTrue(TimeUtils.timeAgoCss(offset(120 * TimeUtils.MIN)).equals("age1"));\r
-               assertTrue(TimeUtils.timeAgoCss(offset(24 * TimeUtils.ONEHOUR)).equals("age1"));\r
-               assertTrue(TimeUtils.timeAgoCss(offset(2 * TimeUtils.ONEDAY)).equals("age2"));\r
+               assertEquals("age0", TimeUtils.timeAgoCss(offset(1 * TimeUtils.MIN)));\r
+               assertEquals("age0", TimeUtils.timeAgoCss(offset(60 * TimeUtils.MIN)));\r
+               assertEquals("age1", TimeUtils.timeAgoCss(offset(120 * TimeUtils.MIN)));\r
+               assertEquals("age1", TimeUtils.timeAgoCss(offset(24 * TimeUtils.ONEHOUR)));\r
+               assertEquals("age2", TimeUtils.timeAgoCss(offset(2 * TimeUtils.ONEDAY)));\r
+       }\r
+\r
+       public void testFrequency() {\r
+               assertEquals(5, TimeUtils.convertFrequencyToMinutes("2 mins"));\r
+               assertEquals(10, TimeUtils.convertFrequencyToMinutes("10 mins"));\r
+               assertEquals(600, TimeUtils.convertFrequencyToMinutes("10 hours"));\r
+               assertEquals(14400, TimeUtils.convertFrequencyToMinutes(" 10 days "));\r
        }\r
 }\r