当前位置: 首页>>代码示例>>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;未经允许,请勿转载。