[github-tests] Fix the Project leak: cleanup components on tearDown

This commit is contained in:
Kirill Likhodedov
2013-07-09 19:04:26 +04:00
parent ba7423bdbd
commit ed792bd8b1
4 changed files with 20 additions and 2 deletions
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class GitHttpAuthTestService extends GitHttpAuthService {
@NotNull private GitHttpAuthenticator myAuthenticator = new GitHttpAuthenticator() {
public static final GitHttpAuthenticator STUB_AUTHENTICATOR = new GitHttpAuthenticator() {
@NotNull
@Override
public String askPassword(@NotNull String url) {
@@ -52,6 +52,8 @@ public class GitHttpAuthTestService extends GitHttpAuthService {
}
};
@NotNull private GitHttpAuthenticator myAuthenticator = STUB_AUTHENTICATOR;
@NotNull
@Override
public GitHttpAuthenticator createAuthenticator(@NotNull Project project, @Nullable ModalityState state, @NotNull GitCommand command,
@@ -63,4 +65,8 @@ public class GitHttpAuthTestService extends GitHttpAuthService {
myAuthenticator = authenticator;
}
public void cleanup() {
myAuthenticator = STUB_AUTHENTICATOR;
}
}
@@ -53,4 +53,8 @@ public class TestDialogManager extends DialogManager {
myHandlers.put(dialogClass, handler);
}
public void cleanup() {
myHandlers.clear();
}
}
@@ -78,4 +78,7 @@ public class TestNotificator extends Notificator {
myLastNotification = createNotification(notificationGroup, title, message, type, listener);
}
public void cleanup() {
myLastNotification = null;
}
}
@@ -37,7 +37,6 @@ import git4idea.test.TestDialogManager;
import git4idea.test.TestNotificator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.GithubAuthData;
import org.jetbrains.plugins.github.GithubSettings;
import static org.junit.Assume.assumeNotNull;
@@ -63,6 +62,7 @@ public abstract class GithubTest extends UsefulTestCase {
@NotNull protected VirtualFile myProjectRoot;
@NotNull protected GitVcsSettings myGitSettings;
@NotNull protected GithubSettings myGitHubSettings;
@NotNull private GitHttpAuthTestService myHttpAuthService;
@NotNull protected TestDialogManager myDialogManager;
@NotNull protected TestNotificator myNotificator;
@@ -163,10 +163,15 @@ public abstract class GithubTest extends UsefulTestCase {
myDialogManager = (TestDialogManager)ServiceManager.getService(DialogManager.class);
myNotificator = (TestNotificator)ServiceManager.getService(myProject, Notificator.class);
myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class);
}
@Override
protected void tearDown() throws Exception {
myHttpAuthService.cleanup();
myDialogManager.cleanup();
myNotificator.cleanup();
myProjectFixture.tearDown();
super.tearDown();
}