Remove dependency on Java test framework

GitOrigin-RevId: 92b6c1e566fb9c55db80d8beb5cf09d508163633
This commit is contained in:
Rustam Vishnyakov
2019-06-17 18:00:28 +03:00
committed by intellij-monorepo-bot
parent c3b05f68f3
commit 1add695580
17 changed files with 22 additions and 352 deletions

View File

@@ -32,7 +32,6 @@
<orderEntry type="library" name="kotlin-reflect" level="project" />
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="intellij.spellchecker" />
<orderEntry type="module" module-name="intellij.java.testFramework" scope="TEST" />
<orderEntry type="library" name="automaton" level="project" />
</component>
</module>

View File

@@ -1,49 +0,0 @@
// Copyright 2000-2019 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.editorconfig.configmanagement;
import com.intellij.application.options.CodeStyle;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import org.editorconfig.Utils;
public class EditorConfigStandardSettingsTest extends EditorConfigFileSettingsTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
Utils.setFullIntellijSettingsSupportEnabledInTest(false);
}
public void testIndentSizeTab() {
final CommonCodeStyleSettings.IndentOptions projectIndentOptions =
CodeStyle.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE).getIndentOptions();
projectIndentOptions.TAB_SIZE = 4;
projectIndentOptions.INDENT_SIZE = 2;
PsiFile javaFile = findPsiFile("source.java");
final CommonCodeStyleSettings.IndentOptions indentOptions = CodeStyle.getIndentOptions(javaFile);
assertTrue(indentOptions.USE_TAB_CHARACTER);
assertEquals("Indent size doesn't match tab size", indentOptions.TAB_SIZE, indentOptions.INDENT_SIZE);
}
public void testIndentStyleTab() {
final CommonCodeStyleSettings.IndentOptions projectIndentOptions =
CodeStyle.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE).getIndentOptions();
projectIndentOptions.TAB_SIZE = 4;
projectIndentOptions.INDENT_SIZE = 2;
PsiFile javaFile = findPsiFile("source.java");
final CommonCodeStyleSettings.IndentOptions indentOptions = CodeStyle.getIndentOptions(javaFile);
assertEquals("Indent size doesn't match tab size", indentOptions.TAB_SIZE, indentOptions.INDENT_SIZE);
}
public void testIndentSizeTabWidth() {
PsiFile javaFile = findPsiFile("source.java");
final CommonCodeStyleSettings.IndentOptions indentOptions = CodeStyle.getIndentOptions(javaFile);
assertEquals(3, indentOptions.TAB_SIZE);
assertEquals(3, indentOptions.INDENT_SIZE);
}
@Override
protected String getRelativePath() {
return "/plugins/editorconfig/testData/org/editorconfig/configmanagement/fileSettings";
}
}

View File

@@ -1,117 +0,0 @@
// Copyright 2000-2019 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.editorconfig.configmanagement;
import com.intellij.codeInsight.JavaCodeInsightTestCase;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.EditorTestUtil;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("SameParameterValue")
public class EditorConfigTrailingSpacesTest extends JavaCodeInsightTestCase {
private EditorSettingsExternalizable.OptionSet oldSettings;
@Override
protected void setUp() throws Exception {
super.setUp();
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
oldSettings = settings.getState();
settings.loadState(new EditorSettingsExternalizable.OptionSet());
}
@Override
protected void tearDown() throws Exception {
try {
EditorSettingsExternalizable.getInstance().loadState(oldSettings);
}
catch (Throwable e) {
addSuppressedException(e);
}
finally {
super.tearDown();
}
}
public void testKeepTrailingSpacesOnSave() throws Exception {
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);
PsiFile ecFile = createFile(
".editorconfig",
"root = true\n" +
"[*]\n" +
"trim_trailing_whitespace=false");
final String originalText =
"class Foo { \n" +
" void foo() \n" +
"}";
PsiFile source = createFile(getModule(), ecFile.getVirtualFile().getParent(), "source.java", originalText);
configureByExistingFile(source.getVirtualFile());
type(' ');
EditorTestUtil.executeAction(getEditor(),"SaveAll");
assertEquals(originalText, getEditor().getDocument().getText().trim());
}
public void testRemoveTrailingSpacesOnSave() throws Exception {
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
settings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
PsiFile ecFile = createFile(
".editorconfig",
"root = true\n" +
"[*]\n" +
"trim_trailing_whitespace=true");
final String originalText =
"class Foo { \n" +
" void foo() \n" +
"}";
PsiFile source = createFile(getModule(), ecFile.getVirtualFile().getParent(), "source.java", originalText);
configureByExistingFile(source.getVirtualFile());
type(' ');
EditorTestUtil.executeAction(getEditor(),"SaveAll");
assertEquals(
"class Foo {\n" +
" void foo()\n" +
"}",
getEditor().getDocument().getText().trim());
}
public void testEnsureNewLine() throws Exception {
EditorSettingsExternalizable settings = EditorSettingsExternalizable.getInstance();
settings.setEnsureNewLineAtEOF(false);
PsiFile ecFile = createFile(
".editorconfig",
"root = true\n" +
"[*]\n" +
"insert_final_newline=true");
final String originalText =
"class Foo {\n" +
" void foo()\n" +
"}";
PsiFile source = createFile(getModule(), ecFile.getVirtualFile().getParent(), "source.java", originalText);
configureByExistingFile(source.getVirtualFile());
type(' ');
EditorTestUtil.executeAction(getEditor(),"SaveAll");
assertEquals(
" class Foo {\n" +
" void foo()\n" +
"}\n",
getEditor().getDocument().getText());
}
@NotNull
@Override
protected String getTestDataPath() {
return PluginPathManager.getPluginHomePath("editorconfig") + "/testData/org/editorconfig/configmanagement/fileSettings/";
}
}

