diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java index 7fab69127663..9094d244ae80 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/generation/surroundWith/JavaSurroundWithTest.java @@ -113,18 +113,23 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase { } private void doTestWithTemplateFinish(@NotNull String fileName, final Surrounder surrounder, @Nullable String textToType) - throws Exception - { - ((TemplateManagerImpl)TemplateManager.getInstance(getProject())).setTemplateTesting(true); - configureByFile(BASE_PATH + fileName + ".java"); - SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder); - if (textToType != null) { - type(textToType); + throws Exception { + final TemplateManagerImpl templateManager = (TemplateManagerImpl)TemplateManager.getInstance(getProject()); + try { + templateManager.setTemplateTesting(true); + configureByFile(BASE_PATH + fileName + ".java"); + SurroundWithHandler.invoke(getProject(), getEditor(), getFile(), surrounder); + if (textToType != null) { + type(textToType); + } + TemplateState templateState = TemplateManagerImpl.getTemplateState(getEditor()); + assertNotNull(templateState); + templateState.nextTab(); + checkResultByFile(BASE_PATH + fileName + "_after.java"); + } + finally { + templateManager.setTemplateTesting(false); } - TemplateState templateState = TemplateManagerImpl.getTemplateState(getEditor()); - assertNotNull(templateState); - templateState.nextTab(); - checkResultByFile(BASE_PATH + fileName + "_after.java"); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/command/impl/StartMarkAction.java b/platform/platform-impl/src/com/intellij/openapi/command/impl/StartMarkAction.java index f3066440f3e7..865830252097 100644 --- a/platform/platform-impl/src/com/intellij/openapi/command/impl/StartMarkAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/command/impl/StartMarkAction.java @@ -22,6 +22,7 @@ import com.intellij.openapi.command.undo.UndoManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.TestOnly; /** * User: anna @@ -61,6 +62,16 @@ public class StartMarkAction extends BasicUndoableAction { myCommandName = commandName; } + @TestOnly + public static void checkCleared() { + try { + assert ourCurrentMark == null; + } + finally { + ourCurrentMark = null; + } + } + public static StartMarkAction start(Editor editor, Project project, String commandName) throws AlreadyStartedException { if (ourCurrentMark != null) { throw new AlreadyStartedException(ourCurrentMark.myCommandName, diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index 8c8358a7e851..6fa989698730 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -22,6 +22,7 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.command.impl.StartMarkAction; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Disposer; @@ -190,6 +191,7 @@ public abstract class UsefulTestCase extends TestCase { myOldCodeStyleSettings = null; VariableInplaceRenamer.checkCleared(); + StartMarkAction.checkCleared(); } protected void storeSettings() {