Beispiel #1
0
    public void testFillTheCache(String type) {
      final int size = 100;
      Cache c1 = CacheManager.createCache(type, "c1", size);
      String[] k = new String[size];
      String[] v = new String[size];

      for (int i = 0; i < size; i++) {
        k[i] = "K" + i;
        v[i] = "V" + i;
        c1.put(k[i], v[i]);
      }

      int count = 0;

      for (int i = 0; i < size; i++) {
        if (c1.get(k[i]) != null) {
          count++;
        }
      }

      assertTrue("too low a hit rate: " + type + " = " + count, count > size / 2);
      assertEquals("count puts", size, c1.getPuts());
      assertEquals("count gets", size, c1.getGets());
      assertEquals("count hits", count, c1.getHits());
    }