Convert anonymous to lambda in [svn4idea-tests]

This commit is contained in:
Konstantin Kolosovsky
2017-03-07 14:11:04 +03:00
parent c5c04cd789
commit a1b0a3c62e
19 changed files with 929 additions and 1272 deletions
@@ -17,7 +17,10 @@ package org.jetbrains.idea;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.ide.startup.impl.StartupManagerImpl;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.application.PluginPathManager;
@@ -41,7 +44,6 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
import com.intellij.testFramework.fixtures.TempDirTestFixture;
import com.intellij.testFramework.vcs.AbstractJunitVcsTestCase;
@@ -53,7 +55,6 @@ import com.intellij.util.TimeoutUtil;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.io.ZipUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnApplicationSettings;
@@ -121,63 +122,60 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
myTestDataDir = property;
}
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
myRepoRoot = new File(myTempDirFixture.getTempDirPath(), "svnroot");
assert myRepoRoot.mkdir() || myRepoRoot.isDirectory() : myRepoRoot;
myRepoRoot = new File(myTempDirFixture.getTempDirPath(), "svnroot");
assert myRepoRoot.mkdir() || myRepoRoot.isDirectory() : myRepoRoot;
myPluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea"));
if (!myPluginRoot.isDirectory()) {
// try standalone mode
Class aClass = SvnTestCase.class;
String rootPath = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
myPluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile();
}
File svnBinDir = new File(myPluginRoot, getTestDataDir() + "/svn/bin");
File svnExecutable = null;
if (SystemInfo.isWindows) {
svnExecutable = new File(svnBinDir, "windows/svn.exe");
}
else if (SystemInfo.isLinux) {
svnExecutable = new File(svnBinDir, "linux/svn");
}
else if (SystemInfo.isMac) {
svnExecutable = new File(svnBinDir, "mac/svn");
}
assertTrue("No Subversion executable was found: " + svnExecutable + ", " + SystemInfo.OS_NAME,
svnExecutable != null && svnExecutable.canExecute());
myClientBinaryPath = svnExecutable.getParentFile();
myRunner = SystemInfo.isMac
? createClientRunner(Collections.singletonMap("DYLD_LIBRARY_PATH", myClientBinaryPath.getPath()))
: createClientRunner();
ZipUtil.extract(new File(myPluginRoot, getTestDataDir() + "/svn/newrepo.zip"), myRepoRoot, null);
myWcRoot = new File(myTempDirFixture.getTempDirPath(), myWcRootName);
assert myWcRoot.mkdir() || myWcRoot.isDirectory() : myWcRoot;
myRepoUrl = (SystemInfo.isWindows ? "file:///" : "file://") + FileUtil.toSystemIndependentName(myRepoRoot.getPath());
verify(runSvn("co", myRepoUrl, myWcRoot.getPath()));
initProject(myWcRoot, SvnTestCase.this.getTestName());
activateVCS(SvnVcs.VCS_NAME);
myGate = new MockChangeListManagerGate(ChangeListManager.getInstance(myProject));
((StartupManagerImpl) StartupManager.getInstance(myProject)).runPostStartupActivities();
refreshSvnMappingsSynchronously();
myPluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea"));
if (!myPluginRoot.isDirectory()) {
// try standalone mode
Class aClass = SvnTestCase.class;
String rootPath = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
myPluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile();
}
catch (Exception e) {
throw new RuntimeException(e);
File svnBinDir = new File(myPluginRoot, getTestDataDir() + "/svn/bin");
File svnExecutable = null;
if (SystemInfo.isWindows) {
svnExecutable = new File(svnBinDir, "windows/svn.exe");
}
else if (SystemInfo.isLinux) {
svnExecutable = new File(svnBinDir, "linux/svn");
}
else if (SystemInfo.isMac) {
svnExecutable = new File(svnBinDir, "mac/svn");
}
assertTrue("No Subversion executable was found: " + svnExecutable + ", " + SystemInfo.OS_NAME,
svnExecutable != null && svnExecutable.canExecute());
myClientBinaryPath = svnExecutable.getParentFile();
myRunner = SystemInfo.isMac
? createClientRunner(Collections.singletonMap("DYLD_LIBRARY_PATH", myClientBinaryPath.getPath()))
: createClientRunner();
ZipUtil.extract(new File(myPluginRoot, getTestDataDir() + "/svn/newrepo.zip"), myRepoRoot, null);
myWcRoot = new File(myTempDirFixture.getTempDirPath(), myWcRootName);
assert myWcRoot.mkdir() || myWcRoot.isDirectory() : myWcRoot;
myRepoUrl = (SystemInfo.isWindows ? "file:///" : "file://") + FileUtil.toSystemIndependentName(myRepoRoot.getPath());
verify(runSvn("co", myRepoUrl, myWcRoot.getPath()));
initProject(myWcRoot, SvnTestCase.this.getTestName());
activateVCS(SvnVcs.VCS_NAME);
myGate = new MockChangeListManagerGate(ChangeListManager.getInstance(myProject));
((StartupManagerImpl) StartupManager.getInstance(myProject)).runPostStartupActivities();
refreshSvnMappingsSynchronously();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
@@ -196,12 +194,7 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
}
final Semaphore semaphore = new Semaphore();
semaphore.down();
((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(new Runnable() {
@Override
public void run() {
semaphore.up();
}
});
((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(() -> semaphore.up());
semaphore.waitFor();
}
@@ -216,28 +209,25 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
public void tearDown() throws Exception {
((ChangeListManagerImpl) ChangeListManager.getInstance(myProject)).stopEveryThingIfInTestMode();
sleep(100);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
tearDownProject();
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
tearDownProject();
if (myWcRoot != null && myWcRoot.exists()) {
FileUtil.delete(myWcRoot);
}
if (myRepoRoot != null && myRepoRoot.exists()) {
FileUtil.delete(myRepoRoot);
}
if (myWcRoot != null && myWcRoot.exists()) {
FileUtil.delete(myWcRoot);
}
if (myRepoRoot != null && myRepoRoot.exists()) {
FileUtil.delete(myRepoRoot);
}
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
}
catch (Exception e) {
throw new RuntimeException(e);
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
}
@@ -269,16 +259,13 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
}
protected void undo() {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
final TestDialog oldTestDialog = Messages.setTestDialog(TestDialog.OK);
try {
UndoManager.getInstance(myProject).undo(null);
}
finally {
Messages.setTestDialog(oldTestDialog);
}
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
final TestDialog oldTestDialog = Messages.setTestDialog(TestDialog.OK);
try {
UndoManager.getInstance(myProject).undo(null);
}
finally {
Messages.setTestDialog(oldTestDialog);
}
});
}
@@ -485,15 +472,11 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
final CommonUpdateProjectAction action = new CommonUpdateProjectAction();
action.getTemplatePresentation().setText("1");
action.actionPerformed(new AnActionEvent(null,
new DataContext() {
@Nullable
@Override
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return project;
}
return null;
dataId -> {
if (CommonDataKeys.PROJECT.is(dataId)) {
return project;
}
return null;
}, "test", new Presentation(), ActionManager.getInstance(), 0));
final ChangeListManager clManager = ChangeListManager.getInstance(project);
@@ -511,29 +494,23 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
}
private void runStatusAcrossLocks(@Nullable File workingDir, final boolean sorted, final String... stdoutLines) throws IOException {
final Processor<ProcessOutput> primitiveVerifier = new Processor<ProcessOutput>() {
@Override
public boolean process(ProcessOutput output) {
if (sorted) {
verifySorted(output, stdoutLines); // will assert if err not empty
} else {
verify(output, stdoutLines); // will assert if err not empty
}
return false;
final Processor<ProcessOutput> primitiveVerifier = output -> {
if (sorted) {
verifySorted(output, stdoutLines); // will assert if err not empty
} else {
verify(output, stdoutLines); // will assert if err not empty
}
return false;
};
runAndVerifyAcrossLocks(workingDir, new String[]{"status"}, new Processor<ProcessOutput>() {
@Override
public boolean process(ProcessOutput output) {
final List<String> lines = output.getStdoutLines();
for (String line : lines) {
if (line.trim().startsWith("L")) {
return true; // i.e. continue tries
}
runAndVerifyAcrossLocks(workingDir, new String[]{"status"}, output -> {
final List<String> lines = output.getStdoutLines();
for (String line : lines) {
if (line.trim().startsWith("L")) {
return true; // i.e. continue tries
}
primitiveVerifier.process(output);
return false;
}
primitiveVerifier.process(output);
return false;
}, primitiveVerifier);
}
@@ -543,12 +520,9 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
}
private static Processor<ProcessOutput> createPrimitiveExitCodeVerifier() {
return new Processor<ProcessOutput>() {
@Override
public boolean process(ProcessOutput output) {
assertEquals(output.getStderr(), 0, output.getExitCode());
return false;
}
return output -> {
assertEquals(output.getStderr(), 0, output.getExitCode());
return false;
};
}
@@ -54,57 +54,51 @@ public class IgnoredFilesTest extends Svn17TestCase {
@Before
public void setUp() throws Exception {
super.setUp();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
myClientRoot = new File(myTempDirFixture.getTempDirPath(), "clientroot");
myClientRoot.mkdir();
myClientRoot = new File(myTempDirFixture.getTempDirPath(), "clientroot");
myClientRoot.mkdir();
initProject(myClientRoot, IgnoredFilesTest.this.getTestName());
initProject(myClientRoot, IgnoredFilesTest.this.getTestName());
((StartupManagerImpl)StartupManager.getInstance(myProject)).runPostStartupActivities();
((StartupManagerImpl)StartupManager.getInstance(myProject)).runPostStartupActivities();
myChangeListManager = ChangeListManager.getInstance(myProject);
myVcs = SvnVcs.getInstance(myProject);
myVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
myVcsManager.registerVcs(myVcs);
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
myChangeListManager = ChangeListManager.getInstance(myProject);
myVcs = SvnVcs.getInstance(myProject);
myVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
myVcsManager.registerVcs(myVcs);
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myLocalFileSystem = LocalFileSystem.getInstance();
}
catch (Exception e) {
throw new RuntimeException(e);
}
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myLocalFileSystem = LocalFileSystem.getInstance();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
}
@After
public void tearDown() throws Exception {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
myVcsManager.unregisterVcs(myVcs);
myVcsManager = null;
myVcs = null;
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
myVcsManager.unregisterVcs(myVcs);
myVcsManager = null;
myVcs = null;
tearDownProject();
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
FileUtil.delete(myClientRoot);
}
catch (Exception e) {
throw new RuntimeException(e);
tearDownProject();
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
FileUtil.delete(myClientRoot);
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
}
@@ -15,7 +15,10 @@
*/
package org.jetbrains.idea.svn;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
@@ -31,8 +34,6 @@ import com.intellij.openapi.vcs.update.CommonUpdateProjectAction;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import junit.framework.Assert;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import org.junit.Before;
import org.junit.Test;
@@ -77,12 +78,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -116,12 +114,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -132,15 +127,11 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final CommonUpdateProjectAction action = new CommonUpdateProjectAction();
action.getTemplatePresentation().setText("1");
action.actionPerformed(new AnActionEvent(null,
new DataContext() {
@Nullable
@Override
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
return null;
dataId -> {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
return null;
}, "test", new Presentation(), ActionManager.getInstance(), 0));
myChangeListManager.ensureUpToDate(false);
@@ -161,12 +152,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -179,15 +167,11 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final CommonUpdateProjectAction action = new CommonUpdateProjectAction();
action.getTemplatePresentation().setText("1");
action.actionPerformed(new AnActionEvent(null,
new DataContext() {
@Nullable
@Override
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
return null;
dataId -> {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
return null;
}, "test", new Presentation(), ActionManager.getInstance(), 0));
myChangeListManager.ensureUpToDate(false);
@@ -208,12 +192,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -243,12 +224,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -275,12 +253,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -303,12 +278,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -374,22 +346,16 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
// then annotate both
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), vf1);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(vf1, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(vf1, annotation);
});
listener.registerAnnotation(vf1, annotation);
final FileAnnotation annotation1 = createTestAnnotation(myVcs.getAnnotationProvider(), vf2);
annotation1.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed1 = true;
listener.unregisterAnnotation(vf1, annotation1);
}
annotation1.setCloser(() -> {
myIsClosed1 = true;
listener.unregisterAnnotation(vf1, annotation1);
});
listener.registerAnnotation(vf1, annotation1);
@@ -79,15 +79,12 @@ public class SvnAuthenticationTest extends PlatformTestCase {
@Override
protected void tearDown() throws Exception {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
SvnAuthenticationTest.super.tearDown();
}
catch (Exception e) {
throw new RuntimeException(e);
}
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
SvnAuthenticationTest.super.tearDown();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
@@ -175,31 +172,28 @@ public class SvnAuthenticationTest extends PlatformTestCase {
try {
FileUtil.appendToFile(servers, "\nstore-plaintext-passwords=yes\n");
synchronousBackground(new Runnable() {
@Override
public void run() {
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));
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);
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;
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);
@@ -245,35 +239,32 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
synchronousBackground(() -> {
try {
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
commonScheme(url, false, null);
//long start = System.currentTimeMillis();
//waitListenerStep(start, listener, 2);
Assert.assertEquals(2, listener.getCnt());
commonScheme(url, false, null);
//long start = System.currentTimeMillis();
//waitListenerStep(start, listener, 2);
Assert.assertEquals(2, listener.getCnt());
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
// cause is not cleared though
savedOnceListener.reset();
savedOnceListener.assertNotSaved(url, ISVNAuthenticationManager.PASSWORD);
// cause is not cleared though
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());
//start = System.currentTimeMillis();
//waitListenerStep(start, listener, 4);
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
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());
//start = System.currentTimeMillis();
//waitListenerStep(start, listener, 4);
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
@@ -311,32 +302,29 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
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();
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;
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]);
@@ -372,32 +360,29 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
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();
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;
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]);
@@ -439,34 +424,31 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
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.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(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;
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.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]);
@@ -502,34 +484,31 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
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.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(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;
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.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]);
@@ -572,34 +551,31 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
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.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumPasswordsWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(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;
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.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]);
@@ -635,34 +611,31 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
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.without_pasword_save));
commonScheme(url, false, null);
Assert.assertEquals(3, listener.getCnt());
Assert.assertEquals(1, myTestInteraction.getNumSSLWarn());
myTestInteraction.reset();
savedOnceListener.assertForAwt();
savedOnceListener.reset();
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(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;
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.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]);
@@ -695,61 +668,55 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));
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);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
clearAuthCache();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
clearAuthCache();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
myTestInteraction.setPlaintextAnswer(false);
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
myTestInteraction.setPlaintextAnswer(false);
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
savedOnceListener.reset();
myTestInteraction.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 9);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
savedOnceListener.reset();
myTestInteraction.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 9);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
@@ -784,36 +751,33 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.without_pasword_save));
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.without_pasword_save));
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
// actually password not saved, but save was called
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
// actually password not saved, but save was called
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.PASSWORD);
savedOnceListener.reset();
myTestInteraction.reset();
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.without_pasword_save));
commonScheme(url2, false, "anotherRealm");
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url2, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url2, Type.without_pasword_save));
commonScheme(url2, false, "anotherRealm");
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
@@ -844,62 +808,56 @@ public class SvnAuthenticationTest extends PlatformTestCase {
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.persistent, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.interactive, url, Type.request));
listener.addStep(new Trinity<>(ProviderType.persistent, url, Type.save));
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);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
savedOnceListener.reset();
myTestInteraction.reset();
commonScheme(url, false, null);
long start = System.currentTimeMillis();
waitListenerStep(start, listener, 3);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
savedOnceListener.assertSaved(url, ISVNAuthenticationManager.SSL);
savedOnceListener.reset();
myTestInteraction.reset();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
clearAuthCache();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
clearAuthCache();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
myTestInteraction.setSSLPlaintextAnswer(false);
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
myTestInteraction.setSSLPlaintextAnswer(false);
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 6);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
myTestInteraction.reset();
savedOnceListener.reset();
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
myTestInteraction.reset();
savedOnceListener.reset();
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 9);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
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.without_pasword_save));
commonScheme(url, false, null);
start = System.currentTimeMillis();
waitListenerStep(start, listener, 9);
Assert.assertEquals(1, myTestInteraction.getNumSSLPlaintextPrompt());
}
catch (SVNException e) {
exception[0] = e;
}
result[0] = true;
});
Assert.assertTrue(result[0]);
@@ -918,14 +876,11 @@ public class SvnAuthenticationTest extends PlatformTestCase {
private static void synchronousBackground(final Runnable runnable) throws InterruptedException {
final Semaphore semaphore = new Semaphore();
semaphore.down();
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
try {
runnable.run();
} finally {
semaphore.up();
}
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
runnable.run();
} finally {
semaphore.up();
}
});
semaphore.waitFor();
@@ -20,7 +20,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
import com.intellij.testFramework.vcs.FileBasedTest;
import com.intellij.util.ConcurrencyUtil;
import com.intellij.util.ThrowableConvertor;
import com.intellij.util.TimeoutUtil;
import com.intellij.util.concurrency.Semaphore;
import junit.framework.Assert;
@@ -31,7 +30,6 @@ import org.junit.Test;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.io.ISVNSession;
import org.tmatesoft.svn.core.io.SVNRepository;
import java.util.ArrayList;
import java.util.List;
@@ -75,45 +73,29 @@ public class SvnCachingRepositoryPoolTest extends FileBasedTest {
public void testCancel() throws Exception {
final SvnIdeaRepositoryPoolManager poolManager = new SvnIdeaRepositoryPoolManager(true, null, null, 1, 1);
final SVNURL url = SVNURL.parseURIEncoded("http://a.b.c");
poolManager.setCreator(new ThrowableConvertor<SVNURL, SVNRepository, SVNException>() {
@Override
public SVNRepository convert(SVNURL svnurl) throws SVNException {
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
}
});
poolManager.setCreator(svnurl -> new MockSvnRepository(svnurl, ISVNSession.DEFAULT));
final MockSvnRepository repository1 = (MockSvnRepository)poolManager.createRepository(url, true);
final Semaphore semaphore = new Semaphore();
semaphore.down();
poolManager.setCreator(new ThrowableConvertor<SVNURL, SVNRepository, SVNException>() {
@Override
public SVNRepository convert(SVNURL svnurl) throws SVNException {
semaphore.waitFor();
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
}
poolManager.setCreator(svnurl -> {
semaphore.waitFor();
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
});
final SVNException[] exc = new SVNException[1];
final Runnable target = new Runnable() {
@Override
public void run() {
try {
final MockSvnRepository repository = (MockSvnRepository)poolManager.createRepository(url, true);
repository.fireConnectionClosed();
}
catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
}
final Runnable target = () -> {
try {
final MockSvnRepository repository = (MockSvnRepository)poolManager.createRepository(url, true);
repository.fireConnectionClosed();
}
catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
}
};
final EmptyProgressIndicator indicator = new EmptyProgressIndicator();
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(target, indicator);
}
}, "svn cache repo");
Thread thread = new Thread(() -> ((ProgressManagerImpl)ProgressManager.getInstance()).executeProcessUnderProgress(target, indicator), "svn cache repo");
thread.start();
TimeoutUtil.sleep(10);
@@ -156,12 +138,7 @@ public class SvnCachingRepositoryPoolTest extends FileBasedTest {
}
private void testBigFlow(final SvnIdeaRepositoryPoolManager poolManager, boolean disposeAfter) throws SVNException, InterruptedException {
poolManager.setCreator(new ThrowableConvertor<SVNURL, SVNRepository, SVNException>() {
@Override
public SVNRepository convert(SVNURL svnurl) throws SVNException {
return new MockSvnRepository(svnurl, ISVNSession.DEFAULT);
}
});
poolManager.setCreator(svnurl -> new MockSvnRepository(svnurl, ISVNSession.DEFAULT));
final SVNURL url = SVNURL.parseURIEncoded("http://a.b.c");
final Random random = new Random(System.currentTimeMillis() & 0x00ff);
final int[] cnt = new int[1];
@@ -169,24 +146,21 @@ public class SvnCachingRepositoryPoolTest extends FileBasedTest {
final SVNException[] exc = new SVNException[1];
List<Thread> threads = new ArrayList<>();
for (int i = 0; i < 25; i++) {
Runnable target = new Runnable() {
@Override
public void run() {
MockSvnRepository repository = null;
try {
repository = (MockSvnRepository)poolManager.createRepository(url, true);
}
catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
return;
}
repository.fireConnectionOpened();
TimeoutUtil.sleep(random.nextInt(10));
repository.fireConnectionClosed();
synchronized (cnt) {
-- cnt[0];
}
Runnable target = () -> {
MockSvnRepository repository = null;
try {
repository = (MockSvnRepository)poolManager.createRepository(url, true);
}
catch (SVNException e) {
e.printStackTrace();
exc[0] = e;
return;
}
repository.fireConnectionOpened();
TimeoutUtil.sleep(random.nextInt(10));
repository.fireConnectionClosed();
synchronized (cnt) {
-- cnt[0];
}
};
Thread thread = new Thread(target, "svn cache");
@@ -16,16 +16,17 @@
package org.jetbrains.idea.svn;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.NullableFunction;
import com.intellij.vcsUtil.VcsUtil;
import junit.framework.Assert;
import org.jetbrains.annotations.Nullable;
import org.junit.Before;
import org.junit.Test;
@@ -444,14 +445,7 @@ public class SvnCommitTest extends Svn17TestCase {
changes.add(change);
}
final HashSet<String> feedback = new HashSet<>();
final List<VcsException> exceptions = myVcs.getCheckinEnvironment().commit(changes, "test comment list",
new NullableFunction<Object, Object>() {
@Nullable
@Override
public Object fun(Object o) {
return null;
}
}, feedback);
final List<VcsException> exceptions = myVcs.getCheckinEnvironment().commit(changes, "test comment list", o -> null, feedback);
if (exceptions !=null && ! exceptions.isEmpty()) {
exceptions.get(0).printStackTrace();
}
@@ -53,12 +53,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final String newName = "renamed";
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.editName(list.getName(), newName);
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
}
myScheme.doTest(() -> {
changeListManager.editName(list.getName(), newName);
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
@@ -80,15 +77,12 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
final Runnable check = new Runnable() {
@Override
public void run() {
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
}
final Runnable check = () -> {
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
};
// do before refresh check
check.run();
@@ -101,15 +95,12 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
final Runnable check2 = new Runnable() {
@Override
public void run() {
Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
}
final Runnable check2 = () -> {
Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
};
myScheme.doTest(check2);
@@ -130,19 +121,16 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final String finalText = "final text";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final String intermediate = "intermediate text";
changeListManager.editComment(list.getName(), intermediate);
assert changeListManager.findChangeList(listName) != null;
LocalChangeList list = changeListManager.findChangeList(listName);
assert intermediate.equals(list.getComment());
myScheme.doTest(() -> {
final String intermediate = "intermediate text";
changeListManager.editComment(list.getName(), intermediate);
assert changeListManager.findChangeList(listName) != null;
LocalChangeList list1 = changeListManager.findChangeList(listName);
assert intermediate.equals(list1.getComment());
changeListManager.editComment(list.getName(), finalText);
list = changeListManager.findChangeList(listName);
assert finalText.equals(list.getComment());
}
changeListManager.editComment(list1.getName(), finalText);
list1 = changeListManager.findChangeList(listName);
assert finalText.equals(list1.getComment());
});
LocalChangeList changedList = changeListManager.findChangeList(listName);
@@ -164,12 +152,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
@@ -189,12 +174,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.setDefaultChangeList(target);
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
}
myScheme.doTest(() -> {
changeListManager.setDefaultChangeList(target);
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
});
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
@@ -214,13 +196,10 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final LocalChangeList list = changeListManager.addChangeList("test", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.removeChangeList(list.getName());
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
}
myScheme.doTest(() -> {
changeListManager.removeChangeList(list.getName());
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
});
assert changeListManager.findChangeList(list.getName()) == null;
@@ -243,14 +222,11 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final LocalChangeList target2 = changeListManager.addChangeList("target2", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(target2, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(target2, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
@@ -270,14 +246,11 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
@@ -298,13 +271,10 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final String targetName = "target";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
}
myScheme.doTest(() -> {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
@@ -347,21 +317,18 @@ public class SvnConcurrentChangeListManagerTest extends Svn17TestCase {
final String targetName = "target";
final String finalName = "final list name";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)});
checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager);
changeListManager.editName(targetName, finalName);
checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager);
changeListManager.removeChangeList(toBeDeletedList.getName());
checkFilesAreInList(new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager);
changeListManager.moveChangesTo(LocalChangeList.createEmptyChangeList(myProject, finalName),
new Change[] {changeListManager.getChange(fileC)});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
}
myScheme.doTest(() -> {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)});
checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager);
changeListManager.editName(targetName, finalName);
checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager);
changeListManager.removeChangeList(toBeDeletedList.getName());
checkFilesAreInList(new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager);
changeListManager.moveChangesTo(LocalChangeList.createEmptyChangeList(myProject, finalName),
new Change[] {changeListManager.getChange(fileC)});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
@@ -178,13 +178,8 @@ public class SvnExternalTest extends Svn17TestCase {
}
private void setNewDirectoryMappings(final File sourceDir) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings(
Arrays.asList(new VcsDirectoryMapping(FileUtil.toSystemIndependentName(sourceDir.getPath()), myVcs.getName())));
}
});
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> ProjectLevelVcsManager.getInstance(myProject).setDirectoryMappings(
Arrays.asList(new VcsDirectoryMapping(FileUtil.toSystemIndependentName(sourceDir.getPath()), myVcs.getName()))));
}
@Test
@@ -25,8 +25,6 @@ import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Ignore;
import org.tmatesoft.sqljet.core.SqlJetException;
import org.tmatesoft.sqljet.core.table.ISqlJetBusyHandler;
import org.tmatesoft.sqljet.core.table.ISqlJetTransaction;
import org.tmatesoft.sqljet.core.table.SqlJetDb;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@@ -278,25 +276,22 @@ public class SvnLockingTest extends TestCase {
mySemaphore.down();
try {
System.out.println("starting read " + myName);
myLocks.wrapRead(myWorkingCopyRoot, new Runnable() {
@Override
public void run() {
System.out.println("inside read " + myName);
final SVNWCClient client = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
try {
client.doInfo(myWorkingCopyRoot, SVNRevision.BASE);
}
catch (SVNException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
myIsRunning.set(true);
System.out.println("got status " + myName);
if (myWaitFor) {
mySemaphore.waitFor();
}
System.out.println("have read " + myName);
myLocks.wrapRead(myWorkingCopyRoot, () -> {
System.out.println("inside read " + myName);
final SVNWCClient client = new SVNWCClient((ISVNRepositoryPool)null, new DefaultSVNOptions());
try {
client.doInfo(myWorkingCopyRoot, SVNRevision.BASE);
}
catch (SVNException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
myIsRunning.set(true);
System.out.println("got status " + myName);
if (myWaitFor) {
mySemaphore.waitFor();
}
System.out.println("have read " + myName);
});
}
catch (SVNException e) {
@@ -370,27 +365,21 @@ public class SvnLockingTest extends TestCase {
SqlJetDb open = null;
try {
open = SqlJetDb.open(SvnUtil.getWcDb(myWorkingCopyRoot), true);
open.setBusyHandler(new ISqlJetBusyHandler() {
@Override
public boolean call(int i) {
if (myStopped) return false;
System.out.println("busy " + myName);
TimeoutUtil.sleep(10);
return true;
}
});
open.setBusyHandler(i -> {
if (myStopped) return false;
System.out.println("busy " + myName);
TimeoutUtil.sleep(10);
return true;
});
try {
System.out.println("TRY OPEN FOR WRITE " + myName);
open.runWriteTransaction(new ISqlJetTransaction() {
@Override
public Object run(SqlJetDb db) throws SqlJetException {
System.out.println("OPENed FOR WRITE " + myName);
myInsideWrite.set(true);
if (shouldWait) {
mySemaphore.waitFor();
}
return null;
open.runWriteTransaction(db -> {
System.out.println("OPENed FOR WRITE " + myName);
myInsideWrite.set(true);
if (shouldWait) {
mySemaphore.waitFor();
}
return null;
});
} finally {
myInsideWrite.set(false);
@@ -21,13 +21,10 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
import com.intellij.openapi.vcs.update.SequentialUpdatesContext;
import com.intellij.openapi.vcs.update.UpdateSession;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Processor;
import com.intellij.util.containers.Convertor;
import com.intellij.vcsUtil.VcsUtil;
import junit.framework.Assert;
import org.jetbrains.annotations.NotNull;
@@ -36,7 +33,10 @@ import org.jetbrains.idea.svn.auth.SvnAuthenticationManager;
import org.jetbrains.idea.svn.auth.SvnAuthenticationNotifier;
import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider;
import org.junit.Before;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNErrorMessage;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.*;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNRevision;
@@ -111,31 +111,25 @@ public class SvnNativeClientAuthTest extends Svn17TestCase {
manager.setAuthenticationProvider(authentication);
authentication.addAuthentication(ISVNAuthenticationManager.PASSWORD,
new Convertor<SVNURL, SVNAuthentication>() {
@Override
public SVNAuthentication convert(SVNURL o) {
++ myCredentialsAskedInteractivelyCount;
if (myCancelAuth) return null;
if (myCredentialsCorrect) {
return new SVNPasswordAuthentication(outHttpUser, outHttpPassword, mySaveCredentials, o, false);
} else {
myCredentialsCorrect = true;// only once
return new SVNPasswordAuthentication("1234214 23 4234", "324324", mySaveCredentials, o, false);
}
o -> {
++ myCredentialsAskedInteractivelyCount;
if (myCancelAuth) return null;
if (myCredentialsCorrect) {
return new SVNPasswordAuthentication(outHttpUser, outHttpPassword, mySaveCredentials, o, false);
} else {
myCredentialsCorrect = true;// only once
return new SVNPasswordAuthentication("1234214 23 4234", "324324", mySaveCredentials, o, false);
}
});
authentication.addAuthentication(ISVNAuthenticationManager.SSL,
new Convertor<SVNURL, SVNAuthentication>() {
@Override
public SVNAuthentication convert(SVNURL o) {
++ myCredentialsAskedInteractivelyCount;
if (myCancelAuth) return null;
if (myCredentialsCorrect) {
return new SVNSSLAuthentication(certFile, "12345", mySaveCredentials, o, false);
} else {
myCredentialsCorrect = true;// only once
return new SVNSSLAuthentication(new File("1232432423"), "3245321532534235445", mySaveCredentials, o, false);
}
o -> {
++ myCredentialsAskedInteractivelyCount;
if (myCancelAuth) return null;
if (myCredentialsCorrect) {
return new SVNSSLAuthentication(certFile, "12345", mySaveCredentials, o, false);
} else {
myCredentialsCorrect = true;// only once
return new SVNSSLAuthentication(new File("1232432423"), "3245321532534235445", mySaveCredentials, o, false);
}
});
myCertificateAskedInteractivelyCount = 0;
@@ -557,12 +551,9 @@ public class SvnNativeClientAuthTest extends Svn17TestCase {
}, WorkingCopyFormat.ONE_DOT_SEVEN);
final int[] cnt = new int[1];
cnt[0] = 0;
FileUtil.processFilesRecursively(root, new Processor<File>() {
@Override
public boolean process(File file) {
++ cnt[0];
return ! (cnt[0] > 1);
}
FileUtil.processFilesRecursively(root, file -> {
++ cnt[0];
return ! (cnt[0] > 1);
});
Assert.assertTrue(cnt[0] > 1);
myIsSecure = url.contains("https:");
@@ -610,12 +601,7 @@ public class SvnNativeClientAuthTest extends Svn17TestCase {
private void testBrowseRepositoryImpl(final String url) throws SVNException {
final List<SVNDirEntry> list = new ArrayList<>();
final SVNRepository repository = myVcs.getSvnKitManager().createRepository(url);
repository.getDir(".", -1, null, new ISVNDirEntryHandler() {
@Override
public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
list.add(dirEntry);
}
});
repository.getDir(".", -1, null, dirEntry -> list.add(dirEntry));
Assert.assertTrue(!list.isEmpty());
}
@@ -19,17 +19,16 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.util.Consumer;
import com.intellij.util.containers.Convertor;
import com.intellij.util.containers.MultiMap;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.api.NodeKind;
import org.jetbrains.idea.svn.status.Status;
import org.jetbrains.idea.svn.info.Info;
import org.jetbrains.idea.svn.status.*;
import org.jetbrains.idea.svn.info.SvnInfoHandler;
import org.jetbrains.idea.svn.status.CmdStatusClient;
import org.jetbrains.idea.svn.status.PortableStatus;
import org.jetbrains.idea.svn.status.SvnStatusHandler;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.SVNRevision;
@@ -81,12 +80,7 @@ public class SvnParseCommandLineParseTest extends TestCase {
"</info>";
final Info[] info = new Info[1];
final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), new Consumer<Info>() {
@Override
public void consume(Info info1) {
info[0] = info1;
}
});
final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), info1 -> info[0] = info1);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new ByteArrayInputStream(s.getBytes(CharsetToolkit.UTF8_CHARSET)), handler);
@@ -570,33 +564,30 @@ public class SvnParseCommandLineParseTest extends TestCase {
@Override
public void switchChangeList(String newList) {
}
}, new File(basePath), new Convertor<File, Info>() {
@Override
public Info convert(File o) {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}, new File(basePath), o -> {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}
});
handlerArr[0] = handler;
@@ -667,33 +658,27 @@ public class SvnParseCommandLineParseTest extends TestCase {
final String basePath = "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main";
final SvnStatusHandler[] handler = new SvnStatusHandler[1];
final File baseFile = new File(basePath);
final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(new StatusConsumer() {
@Override
public void consume(Status status) throws SVNException {
System.out.println(status.getURL());
if (new File(
"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java")
.equals(status.getFile())) {
Assert.assertEquals("http://external/src/com/slave/MacMessagesParser.java", status.getURL().toString());
}
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java")
.equals(status.getFile())) {
Assert.assertEquals("http://external/src/com/slave/SomeOtherClass.java", status.getURL().toString());
}
final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(status1 -> {
System.out.println(status1.getURL());
if (new File(
"C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java")
.equals(status1.getFile())) {
Assert.assertEquals("http://external/src/com/slave/MacMessagesParser.java", status1.getURL().toString());
}
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\SomeOtherClass.java")
.equals(status1.getFile())) {
Assert.assertEquals("http://external/src/com/slave/SomeOtherClass.java", status1.getURL().toString());
}
}, baseFile, createStubInfo(basePath, "http://mainurl/"), handler);
handler[0] = new SvnStatusHandler(callback, baseFile, new Convertor<File, Info>() {
@Override
public Info convert(File o) {
try {
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) {
return createStubInfo(o.getPath(), "http://external");
}
return createStubInfo(o.getPath(), "http://12345");
}
catch (SVNException e) {
throw new RuntimeException(e);
handler[0] = new SvnStatusHandler(callback, baseFile, o -> {
try {
if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) {
return createStubInfo(o.getPath(), "http://external");
}
return createStubInfo(o.getPath(), "http://12345");
}
catch (SVNException e) {
throw new RuntimeException(e);
}
});
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
@@ -752,33 +737,30 @@ public class SvnParseCommandLineParseTest extends TestCase {
@Override
public void switchChangeList(String newList) {
}
}, new File(basePath), new Convertor<File, Info>() {
@Override
public Info convert(File o) {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}, new File(basePath), o -> {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}
});
handlerArr[0] = handler;
@@ -842,33 +824,30 @@ public class SvnParseCommandLineParseTest extends TestCase {
public void switchChangeList(String newList) {
clName[0] = newList;
}
}, new File(basePath), new Convertor<File, Info>() {
@Override
public Info convert(File o) {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}, new File(basePath), o -> {
try {
o.getCanonicalFile();
}
catch (IOException e) {
throw new RuntimeException(e);
}
if (isWindows) {
final int idx = o.getPath().indexOf(":");
Assert.assertTrue(idx > 0);
final int secondIdx = o.getPath().indexOf(":", idx + 1);
Assert.assertTrue(o.getPath(), secondIdx == -1);
} else {
if (o.getPath().contains(LINUX_ROOT)) {
Assert.assertFalse(o.getPath().contains(basePath));
}
}
try {
return createStubInfo(basePath + "1", "http://a.b.c");
}
catch (SVNException e) {
//
throw new RuntimeException(e);
}
});
handlerArr[0] = handler;
@@ -19,7 +19,10 @@ import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.CheckoutProvider;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsKey;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.CurrentContentRevision;
@@ -27,20 +30,19 @@ import com.intellij.openapi.vcs.history.VcsAppendableHistoryPartnerAdapter;
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
import com.intellij.openapi.vcs.update.FileGroup;
import com.intellij.openapi.vcs.update.SequentialUpdatesContext;
import com.intellij.openapi.vcs.update.UpdateSession;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Processor;
import com.intellij.util.containers.Convertor;
import com.intellij.vcsUtil.VcsUtil;
import junit.framework.Assert;
import org.jetbrains.idea.svn.api.Depth;
import org.jetbrains.idea.svn.auth.SvnAuthenticationManager;
import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider;
import org.junit.Before;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.*;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNRevision;
@@ -96,25 +98,10 @@ public class SvnProtocolsTest extends Svn17TestCase {
manager.setAuthenticationProvider(authentication);
authentication.addAuthentication(ISVNAuthenticationManager.SSH,
new Convertor<SVNURL, SVNAuthentication>() {
@Override
public SVNAuthentication convert(SVNURL o) {
return new SVNSSHAuthentication(SSH_USER_NAME, SSH_PASSWORD, SSH_PORT_NUMBER, true, o, false);
}
});
authentication.addAuthentication(ISVNAuthenticationManager.USERNAME, new Convertor<SVNURL, SVNAuthentication>() {
@Override
public SVNAuthentication convert(SVNURL o) {
return new SVNUserNameAuthentication(SSH_USER_NAME, true, o, false);
}
});
authentication.addAuthentication(ISVNAuthenticationManager.PASSWORD,
new Convertor<SVNURL, SVNAuthentication>() {
@Override
public SVNAuthentication convert(SVNURL o) {
return new SVNPasswordAuthentication("sally", "abcde", true, o, false);
}
});
o -> new SVNSSHAuthentication(SSH_USER_NAME, SSH_PASSWORD, SSH_PORT_NUMBER, true, o, false));
authentication.addAuthentication(ISVNAuthenticationManager.USERNAME, o -> new SVNUserNameAuthentication(SSH_USER_NAME, true, o, false));
authentication
.addAuthentication(ISVNAuthenticationManager.PASSWORD, o -> new SVNPasswordAuthentication("sally", "abcde", true, o, false));
}
@Test
@@ -128,12 +115,7 @@ public class SvnProtocolsTest extends Svn17TestCase {
private void testBrowseRepositoryImpl(final String url) throws SVNException {
final List<SVNDirEntry> list = new ArrayList<>();
final SVNRepository repository = myVcs.getSvnKitManager().createRepository(url);
repository.getDir(".", -1, null, new ISVNDirEntryHandler() {
@Override
public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
list.add(dirEntry);
}
});
repository.getDir(".", -1, null, dirEntry -> list.add(dirEntry));
Assert.assertTrue(! list.isEmpty());
}
@@ -235,12 +217,9 @@ public class SvnProtocolsTest extends Svn17TestCase {
}, WorkingCopyFormat.ONE_DOT_SEVEN);
final int[] cnt = new int[1];
cnt[0] = 0;
FileUtil.processFilesRecursively(root, new Processor<File>() {
@Override
public boolean process(File file) {
++ cnt[0];
return ! (cnt[0] > 1);
}
FileUtil.processFilesRecursively(root, file -> {
++ cnt[0];
return ! (cnt[0] > 1);
});
Assert.assertTrue(cnt[0] > 1);
return root;
@@ -110,18 +110,15 @@ public class SvnRenameTest extends Svn17TestCase {
refreshVfs(); // wait for end of refresh operations initiated from SvnFileSystemListener
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
insideInitializedChangeListManager(changeListManager, new Runnable() {
@Override
public void run() {
changeListManager.ensureUpToDate(false);
List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
Assert.assertEquals(4, changes.size());
sortChanges(changes);
verifyChange(changes.get(0), "child", "childnew");
verifyChange(changes.get(1), "child" + File.separatorChar + "a.txt", "childnew" + File.separatorChar + "a.txt");
verifyChange(changes.get(2), "child" + File.separatorChar + "grandChild", "childnew" + File.separatorChar + "grandChild");
verifyChange(changes.get(3), "child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "childnew" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
}
insideInitializedChangeListManager(changeListManager, () -> {
changeListManager.ensureUpToDate(false);
List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
Assert.assertEquals(4, changes.size());
sortChanges(changes);
verifyChange(changes.get(0), "child", "childnew");
verifyChange(changes.get(1), "child" + File.separatorChar + "a.txt", "childnew" + File.separatorChar + "a.txt");
verifyChange(changes.get(2), "child" + File.separatorChar + "grandChild", "childnew" + File.separatorChar + "grandChild");
verifyChange(changes.get(3), "child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "childnew" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt");
});
// there is no such directory any more
@@ -181,20 +178,17 @@ public class SvnRenameTest extends Svn17TestCase {
renameFileInCommand(child, "newchild");
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
insideInitializedChangeListManager(changeListManager, new Runnable() {
@Override
public void run() {
changeListManager.ensureUpToDate(false);
final Change change = changeListManager.getChange(myWorkingCopyDir.findChild("newchild"));
Assert.assertNotNull(change);
insideInitializedChangeListManager(changeListManager, () -> {
changeListManager.ensureUpToDate(false);
final Change change = changeListManager.getChange(myWorkingCopyDir.findChild("newchild"));
Assert.assertNotNull(change);
final List<VcsException> exceptions = new ArrayList<>();
SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(Collections.singletonList(change), exceptions,
RollbackProgressListener.EMPTY);
Assert.assertTrue(exceptions.isEmpty());
Assert.assertFalse(new File(myWorkingCopyDir.getPath(), "newchild").exists());
Assert.assertTrue(new File(myWorkingCopyDir.getPath(), "child").exists());
}
final List<VcsException> exceptions = new ArrayList<>();
SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(Collections.singletonList(change), exceptions,
RollbackProgressListener.EMPTY);
Assert.assertTrue(exceptions.isEmpty());
Assert.assertFalse(new File(myWorkingCopyDir.getPath(), "newchild").exists());
Assert.assertTrue(new File(myWorkingCopyDir.getPath(), "child").exists());
});
}
@@ -208,19 +202,16 @@ public class SvnRenameTest extends Svn17TestCase {
createFileInCommand(grandChild, "a.txt", "a");
checkin();
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
insideInitializedChangeListManager(changeListManager, new Runnable() {
@Override
public void run() {
moveFileInCommand(grandChild, myWorkingCopyDir);
refreshVfs(); // wait for end of refresh operations initiated from SvnFileSystemListener
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
Assert.assertEquals(listToString(changes), 2, changes.size());
sortChanges(changes);
verifyChange(changes.get(0), "child" + File.separatorChar + "grandChild", "grandChild");
verifyChange(changes.get(1), "child" + File.separatorChar + "grandChild" + File.separatorChar + "a.txt",
"grandChild" + File.separatorChar + "a.txt");
}
insideInitializedChangeListManager(changeListManager, () -> {
moveFileInCommand(grandChild, myWorkingCopyDir);
refreshVfs(); // wait for end of refresh operations initiated from SvnFileSystemListener
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
Assert.assertEquals(listToString(changes), 2, changes.size());
sortChanges(changes);
verifyChange(changes.get(0), "child" + File.separatorChar + "grandChild", "grandChild");
verifyChange(changes.get(1), "child" + File.separatorChar + "grandChild" + File.separatorChar + "a.txt",
"grandChild" + File.separatorChar + "a.txt");
});
}
@@ -241,37 +232,34 @@ public class SvnRenameTest extends Svn17TestCase {
createFileInCommand(unversionedDir, "c.txt", "c");
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
insideInitializedChangeListManager(changeListManager, new Runnable() {
@Override
public void run() {
changeListManager.ensureUpToDate(false);
Assert.assertEquals(FileStatus.UNKNOWN, changeListManager.getStatus(unversioned));
insideInitializedChangeListManager(changeListManager, () -> {
changeListManager.ensureUpToDate(false);
Assert.assertEquals(FileStatus.UNKNOWN, changeListManager.getStatus(unversioned));
renameFileInCommand(child, "newchild");
File childPath = new File(myWorkingCopyDir.getPath(), "child");
File newChildPath = new File(myWorkingCopyDir.getPath(), "newchild");
Assert.assertTrue(new File(newChildPath, "a.txt").exists());
Assert.assertTrue(new File(newChildPath, "u.txt").exists());
Assert.assertFalse(new File(childPath, "u.txt").exists());
renameFileInCommand(child, "newchild");
File childPath = new File(myWorkingCopyDir.getPath(), "child");
File newChildPath = new File(myWorkingCopyDir.getPath(), "newchild");
Assert.assertTrue(new File(newChildPath, "a.txt").exists());
Assert.assertTrue(new File(newChildPath, "u.txt").exists());
Assert.assertFalse(new File(childPath, "u.txt").exists());
refreshVfs();
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>();
changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild").findChild("a.txt")));
changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild")));
refreshVfs();
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>();
changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild").findChild("a.txt")));
changes.add(ChangeListManager.getInstance(myProject).getChange(myWorkingCopyDir.findChild("newchild")));
final List<VcsException> exceptions = new ArrayList<>();
SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(changes, exceptions, RollbackProgressListener.EMPTY);
TimeoutUtil.sleep(300);
Assert.assertTrue(exceptions.isEmpty());
final File fileA = new File(childPath, "a.txt");
Assert.assertTrue(fileA.getAbsolutePath(), fileA.exists());
final File fileU = new File(childPath, "u.txt");
Assert.assertTrue(fileU.getAbsolutePath(), fileU.exists());
final File unversionedDirFile = new File(childPath, "uc");
Assert.assertTrue(unversionedDirFile.exists());
Assert.assertTrue(new File(unversionedDirFile, "c.txt").exists());
}
final List<VcsException> exceptions = new ArrayList<>();
SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(changes, exceptions, RollbackProgressListener.EMPTY);
TimeoutUtil.sleep(300);
Assert.assertTrue(exceptions.isEmpty());
final File fileA = new File(childPath, "a.txt");
Assert.assertTrue(fileA.getAbsolutePath(), fileA.exists());
final File fileU = new File(childPath, "u.txt");
Assert.assertTrue(fileU.getAbsolutePath(), fileU.exists());
final File unversionedDirFile = new File(childPath, "uc");
Assert.assertTrue(unversionedDirFile.exists());
Assert.assertTrue(new File(unversionedDirFile, "c.txt").exists());
});
}
@@ -288,15 +276,12 @@ public class SvnRenameTest extends Svn17TestCase {
"D child", "D child" + File.separatorChar + "a.txt", "D child" + File.separatorChar + "grandChild", "D child" + File.separatorChar + "grandChild" + File.separatorChar + "b.txt", "D + newchild" + File.separatorChar + "a.txt");
final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
insideInitializedChangeListManager(changeListManager, new Runnable() {
@Override
public void run() {
refreshVfs(); // wait for end of refresh operations initiated from SvnFileSystemListener
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
final List<VcsException> list = SvnVcs.getInstance(myProject).getCheckinEnvironment().commit(changes, "test");
Assert.assertEquals(0, list.size());
}
insideInitializedChangeListManager(changeListManager, () -> {
refreshVfs(); // wait for end of refresh operations initiated from SvnFileSystemListener
changeListManager.ensureUpToDate(false);
final List<Change> changes = new ArrayList<>(changeListManager.getDefaultChangeList().getChanges());
final List<VcsException> list = SvnVcs.getInstance(myProject).getCheckinEnvironment().commit(changes, "test");
Assert.assertEquals(0, list.size());
});
}
@@ -17,14 +17,16 @@ package org.jetbrains.idea.svn;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vcs.changes.ChangeListManager;
import com.intellij.openapi.vcs.changes.ChangeListManagerImpl;
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Processor;
import com.intellij.vcsUtil.VcsUtil;
import junit.framework.Assert;
import org.jetbrains.idea.svn.info.Info;
@@ -84,12 +86,7 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase {
return withSvn || ! SvnUtil.isAdminDirectory(o);
}
});*/
clearDirInCommand(myWorkingCopyDir, new Processor<VirtualFile>() {
@Override
public boolean process(VirtualFile file) {
return withSvn || ! SvnUtil.isAdminDirectory(file);
}
});
clearDirInCommand(myWorkingCopyDir, file -> withSvn || ! SvnUtil.isAdminDirectory(file));
myWorkingCopyDir.refresh(false, true);
}
@@ -257,40 +254,37 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase {
myTheirs.refresh(false, true);
myWorkingCopyDir.refresh(false, true);
VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, new Processor<VirtualFile>() {
@Override
public boolean process(VirtualFile file) {
final String relative = VfsUtil.getRelativePath(file, myTheirs, File.separatorChar);
File workingFile = new File(myWorkingCopyDir.getPath(), relative);
boolean exists = workingFile.exists();
if (! exists) {
String[] excluded = data.getExcludeFromToTheirsCheck();
if (excluded != null && Arrays.asList(excluded).contains(relative)) {
return true;
}
Assert.assertTrue("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath(),
exists);
VfsUtil.processFileRecursivelyWithoutIgnored(myTheirs, file -> {
final String relative = VfsUtil.getRelativePath(file, myTheirs, File.separatorChar);
File workingFile = new File(myWorkingCopyDir.getPath(), relative);
boolean exists = workingFile.exists();
if (! exists) {
String[] excluded = data.getExcludeFromToTheirsCheck();
if (excluded != null && Arrays.asList(excluded).contains(relative)) {
return true;
}
final File theirsFile = new File(file.getPath());
Info theirsInfo = myVcs.getInfo(theirsFile);
Info thisInfo = myVcs.getInfo(workingFile);
if (theirsInfo != null) {
Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() +
", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(),
theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber());
if (! theirsFile.isDirectory()){
try {
final String workText = FileUtil.loadFile(workingFile);
final String theirsText = FileUtil.loadFile(theirsFile);
Assert.assertEquals(theirsText, workText);
}
catch (IOException e) {
Assert.assertTrue(e.getMessage(), false);
}
}
}
return true;
Assert.assertTrue("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath(),
exists);
}
final File theirsFile = new File(file.getPath());
Info theirsInfo = myVcs.getInfo(theirsFile);
Info thisInfo = myVcs.getInfo(workingFile);
if (theirsInfo != null) {
Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() +
", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(),
theirsInfo.getRevision().getNumber(), thisInfo.getRevision().getNumber());
if (! theirsFile.isDirectory()){
try {
final String workText = FileUtil.loadFile(workingFile);
final String theirsText = FileUtil.loadFile(theirsFile);
Assert.assertEquals(theirsText, workText);
}
catch (IOException e) {
Assert.assertTrue(e.getMessage(), false);
}
}
}
return true;
});
++ cnt;
}
@@ -31,7 +31,6 @@ import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNPropertyValue;
import org.tmatesoft.svn.core.wc.ISVNPropertyValueProvider;
import org.tmatesoft.svn.core.wc.SVNPropertyData;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCClient;
@@ -310,13 +309,10 @@ public class SvnRollbackTest extends Svn17TestCase {
private void setProperty(final File file, final String name, final String value) throws SVNException {
final SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
client.doSetProperty(file, new ISVNPropertyValueProvider() {
@Override
public SVNProperties providePropertyValues(File path, SVNProperties properties) throws SVNException {
final SVNProperties result = new SVNProperties();
result.put(name, SVNPropertyValue.create(value));
return result;
}
client.doSetProperty(file, (path, properties) -> {
final SVNProperties result = new SVNProperties();
result.put(name, SVNPropertyValue.create(value));
return result;
}, true, SVNDepth.EMPTY, null, null);
}
@@ -52,57 +52,51 @@ public class IgnoredFilesTest extends Svn16TestCase {
@Before
public void setUp() throws Exception {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
myTempDirFixture = fixtureFactory.createTempDirTestFixture();
myTempDirFixture.setUp();
myClientRoot = new File(myTempDirFixture.getTempDirPath(), "clientroot");
myClientRoot.mkdir();
myClientRoot = new File(myTempDirFixture.getTempDirPath(), "clientroot");
myClientRoot.mkdir();
initProject(myClientRoot, IgnoredFilesTest.this.getTestName());
initProject(myClientRoot, IgnoredFilesTest.this.getTestName());
((StartupManagerImpl)StartupManager.getInstance(myProject)).runPostStartupActivities();
((StartupManagerImpl)StartupManager.getInstance(myProject)).runPostStartupActivities();
myChangeListManager = ChangeListManager.getInstance(myProject);
myVcs = SvnVcs.getInstance(myProject);
myVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
myVcsManager.registerVcs(myVcs);
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
myChangeListManager = ChangeListManager.getInstance(myProject);
myVcs = SvnVcs.getInstance(myProject);
myVcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(myProject);
myVcsManager.registerVcs(myVcs);
myVcsManager.setDirectoryMapping(myWorkingCopyDir.getPath(), myVcs.getName());
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myLocalFileSystem = LocalFileSystem.getInstance();
}
catch (Exception e) {
throw new RuntimeException(e);
}
myVcsDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
myLocalFileSystem = LocalFileSystem.getInstance();
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
}
@After
public void tearDown() throws Exception {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
myVcsManager.unregisterVcs(myVcs);
myVcsManager = null;
myVcs = null;
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
try {
myVcsManager.unregisterVcs(myVcs);
myVcsManager = null;
myVcs = null;
tearDownProject();
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
FileUtil.delete(myClientRoot);
}
catch (Exception e) {
throw new RuntimeException(e);
tearDownProject();
if (myTempDirFixture != null) {
myTempDirFixture.tearDown();
myTempDirFixture = null;
}
FileUtil.delete(myClientRoot);
}
catch (Exception e) {
throw new RuntimeException(e);
}
});
}
@@ -76,12 +76,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -115,12 +112,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -143,12 +137,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -173,12 +164,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -208,12 +196,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -240,12 +225,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
@@ -268,12 +250,9 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), tree.myS1File);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(tree.myS1File, annotation);
});
listener.registerAnnotation(tree.myS1File, annotation);
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, "1+\n2\n3\n4\n");
@@ -339,22 +318,16 @@ public class SvnAnnotationIsClosedTest extends Svn17TestCase {
// then annotate both
final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(myProject).getAnnotationLocalChangesListener();
final FileAnnotation annotation = createTestAnnotation(myVcs.getAnnotationProvider(), vf1);
annotation.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed = true;
listener.unregisterAnnotation(vf1, annotation);
}
annotation.setCloser(() -> {
myIsClosed = true;
listener.unregisterAnnotation(vf1, annotation);
});
listener.registerAnnotation(vf1, annotation);
final FileAnnotation annotation1 = createTestAnnotation(myVcs.getAnnotationProvider(), vf2);
annotation1.setCloser(new Runnable() {
@Override
public void run() {
myIsClosed1 = true;
listener.unregisterAnnotation(vf1, annotation1);
}
annotation1.setCloser(() -> {
myIsClosed1 = true;
listener.unregisterAnnotation(vf1, annotation1);
});
listener.registerAnnotation(vf1, annotation1);
@@ -53,12 +53,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final String newName = "renamed";
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.editName(list.getName(), newName);
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
}
myScheme.doTest(() -> {
changeListManager.editName(list.getName(), newName);
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, newName, changeListManager);
@@ -80,15 +77,12 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
final Runnable check = new Runnable() {
@Override
public void run() {
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
}
final Runnable check = () -> {
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
};
myScheme.doTest(check);
@@ -99,15 +93,12 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
final Runnable check2 = new Runnable() {
@Override
public void run() {
Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
}
final Runnable check2 = () -> {
Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
};
myScheme.doTest(check2);
@@ -128,19 +119,16 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final String finalText = "final text";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final String intermediate = "intermediate text";
changeListManager.editComment(list.getName(), intermediate);
assert changeListManager.findChangeList(listName) != null;
LocalChangeList list = changeListManager.findChangeList(listName);
assert intermediate.equals(list.getComment());
myScheme.doTest(() -> {
final String intermediate = "intermediate text";
changeListManager.editComment(list.getName(), intermediate);
assert changeListManager.findChangeList(listName) != null;
LocalChangeList list1 = changeListManager.findChangeList(listName);
assert intermediate.equals(list1.getComment());
changeListManager.editComment(list.getName(), finalText);
list = changeListManager.findChangeList(listName);
assert finalText.equals(list.getComment());
}
changeListManager.editComment(list1.getName(), finalText);
list1 = changeListManager.findChangeList(listName);
assert finalText.equals(list1.getComment());
});
LocalChangeList changedList = changeListManager.findChangeList(listName);
@@ -162,12 +150,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
@@ -187,12 +172,9 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.setDefaultChangeList(target);
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
}
myScheme.doTest(() -> {
changeListManager.setDefaultChangeList(target);
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
});
assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
@@ -212,13 +194,10 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final LocalChangeList list = changeListManager.addChangeList("test", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.removeChangeList(list.getName());
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
}
myScheme.doTest(() -> {
changeListManager.removeChangeList(list.getName());
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
});
assert changeListManager.findChangeList(list.getName()) == null;
@@ -241,14 +220,11 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final LocalChangeList target2 = changeListManager.addChangeList("target2", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(target2, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(target2, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
@@ -268,14 +244,11 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final LocalChangeList target = changeListManager.addChangeList("target", null);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
myScheme.doTest(new Runnable() {
@Override
public void run() {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
}
myScheme.doTest(() -> {
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, list.getName(), changeListManager);
@@ -296,13 +269,10 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final String targetName = "target";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
}
myScheme.doTest(() -> {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file)});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
@@ -345,21 +315,18 @@ public class SvnConcurrentChangeListManagerTest extends Svn16TestCase {
final String targetName = "target";
final String finalName = "final list name";
myScheme.doTest(new Runnable() {
@Override
public void run() {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)});
checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager);
changeListManager.editName(targetName, finalName);
checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager);
changeListManager.removeChangeList(toBeDeletedList.getName());
checkFilesAreInList(new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager);
changeListManager.moveChangesTo(LocalChangeList.createEmptyChangeList(myProject, finalName),
new Change[] {changeListManager.getChange(fileC)});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
}
myScheme.doTest(() -> {
final LocalChangeList target = changeListManager.addChangeList(targetName, null);
changeListManager.moveChangesTo(target, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)});
checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager);
changeListManager.editName(targetName, finalName);
checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager);
changeListManager.removeChangeList(toBeDeletedList.getName());
checkFilesAreInList(new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager);
changeListManager.moveChangesTo(LocalChangeList.createEmptyChangeList(myProject, finalName),
new Change[] {changeListManager.getChange(fileC)});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
});
checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
@@ -33,7 +33,6 @@ import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNPropertyValue;
import org.tmatesoft.svn.core.wc.ISVNPropertyValueProvider;
import org.tmatesoft.svn.core.wc.SVNPropertyData;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCClient;
@@ -312,13 +311,10 @@ public class SvnRollbackTest extends Svn17TestCase {
private void setProperty(final File file, final String name, final String value) throws SVNException {
final SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
client.doSetProperty(file, new ISVNPropertyValueProvider() {
@Override
public SVNProperties providePropertyValues(File path, SVNProperties properties) throws SVNException {
final SVNProperties result = new SVNProperties();
result.put(name, SVNPropertyValue.create(value));
return result;
}
client.doSetProperty(file, (path, properties) -> {
final SVNProperties result = new SVNProperties();
result.put(name, SVNPropertyValue.create(value));
return result;
}, true, SVNDepth.EMPTY, null, null);
}