From 1cf183d1bf4d31fd1123fb1f6a487e50fb29c0b4 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 1 Jul 2013 17:23:20 +0400 Subject: [PATCH] Enable the BuiltInServer for tests It is needed for Git tests. For Cucumber tests we could stay with the previous implementation, since they are run after all other tests on our build server; but it is not acceptable for JUnits. The alternative to start/stop before/after each test is also unacceptable slow down. Remove the test startup instruction from GitCucumberWorld. Move default server port setting to a utility function. --- .../src/org/jetbrains/ide/BuiltInServerManagerImpl.java | 2 +- .../git4idea/test-stepdefs/git4idea/GitCucumberWorld.java | 6 +----- .../git4idea/testFramework/git4idea/test/GitTestUtil.java | 4 ++++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java b/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java index 79a68995f4f6..63e9919ea309 100644 --- a/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java +++ b/platform/platform-impl/src/org/jetbrains/ide/BuiltInServerManagerImpl.java @@ -37,7 +37,7 @@ public class BuiltInServerManagerImpl extends BuiltInServerManager { @Nullable private BuiltInServer server; - private boolean myEnabledInUnitTestMode; + private boolean myEnabledInUnitTestMode = true; @Override public int getPort() { diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java index 0d42bf81b385..c7932f216529 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java @@ -31,8 +31,6 @@ import git4idea.test.GitExecutor; import git4idea.test.GitTestUtil; import git4idea.test.TestNotificator; import org.jetbrains.annotations.NotNull; -import org.jetbrains.ide.BuiltInServerManager; -import org.jetbrains.ide.BuiltInServerManagerImpl; import org.junit.Assert; import org.picocontainer.MutablePicoContainer; @@ -139,9 +137,8 @@ public class GitCucumberWorld { @Before("@remote") @Order(1) public void setUpRemoteOperations() { - ((BuiltInServerManagerImpl)BuiltInServerManager.getInstance()).setEnabledInUnitTestMode(true); // default port will be occupied by main idea instance => define the custom default to avoid searching of free port - System.setProperty(BuiltInServerManagerImpl.PROPERTY_RPC_PORT, "64463"); + GitTestUtil.setDefaultBuiltInServerPort(); myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class); } @@ -156,7 +153,6 @@ public class GitCucumberWorld { @After("@remote") @Order(1) public void tearDownRemoteOperations() { - ((BuiltInServerManagerImpl)BuiltInServerManager.getInstance()).setEnabledInUnitTestMode(false); } @After diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java b/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java index 3c9b3f5ef51d..cdfc44bd7608 100644 --- a/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java +++ b/plugins/git4idea/testFramework/git4idea/test/GitTestUtil.java @@ -29,6 +29,7 @@ import git4idea.repo.GitRepository; import junit.framework.Assert; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.ide.BuiltInServerManagerImpl; import java.io.File; import java.util.HashMap; @@ -127,4 +128,7 @@ public class GitTestUtil { Assert.assertEquals("Notification has wrong content", expected.getContent(), actualNotification.getContent()); } + public static void setDefaultBuiltInServerPort() { + System.setProperty(BuiltInServerManagerImpl.PROPERTY_RPC_PORT, "64463"); + } }