Search in sources :

Example 6 with CommandHistory

use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.

the class CommandHistoryTest method testLimit.

public void testLimit() throws Exception {
    CommandHistory hist = new CommandHistory("test", "test", false);
    // set to a sensible value
    assertTrue(hist.getMaxSize() > 10);
    // initially?
    Entry[] entries = new Entry[] { new Entry("a", "pa"), new Entry("b", "pb"), new Entry("c", "pc"), new Entry("d", "pd") };
    for (Entry entrie : entries) {
        hist.add(entrie);
    }
    assertEquals(entries.length, hist.size());
    hist.setMaxSize(2);
    assertEquals(2, hist.getMaxSize());
    assertEquals(2, hist.size());
    assertIterator(hist, new Entry("d", "pd"), new Entry("c", "pc"));
    saveFile = new File("testSave.gch");
    hist.save(saveFile);
    hist = new CommandHistory("test", "test", false);
    // This really is a new instance
    assertTrue(hist.isEmpty());
    // set to a sensible value
    assertTrue(hist.getMaxSize() > 10);
    // initially?
    hist.load(saveFile);
    assertEquals(2, hist.getMaxSize());
    assertIterator(hist, new Entry("d", "pd"), new Entry("c", "pc"));
}
Also used : CommandHistory(org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory) Entry(org.springsource.ide.eclipse.commons.core.Entry) File(java.io.File)

Aggregations

CommandHistory (org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory)6 Entry (org.springsource.ide.eclipse.commons.core.Entry)4 File (java.io.File)2 CoreException (org.eclipse.core.runtime.CoreException)1