use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.
the class CommandHistoryTest method testSaveLoad.
public void testSaveLoad() throws Exception {
saveFile = new File("saveit.gch");
CommandHistory hist = new CommandHistory("test", "test", false);
hist.add(new Entry("run-app foo", "kris"));
assertFalse(hist.isEmpty());
assertEquals(new Entry("run-app foo", "kris"), hist.getLast());
hist.add(new Entry("run-app bar", "nieraj"));
assertFalse(hist.isEmpty());
assertEquals(new Entry("run-app bar", "nieraj"), hist.getLast());
assertEquals(2, hist.size());
assertTrue(hist.isDirty());
hist.save(saveFile);
assertFalse(hist.isDirty());
hist = new CommandHistory("test", "test", false);
assertTrue(hist.isEmpty());
hist.load(saveFile);
assertFalse(hist.isDirty());
assertEquals(2, hist.size());
assertIterator(hist, new Entry("run-app bar", "nieraj"), new Entry("run-app foo", "kris"));
}
use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.
the class CommandHistoryTest method testAddElements.
public void testAddElements() throws Exception {
CommandHistory hist = new CommandHistory("test", "test", false);
assertFalse(hist.isDirty());
hist.add(new Entry("run-app foo", "kris"));
assertTrue(hist.isDirty());
assertFalse(hist.isEmpty());
assertEquals(new Entry("run-app foo", "kris"), hist.getLast());
hist.add(new Entry("run-app bar", "nieraj"));
assertTrue(hist.isDirty());
assertFalse(hist.isEmpty());
assertEquals(new Entry("run-app bar", "nieraj"), hist.getLast());
}
use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.
the class CommandHistoryProvider method getCommandHistory.
public static synchronized ICommandHistory getCommandHistory(String historyId, String natureId) {
String key = getKey(historyId, natureId);
if (COMMAND_HISTORIES.containsKey(key)) {
return COMMAND_HISTORIES.get(key);
} else {
try {
CommandHistory commandHistory = new CommandHistory(historyId, natureId, true);
COMMAND_HISTORIES.put(key, commandHistory);
return commandHistory;
} catch (CoreException e) {
CorePlugin.log("Warning: couldn't get persistent command history, using non-persistent history instead", e);
return new CommandHistory(historyId, natureId);
}
}
}
use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.
the class CommandHistoryTest method testNewHistory.
public void testNewHistory() throws Exception {
CommandHistory hist = new CommandHistory("test", "test", false);
assertTrue(hist.isEmpty());
}
use of org.springsource.ide.eclipse.commons.internal.core.commandhistory.CommandHistory in project eclipse-integration-commons by spring-projects.
the class CommandHistoryTest method testToArray.
public void testToArray() throws Exception {
Entry[] entries = new Entry[] { new Entry("run-app foo", "kris"), new Entry("run-app bar", "nieraj"), new Entry("blah blah", "ka.da.na.za") };
CommandHistory hist = new CommandHistory("test", "test", false);
assertTrue(hist.isEmpty());
for (int i = entries.length - 1; i >= 0; i--) {
hist.add(entries[i]);
}
assertTrue(Arrays.equals(entries, hist.toArray()));
}
Aggregations