summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/testsrc/com
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-08-15 14:06:37 -0700
committerTor Norbye <tnorbye@google.com>2013-08-15 14:06:37 -0700
commita3c36999a717e0d9923378ca5e0ae1160118c1e6 (patch)
treeeda7fde5565d08649c0f5952e957a5ff4b2070d5 /plugins/InspectionGadgets/testsrc/com
parentd1129abbe4dc0ce9bbad9118a35a85dbebc8758f (diff)
downloadidea-a3c36999a717e0d9923378ca5e0ae1160118c1e6.tar.gz
Snapshot 13baaa319cd568c4e19b9232b24f2002f2631688 from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I2ede7fef748e781ed425346a4e03e721bf4d2610
Diffstat (limited to 'plugins/InspectionGadgets/testsrc/com')
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/WhileCanBeForeachFixTest.java38
-rw-r--r--plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java47
2 files changed, 85 insertions, 0 deletions
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/WhileCanBeForeachFixTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/WhileCanBeForeachFixTest.java
new file mode 100644
index 000000000000..0b2d7d2f9e5e
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/migration/WhileCanBeForeachFixTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2012 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.fixes.migration;
+
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.IGQuickFixesTestCase;
+import com.siyeh.ig.migration.UnnecessaryBoxingInspection;
+import com.siyeh.ig.migration.WhileCanBeForeachInspection;
+
+public class WhileCanBeForeachFixTest extends IGQuickFixesTestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ myFixture.enableInspections(new WhileCanBeForeachInspection());
+ myDefaultHint = InspectionGadgetsBundle.message("foreach.replace.quickfix");
+ }
+
+ public void testThis() { doTest(); }
+ public void testCast() { doTest(); }
+
+ @Override
+ protected String getRelativePath() {
+ return "migration/while_can_be_foreach";
+ }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
new file mode 100644
index 000000000000..e057666843c8
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspectionTest.java
@@ -0,0 +1,47 @@
+/**
+ * (c) 2013 Desert Island BV
+ * created: 14 08 2013
+ */
+package com.siyeh.ig.junit;
+
+import com.intellij.codeInspection.LocalInspectionTool;
+import com.siyeh.ig.LightInspectionTestCase;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class ExpectedExceptionNeverThrownInspectionTest extends LightInspectionTestCase {
+ @Override
+ protected LocalInspectionTool getInspection() {
+ return new ExpectedExceptionNeverThrownInspection();
+ }
+
+ @Override
+ protected String[] getEnvironmentClasses() {
+ return new String[] {"package org.junit; " +
+ "public @interface Test {\n" +
+ " java.lang.Class<? extends java.lang.Throwable> expected() default org.junit.Test.None.class;" +
+ "}"};
+ }
+
+ public void testSimple() {
+ doTest("class X {" +
+ " @org.junit.Test(expected=/*Expected 'java.io.IOException' never thrown in body of 'test()'*/java.io.IOException/**/.class)" +
+ " public void test() {}" +
+ "}");
+ }
+
+ public void testError() {
+ doTest("class X {" +
+ " @org.junit.Test(expected = Error.class)" +
+ " public void test() {}" +
+ "}");
+ }
+
+ public void testRuntimeException() {
+ doTest("class X {" +
+ " @org.junit.Test(expected = IllegalArgumentException.class)" +
+ " public void test() {}" +
+ "}");
+ }
+}