diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRollbackTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRollbackTest.java index b237346cd3db..ef8d3336aa84 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRollbackTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRollbackTest.java @@ -1,6 +1,10 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.idea.svn; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.vcs.VcsConfiguration; @@ -12,6 +16,8 @@ import com.intellij.openapi.vcs.changes.SimpleContentRevision; import com.intellij.openapi.vcs.rollback.RollbackProgressListener; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.testFramework.RunAll; +import com.intellij.testFramework.TestLoggerFactory; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.Target; @@ -43,6 +49,8 @@ import static org.jetbrains.idea.svn.api.Revision.WORKING; import static org.junit.Assert.*; public class SvnRollbackTest extends SvnTestCase { + private Disposable testRootDisposable = null; + @Override @Before public void before() throws Exception { @@ -50,6 +58,22 @@ public class SvnRollbackTest extends SvnTestCase { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE); + + testRootDisposable = Disposer.newDisposable("SvnRollbackTest"); + TestLoggerFactory.enableDebugLogging(testRootDisposable, + "#com.intellij.openapi.vfs.newvfs.RefreshSession" + ); + } + + @Override + public void after() throws Exception { + RunAll.runAll( + () -> { + Disposer.dispose(testRootDisposable); + testRootDisposable = null; + }, + () -> super.after() + ); } @Test @@ -602,31 +626,31 @@ public class SvnRollbackTest extends SvnTestCase { assertTrue(copy.isEmpty()); } - private Change assertAdd(VirtualFile newDir) { - final Change change = changeListManager.getChange(newDir); - assertNotNull(change); - assertNull(change.getBeforeRevision()); - return change; + private Change assertAdd(VirtualFile file) { + return assertChangeFor(file, change -> change.getBeforeRevision() == null); } private Change assertDelete(FilePath fpSource) { - final Change change = changeListManager.getChange(fpSource); - assertNotNull(change); - assertNull(change.getAfterRevision()); - return change; + return assertChangeFor(fpSource, change -> change.getAfterRevision() == null); } - private Change assertMove(final VirtualFile file) { - final Change change = changeListManager.getChange(file); - assertNotNull(change); - assertTrue(change.isMoved()); - return change; + private Change assertMove(VirtualFile file) { + return assertChangeFor(file, change -> change.isMoved()); } - private Change assertRename(final VirtualFile file) { - final Change change = changeListManager.getChange(file); - assertNotNull(change); - assertTrue(change.isRenamed()); + private Change assertRename(VirtualFile file) { + return assertChangeFor(file, change -> change.isRenamed()); + } + + private Change assertChangeFor(VirtualFile file, Condition check) { + if (!file.isValid()) Logger.getInstance(SvnRollbackTest.class).warn("File is invalid: " + file); + return assertChangeFor(getFilePath(file), check); + } + + private Change assertChangeFor(final FilePath file, Condition check) { + Change change = changeListManager.getChange(file); + assertTrue(String.format("Wring change: %s\nAll changes: %s", change, changeListManager.getAllChanges()), + change != null && check.value(change)); return change; } }