View File

@@ -1,13 +1,11 @@
// Copyright 2000-2019 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.editorconfig.configmanagement;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightJavaInspectionTestCase;
import com.intellij.testFramework.InspectionFixtureTestCase;
import org.editorconfig.Utils;
import org.editorconfig.language.codeinsight.inspections.EditorConfigValueCorrectnessInspection;
import org.jetbrains.annotations.Nullable;
public class EditorConfigValueInspectionTest extends LightJavaInspectionTestCase {
public class EditorConfigValueInspectionTest extends InspectionFixtureTestCase {
@Override
protected void setUp() throws Exception {
@@ -30,17 +28,17 @@ public class EditorConfigValueInspectionTest extends LightJavaInspectionTestCase
public void testValues() {
myFixture.configureByFile(".editorconfig");
myFixture.enableInspections(EditorConfigValueCorrectnessInspection.class);
myFixture.testHighlighting(true, false, true);
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new EditorConfigValueCorrectnessInspection();
}
@Override
protected String getBasePath() {
return "/plugins/editorconfig/testData/org/editorconfig/configmanagement/inspections/";
}
@Override
protected boolean isCommunity() {
return true;
}
}

View File

@@ -1,133 +0,0 @@
// Copyright 2000-2019 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.editorconfig.configmanagement.export;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.testFramework.LightPlatformTestCase;
import com.intellij.util.LineSeparator;
import org.editorconfig.configmanagement.extended.EditorConfigPropertyKind;
import org.editorconfig.language.EditorConfigLanguage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class EditorConfigExportTest extends LightPlatformTestCase {
public void testWriter() throws IOException {
CodeStyleSettings setting = CodeStyleSettings.getDefaults().clone();
setting.LINE_SEPARATOR = LineSeparator.CRLF.getSeparatorString();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (EditorConfigSettingsWriter writer =
new EditorConfigSettingsWriter(getProject(), output, setting, false, false)
.forLanguages(EditorConfigLanguage.INSTANCE, XMLLanguage.INSTANCE)) {
writer.writeSettings();
}
String result = output.toString("UTF-8");
result = result.replaceAll("\\[.*\\.xml.*]", "[*.xml]"); // Leave only XML
assertEquals(
"[*]\n" +
"charset = utf-8\n" +
"end_of_line = crlf\n" +
"indent_size = 4\n" +
"indent_style = space\n" +
"insert_final_newline = false\n" +
"max_line_length = 120\n" +
"tab_width = 4\n" +
"ij_continuation_indent_size = 8\n" +
"ij_formatter_off_tag = @formatter:off\n" +
"ij_formatter_on_tag = @formatter:on\n" +
"ij_formatter_tags_enabled = false\n" +
"ij_smart_tabs = false\n" +
"ij_wrap_on_typing = false\n" +
"\n" +
"[.editorconfig]\n" +
"ij_editorconfig_align_group_field_declarations = false\n" +
"ij_editorconfig_space_after_colon = false\n" +
"ij_editorconfig_space_after_comma = true\n" +
"ij_editorconfig_space_before_colon = false\n" +
"ij_editorconfig_space_before_comma = false\n" +
"ij_editorconfig_spaces_around_assignment_operators = true\n" +
"\n" +
"[*.xml]\n" +
"ij_xml_block_comment_at_first_column = true\n" +
"ij_xml_keep_indents_on_empty_lines = false\n" +
"ij_xml_line_comment_at_first_column = true\n",
result);
}
public void testSkipEmptySection() throws IOException {
CodeStyleSettings setting = CodeStyleSettings.getDefaults().clone();
setting.LINE_SEPARATOR = LineSeparator.CRLF.getSeparatorString();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (EditorConfigSettingsWriter writer = new EditorConfigSettingsWriter(getProject(), output, setting, false, false)
.forLanguages(EditorConfigLanguage.INSTANCE, XMLLanguage.INSTANCE)
.forPropertyKinds(EditorConfigPropertyKind.EDITOR_CONFIG_STANDARD)) {
writer.writeSettings();
}
String result = output.toString("UTF-8");
assertEquals(
"[*]\n" +
"charset = utf-8\n" +
"end_of_line = crlf\n" +
"indent_size = 4\n" +
"indent_style = space\n" +
"insert_final_newline = false\n" +
"max_line_length = 120\n" +
"tab_width = 4\n",
result);
}
public void testFilterByPropertyKind() throws IOException {
CodeStyleSettings setting = CodeStyleSettings.getDefaults().clone();
setting.LINE_SEPARATOR = LineSeparator.CRLF.getSeparatorString();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (EditorConfigSettingsWriter writer =
new EditorConfigSettingsWriter(getProject(), output, setting, true, false)
.forLanguages(EditorConfigLanguage.INSTANCE)
.forPropertyKinds(EditorConfigPropertyKind.EDITOR_CONFIG_STANDARD)) {
writer.writeSettings();
}
String result = output.toString("UTF-8");
assertEquals(
"root = true\n" +
"\n" +
"[*]\n" +
"charset = utf-8\n" +
"end_of_line = crlf\n" +
"indent_size = 4\n" +
"indent_style = space\n" +
"insert_final_newline = false\n" +
"max_line_length = 120\n" +
"tab_width = 4\n",
result);
}
public void testCommentedOut() throws IOException {
CodeStyleSettings setting = CodeStyleSettings.getDefaults().clone();
setting.LINE_SEPARATOR = LineSeparator.CRLF.getSeparatorString();
ByteArrayOutputStream output = new ByteArrayOutputStream();
try (EditorConfigSettingsWriter writer =
new EditorConfigSettingsWriter(getProject(), output, setting, true, true)
.forLanguages(EditorConfigLanguage.INSTANCE)
.forPropertyKinds(EditorConfigPropertyKind.EDITOR_CONFIG_STANDARD)) {
writer.writeSettings();
}
String result = output.toString("UTF-8");
assertEquals(
"root = true\n" +
"\n" +
"[*]\n" +
"# charset = utf-8\n" +
"# end_of_line = crlf\n" +
"# indent_size = 4\n" +
"# indent_style = space\n" +
"# insert_final_newline = false\n" +
"# max_line_length = 120\n" +
"# tab_width = 4\n",
result);
}
}

View File

@@ -3,12 +3,14 @@ package org.editorconfig.language
import com.intellij.testFramework.PlatformTestUtil.assertTreeEqual
import com.intellij.testFramework.PlatformTestUtil.expandAll
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.BasePlatformTestCase
class EditorConfigStructureViewTest : LightJavaCodeInsightFixtureTestCase() {
class EditorConfigStructureViewTest : BasePlatformTestCase() {
override fun getBasePath() =
"/plugins/editorconfig/testData/org/editorconfig/language/structureview/"
override fun isCommunity(): Boolean = true
fun doTest(expected: String) {
myFixture.configureByFile(getTestName(true) + "/.editorconfig")
myFixture.testStructureView { svc ->

View File

@@ -3,12 +3,14 @@ package org.editorconfig.language.codeinsight.actions
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.BasePlatformTestCase
class EditorConfigMoveElementLeftRightHandlerTest : LightJavaCodeInsightFixtureTestCase() {
class EditorConfigMoveElementLeftRightHandlerTest : BasePlatformTestCase() {
override fun getBasePath() =
"/plugins/editorconfig/testData/org/editorconfig/language/codeinsight/actions/moveLeftRight/"
override fun isCommunity(): Boolean = true
fun testMoveCentralValue() = doTest()
fun testMoveFirstValue() = doTest()
fun testMoveLastValue() = doTest()

View File

@@ -3,12 +3,14 @@ package org.editorconfig.language.codeinsight.actions
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.BasePlatformTestCase
class EditorConfigStatementUpDownMoverTest : LightJavaCodeInsightFixtureTestCase() {
class EditorConfigStatementUpDownMoverTest : BasePlatformTestCase() {
override fun getBasePath() =
"/plugins/editorconfig/testData/org/editorconfig/language/codeinsight/actions/moveUpDown/"
override fun isCommunity(): Boolean = true
fun testMoveFirstOption() = doTest()
fun testMoveCentralOption() = doTest()
fun testMoveLastOption() = doTest()

View File

@@ -2,10 +2,10 @@
package org.editorconfig.language.documentation
import com.intellij.codeInsight.documentation.DocumentationManager
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import org.editorconfig.language.codeinsight.documentation.EditorConfigDocumentationProvider
class EditorConfigDocumentationTest : LightJavaCodeInsightFixtureTestCase() {
class EditorConfigDocumentationTest : BasePlatformTestCase() {
fun testIndentSizeDoc() {
myFixture.configureByText(
".editorconfig",

View File

@@ -1,6 +0,0 @@
root = true
[*]
indent_style = tab
indent_size = tab

View File

@@ -1,6 +0,0 @@
root = true
[*]
indent_size = tab
tab_width = 3

View File

@@ -1,5 +0,0 @@
root = true
[*]
trim_trailing_whitespace = false