From 6061bb407f2596038628222018317847585f2662 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 13 May 2015 13:51:38 +0200 Subject: [PATCH] autodetect platform prefix in all tests; mark the manual initialization methods as deprecated; remove some of the usages --- .../com/intellij/testFramework/IdeaTestCase.java | 5 ++++- .../testFramework/LightCodeInsightTestCase.java | 7 +------ .../intellij/testFramework/LightIdeaTestCase.java | 8 +------- .../fixtures/LightCodeInsightFixtureTestCase.java | 3 +-- .../impl/ModuleRunConfigurationManagerTest.java | 4 +--- .../com/intellij/openapi/editor/FoldingTest.java | 7 +------ .../openapi/fileTypes/impl/FileTypesTest.java | 8 +------- .../src/com/intellij/idea/IdeaTestApplication.java | 4 +++- .../testFramework/LightPlatformLangTestCase.java | 4 ++-- .../intellij/testFramework/PlatformTestCase.java | 13 ++++++++++++- .../inspection/SpellcheckerInspectionTestCase.java | 8 +------- 11 files changed, 28 insertions(+), 43 deletions(-) diff --git a/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java b/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java index 93e357cbe0df..9826066cbf43 100644 --- a/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/IdeaTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,9 @@ public abstract class IdeaTestCase extends PlatformTestCase { return StdModuleTypes.JAVA; } + /** + * @deprecated calling this method is no longer necessary + */ public static void initPlatformPrefix() { initPlatformPrefix("com.intellij.idea.IdeaUltimateApplication", "Idea"); } diff --git a/java/testFramework/src/com/intellij/testFramework/LightCodeInsightTestCase.java b/java/testFramework/src/com/intellij/testFramework/LightCodeInsightTestCase.java index e8f5a58be318..79cb377415bc 100644 --- a/java/testFramework/src/com/intellij/testFramework/LightCodeInsightTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/LightCodeInsightTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,6 @@ import com.intellij.psi.impl.JavaPsiFacadeEx; * A TestCase for single PsiFile being opened in Editor conversion. See configureXXX and checkResultXXX method docs. */ public abstract class LightCodeInsightTestCase extends LightPlatformCodeInsightTestCase { - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - protected LightCodeInsightTestCase() { - IdeaTestCase.initPlatformPrefix(); - } - public static JavaPsiFacadeEx getJavaFacade() { return JavaPsiFacadeEx.getInstanceEx(ourProject); } diff --git a/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java b/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java index 8da3a59bca32..41fb94afccbf 100644 --- a/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/LightIdeaTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.testFramework; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.StdModuleTypes; import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.psi.impl.JavaPsiFacadeEx; /** @@ -31,11 +30,6 @@ import com.intellij.psi.impl.JavaPsiFacadeEx; * so it contains classes that is really needed in order to speed up tests startup. */ public abstract class LightIdeaTestCase extends LightPlatformTestCase { - @SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"}) - public LightIdeaTestCase() { - IdeaTestCase.initPlatformPrefix(); - } - public static JavaPsiFacadeEx getJavaFacade() { return JavaPsiFacadeEx.getInstanceEx(ourProject); } diff --git a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java index f3a39371ac13..6232d953a7d7 100644 --- a/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/fixtures/LightCodeInsightFixtureTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,6 @@ public abstract class LightCodeInsightFixtureTestCase extends UsefulTestCase{ @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") protected LightCodeInsightFixtureTestCase() { - IdeaTestCase.initPlatformPrefix(); } @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") diff --git a/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java index 25f64eb7aa3e..7b3218210b62 100644 --- a/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java +++ b/platform/lang-impl/testSources/com/intellij/execution/impl/ModuleRunConfigurationManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.project.Project; import com.intellij.testFramework.LightPlatformTestCase; -import com.intellij.testFramework.PlatformTestCase; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; @@ -53,7 +52,6 @@ public class ModuleRunConfigurationManagerTest extends LightPlatformTestCase { @Override public void setUp() throws Exception { - PlatformTestCase.initPlatformLangPrefix(); super.setUp(); myModule = context.mock(Module.class, "myModule"); context.checking(new Expectations() {{ diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/FoldingTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/FoldingTest.java index a587049a9522..b963a84fcba7 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/FoldingTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/FoldingTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.intellij.openapi.editor; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.ex.FoldingModelEx; import com.intellij.openapi.editor.impl.AbstractEditorTest; -import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.TestFileType; import static org.junit.Assert.assertArrayEquals; @@ -27,10 +26,6 @@ import static org.junit.Assert.assertArrayEquals; * @author max */ public class FoldingTest extends AbstractEditorTest { - static { - PlatformTestCase.autodetectPlatformPrefix(); - } - private FoldingModelEx myModel; @Override diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java index 4d8c43bb847f..46037ebed8b3 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileTypes/impl/FileTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,6 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; -import com.intellij.testFramework.IdeaTestCase; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.PlatformTestUtil; import com.intellij.util.PatternUtil; @@ -62,11 +61,6 @@ public class FileTypesTest extends PlatformTestCase { private FileTypeManagerImpl myFileTypeManager; private String myOldIgnoredFilesList; - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - public FileTypesTest() { - IdeaTestCase.initPlatformPrefix(); - } - @Override protected void setUp() throws Exception { super.setUp(); diff --git a/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java b/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java index 182279f2dfa0..0b3a954b4d8f 100644 --- a/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java +++ b/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.util.Disposer; +import com.intellij.testFramework.PlatformTestCase; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,6 +48,7 @@ public class IdeaTestApplication extends CommandLineApplication implements Dispo public static synchronized IdeaTestApplication getInstance(@Nullable final String configPath) { if (ourInstance == null) { + PlatformTestCase.doAutodetectPlatformPrefix(); new IdeaTestApplication(); PluginManagerCore.getPlugins(); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformLangTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformLangTestCase.java index aa070a93137d..e74eb9482ee3 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformLangTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformLangTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,6 @@ package com.intellij.testFramework; public abstract class LightPlatformLangTestCase extends LightPlatformTestCase { @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") protected LightPlatformLangTestCase() { - PlatformTestCase.initPlatformLangPrefix(); + PlatformTestCase.autodetectPlatformPrefix(); } } diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java index 670bcfd7bd43..a1dd7ab93069 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java @@ -151,9 +151,16 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro private static final String[] PREFIX_CANDIDATES = { "AppCode", "CLion", "CidrCommon", - "Python", "PyCharmCore", "Ruby", "UltimateLangXml", "Idea" }; + "Python", "PyCharmCore", "Ruby", "UltimateLangXml", "Idea", "PlatformLangXml" }; + /** + * @deprecated calling this method is no longer necessary + */ public static void autodetectPlatformPrefix() { + doAutodetectPlatformPrefix(); + } + + public static void doAutodetectPlatformPrefix() { if (ourPlatformPrefixInitialized) { return; } @@ -835,6 +842,9 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro return PsiDocumentManager.getInstance(getProject()).getPsiFile(document); } + /** + * @deprecated calling this method is no longer necessary + */ public static void initPlatformLangPrefix() { initPlatformPrefix(IDEA_MARKER_CLASS, "PlatformLangXml"); } @@ -849,6 +859,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro * * @param classToTest marker class qualified name e.g. {@link #IDEA_MARKER_CLASS}. * @param prefix platform prefix to be set up if marker class not found in classpath. + * @deprecated calling this method is no longer necessary */ public static void initPlatformPrefix(String classToTest, String prefix) { if (!ourPlatformPrefixInitialized) { diff --git a/spellchecker/testSrc/com/intellij/spellchecker/inspection/SpellcheckerInspectionTestCase.java b/spellchecker/testSrc/com/intellij/spellchecker/inspection/SpellcheckerInspectionTestCase.java index efc00486d51a..6237150bcdff 100644 --- a/spellchecker/testSrc/com/intellij/spellchecker/inspection/SpellcheckerInspectionTestCase.java +++ b/spellchecker/testSrc/com/intellij/spellchecker/inspection/SpellcheckerInspectionTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,15 +17,9 @@ package com.intellij.spellchecker.inspection; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.spellchecker.inspections.SpellCheckingInspection; -import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; public abstract class SpellcheckerInspectionTestCase extends LightPlatformCodeInsightFixtureTestCase { - @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") - protected SpellcheckerInspectionTestCase() { - PlatformTestCase.initPlatformLangPrefix(); - } - @Override protected boolean isCommunity() { return true;