Examples of DozerCache


Examples of org.dozer.cache.DozerCache

*/
public class DozerCacheTest extends AbstractDozerTest {

  @Test
  public void testPutGetFromCache() throws Exception {
    Cache cache = new DozerCache(getRandomString(), 50);
    int numCacheEntriesToAdd = 45;
    for (int i = 0; i < numCacheEntriesToAdd; i++) {
      Object key = String.valueOf(i);

      assertNull("cache entry should not already exist", cache.get(key));

      cache.put(key, "testvalue" + i);

      String value = (String) cache.get(key);
      assertEquals("cache entries should be equal", value, "testvalue" + i);
    }
    assertEquals("invlid cache size", numCacheEntriesToAdd, cache.getSize());
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

  }

  @Test
  public void testMaximumCacheSize() throws Exception {
    int maxSize = 25;
    Cache cache = new DozerCache(getRandomString(), maxSize);
    // Add a bunch of entries to cache to verify the cache doesnt grow larger than specified max size
    for (int i = 0; i < maxSize + 125; i++) {
      cache.put("testkey" + i, "testvalue" + i);
    }
    assertEquals("cache size should not exceed max size", maxSize, cache.getSize());
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

  }

  @Test(expected = IllegalArgumentException.class)
  public void testMaximumCacheSize_Zero() throws Exception {
    int maxSize = 0;
    Cache cache = new DozerCache(getRandomString(), maxSize);
    // Add a bunch of entries to cache to verify the cache doesnt grow larger than specified max size
    for (int i = 0; i < maxSize + 5; i++) {
      cache.put("testkey" + i, "testvalue" + i);
    }
    assertEquals("cache size should not exceed max size", maxSize, cache.getSize());
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

  }

  @Test
  public void testGetMaxSize() {
    int maxSize = 550;
    Cache cache = new DozerCache(getRandomString(), maxSize);

    assertEquals("invalid max size", maxSize, cache.getMaxSize());
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

    assertEquals("invalid max size", maxSize, cache.getMaxSize());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testGetNull() {
    Cache cache = new DozerCache(getRandomString(), 5);
    cache.get(null);
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

    cache.get(null);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testPutNull() {
    Cache cache = new DozerCache(getRandomString(), 5);
    cache.put(null, null);
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

    cache.put(null, null);
  }

  @Test
  public void testAddEntries() {
    DozerCache cache = new DozerCache(getRandomString(), 5);
    DozerCache<String, String> cache2 = new DozerCache<String, String>(getRandomString(), 5);

    cache2.put("A", "B");
    cache2.put("B", "C");

    assertEquals(0, cache.getSize());

    cache.addEntries(cache2.getEntries());

    assertEquals(2, cache.getSize());
    assertEquals(2, cache2.getSize());
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

  private List<CustomConverterDescription> converters;

  @Before
  public void setUp() throws Exception {
    ccc = new CustomConverterContainer();
    cache = new DozerCache("NAME", 10);
    converters = new ArrayList<CustomConverterDescription>();
    ccc.setConverters(converters);
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

  private List<CustomConverterDescription> converters;

  @Before
  public void setUp() throws Exception {
    ccc = new CustomConverterContainer();
    cache = new DozerCache("NAME", 10);
    converters = new ArrayList<CustomConverterDescription>();
    ccc.setConverters(converters);
  }
View Full Code Here

Examples of org.dozer.cache.DozerCache

*/
public class DozerCacheTest extends AbstractDozerTest {

  @Test
  public void testPutGetFromCache() throws Exception {
    Cache cache = new DozerCache(getRandomString(), 50);
    int numCacheEntriesToAdd = 45;
    for (int i = 0; i < numCacheEntriesToAdd; i++) {
      Object key = String.valueOf(i);

      assertNull("cache entry should not already exist", cache.get(key));

      cache.put(key, "testvalue" + i);

      String value = (String) cache.get(key);
      assertEquals("cache entries should be equal", value, "testvalue" + i);
    }
    assertEquals("invlid cache size", numCacheEntriesToAdd, cache.getSize());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.