Exemple #1
0
  @Test
  public void testGC2() throws Exception {
    int reduceSize = 500;
    int gcRuns = PictureTilingCacheGCManager.getGCRuns();
    int gcCalls = PictureTilingCacheGCManager.getGCCalls();
    PictureTilingComponent.endGC();

    String maxStr =
        PictureTilingComponent.getEnvValue(
            PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY,
            Long.toString(PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KB));
    PictureTilingComponent.setEnvValue(
        PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY, Integer.toString(reduceSize));

    PictureTilingService pts = Framework.getLocalService(PictureTilingService.class);
    assertNotNull(pts);
    benchTiler(pts, new MagickTiler());

    // System.out.println("Tiling run 1");
    testMagick2();
    // System.out.println("Tiling run 2");
    testMagick2();
    // System.out.println("Tiling run 3");
    testMagick2();

    long cacheSize = PictureTilingCacheGCManager.getCacheSizeInKBs();
    // System.out.println("CacheSize = " + cacheSize + "KB");
    assertTrue(cacheSize > 0);

    GCTask.setGCIntervalInMinutes(-100);
    PictureTilingComponent.startGC();

    // System.out.println("waiting for GC to run");
    Thread.currentThread().sleep(600);

    int gcRuns2 = PictureTilingCacheGCManager.getGCRuns();
    int gcCalls2 = PictureTilingCacheGCManager.getGCCalls();

    int runs = gcRuns2 - gcRuns;
    int calls = gcCalls2 - gcCalls;
    // System.out.println("GC runs = " + runs);
    // System.out.println("GC calls = " + calls);

    assertTrue(runs > 0);
    assertTrue(calls > 2);

    PictureTilingComponent.endGC();

    long newCacheSize = PictureTilingCacheGCManager.getCacheSizeInKBs();
    // System.out.println("new cacheSize = " + newCacheSize + "KB");
    // System.out.println("effective delta = " + (cacheSize - newCacheSize)
    // + "KB");
    assertTrue(cacheSize - newCacheSize > reduceSize);

    PictureTilingComponent.setEnvValue(
        PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY, maxStr);
  }
Exemple #2
0
  @Test
  public void testParametersContrib() throws Exception {
    deployContrib("org.nuxeo.ecm.platform.pictures.tiles", "OSGI-INF/pictures-tiles-contrib.xml");

    String cacheSize =
        PictureTilingComponent.getEnvValue(
            PictureTilingCacheGCManager.MAX_DISK_SPACE_USAGE_KEY, "ERROR");

    assertEquals("50000", cacheSize);
  }