diff options
Diffstat (limited to 'plugins/java-i18n/testSrc/com/intellij/codeInspection')
4 files changed, 155 insertions, 0 deletions
diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java new file mode 100644 index 000000000000..0cf9f36e1859 --- /dev/null +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/DuplicateStringLiteralInspectionTest.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2005 JetBrains s.r.o. All Rights Reserved. + */ +package com.intellij.codeInspection.i18n; + +import com.intellij.codeInspection.duplicateStringLiteral.DuplicateStringLiteralInspection; +import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.testFramework.InspectionTestCase; + +public class DuplicateStringLiteralInspectionTest extends InspectionTestCase { + private final DuplicateStringLiteralInspection myInspection = new DuplicateStringLiteralInspection(); + + private void doTest() throws Exception { + doTest("duplicateStringLiteral/"+getTestName(true), new LocalInspectionToolWrapper(myInspection), "java 1.5"); + } + + public void testPropertyKey() throws Exception{ myInspection.IGNORE_PROPERTY_KEYS = true; doTest(); } + + @Override + protected String getTestDataPath() { + return PluginPathManager.getPluginHomePath("java-i18n") + "/testData/inspections"; + } +}
\ No newline at end of file diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java new file mode 100644 index 000000000000..dd0a1ac39fa1 --- /dev/null +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2005 JetBrains s.r.o. All Rights Reserved. + */ +package com.intellij.codeInspection.i18n; + +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.roots.LanguageLevelProjectExtension; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.JavaPsiFacade; +import com.intellij.testFramework.InspectionTestCase; + +/** + * @author lesya + */ +public class I18NInspectionTest extends InspectionTestCase { + private void doTest() throws Exception { + doTest(new I18nInspection()); + } + private void doTest(I18nInspection tool) throws Exception { + doTest("i18n/" + getTestName(true), tool); + } + + public void testHardCodedStringLiteralAsParameter() throws Exception{ doTest(); } + public void testReturnTypeInheritsNonNlsAnnotationFromParent() throws Exception{ doTest(); } + public void testRecursiveInheritance() throws Exception { doTest(); } + public void testParameterInheritsNonNlsAnnotationFromSuper() throws Exception { doTest(); } + public void testLocalVariables() throws Exception { doTest(); } + public void testFields() throws Exception{ doTest(); } + public void testAnonymousClassConstructorParameter() throws Exception { doTest(); } + public void testStringBufferNonNls() throws Exception { doTest(); } + public void testEnum() throws Exception { + final JavaPsiFacade facade = getJavaFacade(); + final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel(); + LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); + try { + doTest(); + } + finally { + LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel); + } + } + + public void testFormTabbedPaneTitle() throws Exception { doTest(); } + public void testVarargNonNlsParameter() throws Exception { doTest(); } + public void testInitializerInAnonymousClass() throws Exception{ doTest(); } + public void testNonNlsArray() throws Exception{ doTest(); } + public void testParameterInNewAnonymousClass() throws Exception{ doTest(); } + public void testConstructorCallOfNonNlsVariable() throws Exception{ doTest(); } + public void testSwitchOnNonNlsString() throws Exception{ doTest(); } + public void testNonNlsComment() throws Exception{ + I18nInspection inspection = new I18nInspection(); + inspection.nonNlsCommentPattern = "MYNON-NLS"; + inspection.cacheNonNlsCommentPattern(); + doTest(inspection); + } + public void testAnnotationArgument() throws Exception{ doTest(); } + + @Override + protected String getTestDataPath() { + return PluginPathManager.getPluginHomePath("java-i18n") + "/testData/inspections"; + } +} diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java new file mode 100644 index 000000000000..e5e9c9695f6a --- /dev/null +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/InvalidPropertyKeyInspectionTest.java @@ -0,0 +1,33 @@ +package com.intellij.codeInspection.i18n; + +import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; +import com.intellij.ide.startup.impl.StartupManagerImpl; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.module.impl.ModuleManagerImpl; +import com.intellij.openapi.startup.StartupManager; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.testFramework.InspectionTestCase; + +public class InvalidPropertyKeyInspectionTest extends InspectionTestCase { + private void doTest() throws Exception { + LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(new InvalidPropertyKeyInspection()); + doTest("invalidPropertyKey/" + getTestName(true), tool, "java 1.5"); + } + + @Override + protected void setupRootModel(final String testDir, final VirtualFile[] sourceDir, final String jdkName) { + super.setupRootModel(testDir, sourceDir, jdkName); + ((ModuleManagerImpl)ModuleManager.getInstance(getProject())).projectOpened(); + ((StartupManagerImpl)StartupManager.getInstance(getProject())).runPostStartupActivities(); + } + + public void testSimple() throws Exception { + doTest(); + } + + @Override + protected String getTestDataPath() { + return PluginPathManager.getPluginHomePath("java-i18n") + "/testData/inspections"; + } +} diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/UnusedMessageFormatParameterInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/UnusedMessageFormatParameterInspectionTest.java new file mode 100644 index 000000000000..0b8138a31172 --- /dev/null +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/UnusedMessageFormatParameterInspectionTest.java @@ -0,0 +1,36 @@ +package com.intellij.codeInspection.i18n; + +import com.intellij.lang.properties.UnusedMessageFormatParameterInspection; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.testFramework.InspectionTestCase; + +/** + * User: anna + * Date: 09-Sep-2005 + */ +public class UnusedMessageFormatParameterInspectionTest extends InspectionTestCase { + private void doTest() throws Exception { + doTest("unusedParameter/" + getTestName(true), new UnusedMessageFormatParameterInspection()); + } + + public void testSimpleString() throws Exception { + doTest(); + } + + public void testCorruptedValue() throws Exception{ + doTest(); + } + + public void testWithChoiceFormat() throws Exception{ + doTest(); + } + + public void testRegexp() throws Exception { + doTest(); + } + + @Override + protected String getTestDataPath() { + return PluginPathManager.getPluginHomePath("java-i18n") + "/testData/inspections"; + } +} |