summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/testsrc/com/siyeh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/InspectionGadgets/testsrc/com/siyeh')
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/ImplicitDefaultCharsetUsageInspectionTest.java9
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/LoggerInitializedWithForeignClassInspectionTest.java51
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/PlaceholderCountMatchesArgumentCountInspectionTest.java15
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java15
4 files changed, 86 insertions, 4 deletions
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/ImplicitDefaultCharsetUsageInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/ImplicitDefaultCharsetUsageInspectionTest.java
index 78822492b4bc..312e08aebcc3 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/ImplicitDefaultCharsetUsageInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/internationalization/ImplicitDefaultCharsetUsageInspectionTest.java
@@ -16,13 +16,22 @@
package com.siyeh.ig.internationalization;
import com.intellij.codeInspection.InspectionProfileEntry;
+import com.intellij.testFramework.LightProjectDescriptor;
import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.NotNull;
/**
* @author Bas Leijdekkers
*/
public class ImplicitDefaultCharsetUsageInspectionTest extends LightInspectionTestCase {
+
+ @NotNull
+ @Override
+ protected LightProjectDescriptor getProjectDescriptor() {
+ return JAVA_8;
+ }
+
@Override
protected InspectionProfileEntry getInspection() {
return new ImplicitDefaultCharsetUsageInspection();
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/LoggerInitializedWithForeignClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/LoggerInitializedWithForeignClassInspectionTest.java
new file mode 100644
index 000000000000..7f0b521fcf4e
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/LoggerInitializedWithForeignClassInspectionTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.logging;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class LoggerInitializedWithForeignClassInspectionTest extends LightInspectionTestCase {
+
+ public void testLoggerInitializedWithForeignClass() {
+ doTest();
+ }
+
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ final LoggerInitializedWithForeignClassInspection inspection = new LoggerInitializedWithForeignClassInspection();
+ inspection.loggerFactoryClassNames.add("java.util.logging.Logger");
+ inspection.loggerFactoryMethodNames.add("getLogger");
+ return inspection;
+ }
+
+ @Override
+ protected String[] getEnvironmentClasses() {
+ return new String[] {
+ "package java.util.logging;" +
+ "public class Logger {" +
+ " public static Logger getLogger(String name) {" +
+ " return null;" +
+ " }" +
+ "}"
+ };
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/PlaceholderCountMatchesArgumentCountInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/PlaceholderCountMatchesArgumentCountInspectionTest.java
index 1bd7feadae45..48d120189740 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/PlaceholderCountMatchesArgumentCountInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/logging/PlaceholderCountMatchesArgumentCountInspectionTest.java
@@ -32,7 +32,7 @@ public class PlaceholderCountMatchesArgumentCountInspectionTest extends LightIns
"class X {\n" +
" void foo() {\n" +
" Logger logger = LoggerFactory.getLogger(X.class);\n" +
- " logger./*'info()' call has fewer arguments (1) than placeholders (2)*/info/**/(\"string {}{}\", 1);\n" +
+ " logger.info(/*Fewer arguments provided (1) than placeholders specified (2) in 'string {}{}'*/\"string {}{}\"/**/, 1);\n" +
" }\n" +
"}"
);
@@ -43,7 +43,7 @@ public class PlaceholderCountMatchesArgumentCountInspectionTest extends LightIns
"class X {\n" +
" void foo() {\n" +
" Logger logger = LoggerFactory.getLogger(X.class);\n" +
- " logger./*'info()' call has more arguments (1) than placeholders (0)*/info/**/(\"string\", 1);\n" +
+ " logger.info(/*More arguments provided (1) than placeholders specified (0) in 'string'*/\"string\"/**/, 1);\n" +
" }\n" +
"}"
);
@@ -107,4 +107,15 @@ public class PlaceholderCountMatchesArgumentCountInspectionTest extends LightIns
" }" +
"}");
}
+
+ public void testConstant() {
+ doTest("import org.slf4j.*;" +
+ "class X {" +
+ " Logger LOG = LoggerFactory.getLogger(X.class);" +
+ " private static final String message = \"HELLO {}\";" +
+ " void m() {" +
+ " LOG.info(/*Fewer arguments provided (0) than placeholders specified (1) in 'HELLO {}'*/message/**/);" +
+ " }" +
+ "}");
+ }
} \ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
index 6c5a89009735..2e1b839c85d3 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/style/UnnecessaryFullyQualifiedNameInspectionTest.java
@@ -1,11 +1,22 @@
package com.siyeh.ig.style;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.siyeh.ig.IGInspectionTestCase;
public class UnnecessaryFullyQualifiedNameInspectionTest extends IGInspectionTestCase {
public void test() throws Exception {
- doTest("com/siyeh/igtest/style/unnecessary_fully_qualified_name",
- new UnnecessaryFullyQualifiedNameInspection());
+ final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
+
+ boolean inJavadoc = styleSettings.USE_FQ_CLASS_NAMES_IN_JAVADOC;
+ try {
+ styleSettings.USE_FQ_CLASS_NAMES_IN_JAVADOC = false;
+ doTest("com/siyeh/igtest/style/unnecessary_fully_qualified_name",
+ new UnnecessaryFullyQualifiedNameInspection());
+ }
+ finally {
+ styleSettings.USE_FQ_CLASS_NAMES_IN_JAVADOC = inJavadoc;
+ }
}
}