activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r943861 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
Date Thu, 13 May 2010 10:13:21 GMT
Author: gtully
Date: Thu May 13 10:13:21 2010
New Revision: 943861

URL: http://svn.apache.org/viewvc?rev=943861&view=rev
Log:
a trivial lrucache test to validate resize is not crazy

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
  (with props)

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java?rev=943861&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
Thu May 13 10:13:21 2010
@@ -0,0 +1,34 @@
+package org.apache.activemq.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+
+public class LRUCacheTest {
+    protected static final Log LOG = LogFactory.getLog(LRUCacheTest.class);
+    
+    @Test
+    public void testResize() throws Exception {
+        LRUCache<Long, Long> underTest = new LRUCache<Long, Long>(1000);
+        
+        Long count = new Long(0);
+        long max = 0;
+        for (; count < 27276827; count++) {
+            long start = System.currentTimeMillis();
+            if (!underTest.containsKey(count)) {
+                underTest.put(count, count);
+            }
+            long duration = System.currentTimeMillis() - start;
+            if (duration > max) {
+                LOG.info("count: " + count + ", new max=" + duration);
+                max = duration;
+            }
+            if (count % 100000000 == 0) {
+                LOG.info("count: " + count + ", max=" + max);
+            }
+        }
+        assertEquals("size is still in order", 1000, underTest.size());
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/LRUCacheTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message