I just checked out the latest code for iBATIS 3 and discovered that a unit
test fails while building.

------------------------------------------------------------
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.006 sec
<<< FAILURE!
shouldDemonstrateObjectsBeingCollectedAsNeeded(org.apache.ibatis.cache.SoftCacheTest)
 
Time elapsed: 4.96 sec  <<< FAILURE!
java.lang.AssertionError: 
        at org.junit.Assert.fail(Assert.java:71)
        at org.junit.Assert.assertTrue(Assert.java:34)
        at org.junit.Assert.assertTrue(Assert.java:43)
        at
org.apache.ibatis.cache.SoftCacheTest.shouldDemonstrateObjectsBeingCollectedAsNeeded(SoftCacheTest.java:21)
------------------------------------------------------------

It seems that this test attempts to fill the cache beyond the limits of
available memory, then checks whether the size of the cache is smaller than
the number of items added. The cache is filled with 300,000 byte arrays that
are 5001 bytes in size.

I set the limit to 3,000,000 and told the loop to break as soon as the size
of the cache was less than the number entered, and discovered that it
happened after 326,315 entries and approximately 6 seconds on my machine.
The test I used is below.

@Test
public void shouldDemonstrateObjectsBeingCollectedAsNeeded() throws
Exception {
        final int N = 3000000;
        SoftCache cache = new SoftCache(new PerpetualCache("default"));
        for (int i = 0; i < N; i++) {
          byte[] array = new byte[5001]; //waste a bunch of memory
          array[5000] = 1;
          cache.putObject(i, array);
          Object value = cache.getObject(i);
          if (cache.getSize() < i + 1) {
                  System.out.println("Cache exceeded with " + (i + 1) + " 
entries.");
                  break;
          }
        }
        assertTrue(cache.getSize() < N);
}

-- 
View this message in context: 
http://old.nabble.com/SoftCacheTest-is-Failing-tp26905687p26905687.html
Sent from the iBATIS - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ibatis.apache.org
For additional commands, e-mail: dev-h...@ibatis.apache.org

Reply via email to