Example #1
0
 public void test_removeEldestEntry_lruReplacement() {
   PageState.maxPageStates = 3;
   Config.setDataset("main", new Dataset("maxPageStates", "4"));
   PageState.getPageState(cr, "id1", true);
   PageState.getPageState(cr, "id2", true);
   PageState.getPageState(cr, "id3", true);
   assertEquals("page ids before replacement", "id1, id2, id3", getPageIds(cr));
   PageState.getPageState(cr, "id4", true);
   assertEquals("page ids after replacement", "id2, id3, id4", getPageIds(cr));
 }
Example #2
0
 public void test_removeEldestEntry_maxPageStatesNotDefined() {
   PageState.maxPageStates = -1;
   Config.setDataset("main", new Dataset());
   boolean gotException = false;
   try {
     PageState.getPageState(cr, "id123", true);
   } catch (Dataset.MissingValueError e) {
     assertEquals(
         "exception message", "couldn't find dataset element \"maxPageStates\"", e.getMessage());
     gotException = true;
   }
   assertEquals("exception happened", true, gotException);
 }
Example #3
0
  public void test_removeEldestEntry_maxPageStatesValueBogus() {
    PageState.maxPageStates = -1;
    Config.setDataset("main", new Dataset("maxPageStates", "7bogus8"));

    boolean gotException = false;
    try {
      PageState.getPageState(cr, "id123", true);
    } catch (InternalError e) {
      assertEquals(
          "exception message",
          "bad value \"7bogus8\" for maxPageStates configuration " + "option: must be an integer",
          e.getMessage());
      gotException = true;
    }
    assertEquals("exception happened", true, gotException);
  }
Example #4
0
 public void test_removeEldestEntry_setMaxPageStates() {
   PageState.maxPageStates = -1;
   Config.setDataset("main", new Dataset("maxPageStates", "7"));
   PageState.getPageState(cr, "id123", true);
   assertEquals("maxPageStates", 7, PageState.maxPageStates);
 }