當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.appendToFile方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.appendToFile方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.appendToFile方法的具體用法?Java FileUtil.appendToFile怎麽用?Java FileUtil.appendToFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.appendToFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
  super.setUp();
  cd(myRepository);
  File hgrc = new File(new File(myRepository.getPath(), ".hg"), "hgrc");
  FileUtil.appendToFile(hgrc, "[extensions]\n" +
                              "largefiles=!\n");
  mkdir(subDirName);
  cd(subDirName);
  touch(names[0], "f1");
  myRepository.refresh(false, true);
  hg("add " + names[0]);
  hg("commit -m a");

  for (int i = 1; i < names.length; ++i) {
    hg("mv " + names[i - 1] + " " + names[i]);
    myRepository.refresh(false, true);
    echo(names[i], "f" + i);
    hg("commit -m a ");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:HgHistoryTest.java

示例2: tcLog

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void tcLog(String message, String level) {
  try {
    if (level != null) message = level + ": " + message;
    FileUtil.appendToFile(reportFile(), message + "\n");
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:TeamCityLogger.java

示例3: setUpHgrc

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) throws IOException {
  cd(".hg");
  File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
  String pathToHgrc = "testData\\repo\\dot_hg";
  File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
  File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
  FileUtil.appendToFile(hgrc, FileUtil.loadFile(hgrcFile));
  assertTrue(hgrc.exists());
  repositoryRoot.refresh(false, true);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:HgPlatformTest.java

示例4: appendToHgrc

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
protected static void appendToHgrc(@NotNull VirtualFile repositoryRoot, @NotNull String text) throws IOException {
  cd(".hg");
  File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
  FileUtil.appendToFile(hgrc, text);
  assertTrue(hgrc.exists());
  repositoryRoot.refresh(false, true);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:HgPlatformTest.java

示例5: createFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private void createFile(String relPath, String content) throws IOException {
  File file = createFile(relPath);
  FileUtil.appendToFile(file, content);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:GitCrlfProblemsDetectorTest.java

示例6: editAppend

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void editAppend(String file, String content) throws IOException {
  FileUtil.appendToFile(new File(file), content);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:GitHistoryUtilsTest.java

示例7: testSavedAndReadUnix

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testSavedAndReadUnix() throws Exception {
  if (SystemInfo.isWindows) return;

  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

  final SVNException[] exception = new SVNException[1];
  final Boolean[] result = new Boolean[1];

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.copy(servers, oldServers);
  try {
    FileUtil.appendToFile(servers, "\nstore-plaintext-passwords=yes\n");

    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.save));

          commonScheme(url, false, null);
          Assert.assertEquals(3, listener.getCnt());
          //long start = System.currentTimeMillis();
          //waitListenerStep(start, listener, 3);

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          commonScheme(url, false, null);
          //start = System.currentTimeMillis();
          //waitListenerStep(start, listener, 4);
          Assert.assertEquals(4, listener.getCnt());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }

  Assert.assertTrue(result[0]);
  myTestInteraction.assertNothing();
  Assert.assertEquals(4, listener.getCnt());
  listener.assertForAwt();
  savedOnceListener.assertForAwt();

  savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);

  if (exception[0] != null) {
    throw exception[0];
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:63,代碼來源:SvnAuthenticationTest.java

示例8: testWhenAuthCredsNoInConfig

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenAuthCredsNoInConfig() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
  final String contents = FileUtil.loadFile(config);
  final String auth = "[auth]";
  final int idx = contents.indexOf(auth);
  Assert.assertTrue(idx != -1);
  final String newContents = contents.substring(0, idx + auth.length()) + "\nstore-auth-creds=no\n" + contents.substring(idx + auth.length());

  final File oldConfig = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.rename(config, oldConfig);
  try {
    config.createNewFile();
    FileUtil.appendToFile(config, newContents);

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));

          commonScheme(url, false, null);
          Assert.assertEquals(2, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          commonScheme(url, false, null);
          Assert.assertEquals(4, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
    Assert.assertEquals(4, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(config);
    FileUtil.rename(oldConfig, config);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:67,代碼來源:SvnAuthenticationTest.java

示例9: testWhenAuthCredsNoInServers

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenAuthCredsNoInServers() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");

  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.copy(servers, oldServers);
  try {
    FileUtil.appendToFile(servers, "\nstore-auth-creds=no\n");

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));

          commonScheme(url, false, null);
          Assert.assertEquals(2, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          commonScheme(url, false, null);
          Assert.assertEquals(4, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
    Assert.assertEquals(4, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:61,代碼來源:SvnAuthenticationTest.java

示例10: testWhenPassSaveNoInConfig

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenPassSaveNoInConfig() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
  final String contents = FileUtil.loadFile(config);
  final String auth = "[auth]";
  final int idx = contents.indexOf(auth);
  Assert.assertTrue(idx != -1);
  final String newContents = contents.substring(0, idx + auth.length()) + "\nstore-passwords=no\n" + contents.substring(idx + auth.length());

  final File oldConfig = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.rename(config, oldConfig);
  try {
    config.createNewFile();
    FileUtil.appendToFile(config, newContents);

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));

          commonScheme(url, false, null);
          Assert.assertEquals(3, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));
          commonScheme(url, false, null);
          Assert.assertEquals(6, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
    Assert.assertEquals(6, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(config);
    FileUtil.rename(oldConfig, config);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:69,代碼來源:SvnAuthenticationTest.java

示例11: testWhenPassSaveNoInServers

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenPassSaveNoInServers() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");

  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.copy(servers, oldServers);
  try {
    FileUtil.appendToFile(servers, "\nstore-passwords=no\n");

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));

          commonScheme(url, false, null);
          Assert.assertEquals(3, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));
          commonScheme(url, false, null);
          Assert.assertEquals(6, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
    Assert.assertEquals(6, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:63,代碼來源:SvnAuthenticationTest.java

示例12: testWhenPassSaveNoForGroup

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenPassSaveNoForGroup() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
  final String contents = FileUtil.loadFile(servers);
  final String groups = "[groups]";
  final int idx = contents.indexOf(groups);
  Assert.assertTrue(idx != -1);
  final String newContents = contents.substring(0, idx + groups.length()) + "\nsomegroup=some*\n" + contents.substring(idx + groups.length()) +
    "\n[somegroup]\nstore-passwords=no\n";

  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.rename(servers, oldServers);
  try {
    servers.createNewFile();
    FileUtil.appendToFile(servers, newContents);

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));

          commonScheme(url, false, null);
          Assert.assertEquals(3, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));
          commonScheme(url, false, null);
          Assert.assertEquals(6, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
    Assert.assertEquals(6, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:70,代碼來源:SvnAuthenticationTest.java

示例13: testWhenPassPhraseSaveNo

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenPassPhraseSaveNo() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");

  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.copy(servers, oldServers);
  try {
    FileUtil.appendToFile(servers, "\nstore-ssl-client-cert-pp=no\n");

    final SVNURL url = SVNURL.parseURIEncoded("https://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(new Runnable() {
      @Override
      public void run() {
        try {
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));

          commonScheme(url, false, null);
          Assert.assertEquals(3, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
          myTestInteraction.reset();
          savedOnceListener.assertForAwt();
          savedOnceListener.reset();

          SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.interactive, url, Type.request));
          listener.addStep(new Trinity<ProviderType, SVNURL, Type>(ProviderType.persistent, url, Type.without_pasword_save));
          commonScheme(url, false, null);
          Assert.assertEquals(6, listener.getCnt());
          Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
        }
        catch (SVNException e) {
          exception[0] = e;
        }
        result[0] = true;
      }
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
    Assert.assertEquals(6, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:63,代碼來源:SvnAuthenticationTest.java

示例14: testSavedAndReadUnix

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testSavedAndReadUnix() throws Exception {
  if (SystemInfo.isWindows) return;

  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

  final SVNException[] exception = new SVNException[1];
  final Boolean[] result = new Boolean[1];

  final File servers = new File(myConfiguration.getConfigurationDirectory(), "servers");
  final File oldServers = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.copy(servers, oldServers);
  try {
    FileUtil.appendToFile(servers, "\nstore-plaintext-passwords=yes\n");

    synchronousBackground(() -> {
      try {
        listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
        listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
        listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));

        commonScheme(url, false, null);
        Assert.assertEquals(3, listener.getCnt());
        //long start = System.currentTimeMillis();
        //waitListenerStep(start, listener, 3);

        SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
        listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
        commonScheme(url, false, null);
        //start = System.currentTimeMillis();
        //waitListenerStep(start, listener, 4);
        Assert.assertEquals(4, listener.getCnt());
      }
      catch (SVNException e) {
        exception[0] = e;
      }
      result[0] = true;
    });
  } finally {
    FileUtil.delete(servers);
    FileUtil.rename(oldServers, servers);
  }

  Assert.assertTrue(result[0]);
  myTestInteraction.assertNothing();
  Assert.assertEquals(4, listener.getCnt());
  listener.assertForAwt();
  savedOnceListener.assertForAwt();

  savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);

  if (exception[0] != null) {
    throw exception[0];
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:60,代碼來源:SvnAuthenticationTest.java

示例15: testWhenAuthCredsNoInConfig

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testWhenAuthCredsNoInConfig() throws Exception {
  final TestListener listener = new TestListener(mySynchObject);
  myAuthenticationManager.addListener(listener);
  final SavedOnceListener savedOnceListener = new SavedOnceListener();
  myAuthenticationManager.addListener(savedOnceListener);

  final File config = new File(myConfiguration.getConfigurationDirectory(), "config");
  final String contents = FileUtil.loadFile(config);
  final String auth = "[auth]";
  final int idx = contents.indexOf(auth);
  Assert.assertTrue(idx != -1);
  final String newContents = contents.substring(0, idx + auth.length()) + "\nstore-auth-creds=no\n" + contents.substring(idx + auth.length());

  final File oldConfig = new File(myConfiguration.getConfigurationDirectory(), "config_old");
  FileUtil.rename(config, oldConfig);
  try {
    config.createNewFile();
    FileUtil.appendToFile(config, newContents);

    final SVNURL url = SVNURL.parseURIEncoded("http://some.host.com/repo");

    final SVNException[] exception = new SVNException[1];
    final Boolean[] result = new Boolean[1];
    synchronousBackground(() -> {
      try {
        listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
        listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));

        commonScheme(url, false, null);
        Assert.assertEquals(2, listener.getCnt());
        Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
        myTestInteraction.reset();
        savedOnceListener.assertForAwt();
        savedOnceListener.reset();

        SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
        listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
        listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
        commonScheme(url, false, null);
        Assert.assertEquals(4, listener.getCnt());
        Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
      }
      catch (SVNException e) {
        exception[0] = e;
      }
      result[0] = true;
    });

    Assert.assertTrue(result[0]);
    Assert.assertEquals(1, myTestInteraction.getNumAuthWarn());
    Assert.assertEquals(4, listener.getCnt());
    listener.assertForAwt();
    savedOnceListener.assertForAwt();
    savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);

    if (exception[0] != null) {
      throw exception[0];
    }
  } finally {
    FileUtil.delete(config);
    FileUtil.rename(oldConfig, config);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:64,代碼來源:SvnAuthenticationTest.java


注:本文中的com.intellij.openapi.util.io.FileUtil.appendToFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。