editorModel.saveBufferAs(buffer, file1);
buffer.save(file1);
  public void testSaveBufferAs() throws Exception {    final StringTextSource.Factory stringTextSourceFactory =      new StringTextSource.Factory();    final EditorModel editorModel = new EditorModel(s_resources,                                                    stringTextSourceFactory,                                                    m_agentCacheState,                                                    m_fileChangeWatcher);    final RandomStubFactory listenerStubFactory =      new RandomStubFactory(EditorModel.Listener.class);    final EditorModel.Listener listener =      (EditorModel.Listener)listenerStubFactory.getStub();    editorModel.selectNewBuffer();    final Buffer buffer = editorModel.getSelectedBuffer();    stringTextSourceFactory.getLast().setText("Some text");    final File file1 = new File(getDirectory(), "a file");    final File file2 = new File(getDirectory(), "another  file");    editorModel.addListener(listener);    editorModel.saveBufferAs(buffer, file1);    // Buffer changed because it is associated with a new file.    listenerStubFactory.assertSuccess("bufferStateChanged", buffer);    listenerStubFactory.assertNoMoreCalls();    m_agentCacheStateStubFactory.assertSuccess("setOutOfDate",                                               new Long(file1.lastModified()));    m_agentCacheStateStubFactory.assertNoMoreCalls();    editorModel.saveBufferAs(buffer, file1);    listenerStubFactory.assertNoMoreCalls();    m_agentCacheStateStubFactory.assertSuccess("setOutOfDate",                                             new Long(file1.lastModified()));    m_agentCacheStateStubFactory.assertNoMoreCalls();    assertEquals(buffer, editorModel.getBufferForFile(file1));    editorModel.saveBufferAs(buffer, file2);    // Buffer changed because it is associated with a new file.    listenerStubFactory.assertSuccess("bufferStateChanged", buffer);    listenerStubFactory.assertNoMoreCalls();    m_agentCacheStateStubFactory.assertSuccess("setOutOfDate",                                             new Long(file2.lastModified()));    m_agentCacheStateStubFactory.assertNoMoreCalls();    assertNull(editorModel.getBufferForFile(file1));    assertEquals(buffer, editorModel.getBufferForFile(file2));  }