diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/expected.xml deleted file mode 100644 index e8f00e82629f..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/expected.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/expected.xml deleted file mode 100644 index 248b78324e23..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/expected.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - IOResourceInspection.java - 7 - - void foo() - foo() - com.siyeh.igtest.resources - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - IOResourceInspection.java - 11 - - void foo2() - foo2() - com.siyeh.igtest.resources - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - - - IOResourceInspection.java - 17 - - void foo25() - foo25() - com.siyeh.igtest.resources - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - IOResourceInspection.java - 57 - - void foo6() - foo6() - com.siyeh.igtest.resources - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - IOResourceInspection.java - 66 - - void foo7() - foo7() - com.siyeh.igtest.resources - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - IOResourceInspection.java - 94 - - void interrupting() - interrupting() - com.siyeh.igtest.resources.io - - IOResource - IOResource - - - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a try block and closed in the corresponding finally block #loc - - - - IOResourceInspection.java - 148 - I/O resource opened but not safely closed - 'InputStream' should be opened in front of a 'try' block and closed in the corresponding 'finally' block #loc - - - - IOResourceInspection.java - 152 - I/O resource opened but not safely closed - 'FileInputStream' should be opened in front of a 'try' block and closed in the corresponding 'finally' block #loc - - - diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/IOResourceInspection.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/IOResource.java similarity index 71% rename from plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/IOResourceInspection.java rename to plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/IOResource.java index dacea8301f49..2bc024b6fdf6 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/plain/IOResourceInspection.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/IOResource.java @@ -1,20 +1,20 @@ -package com.siyeh.igtest.resources.io.plain; +package com.siyeh.igtest.resources.ioresource; import java.io.*; -public class IOResourceInspection { +public class IOResource { public void foo() throws FileNotFoundException { - new FileInputStream("bar"); + new FileInputStream("bar"); } public void foo2() throws FileNotFoundException { - final FileInputStream str = new FileInputStream("bar"); + final FileInputStream str = new FileInputStream("bar"); } public void foo25() throws FileNotFoundException { try { - final FileInputStream str = new FileInputStream("bar"); + final FileInputStream str = new FileInputStream("bar"); } finally { } @@ -54,7 +54,7 @@ public class IOResourceInspection { public void foo6() throws IOException { FileInputStream str = null; try { - str = new FileInputStream("bar"); + str = new FileInputStream("bar"); } finally { } } @@ -63,7 +63,7 @@ public class IOResourceInspection { FileInputStream str = null; BufferedInputStream str2 = null; try { - str = new FileInputStream("bar"); + str = new FileInputStream("bar"); str2 = new BufferedInputStream(str); } catch (FileNotFoundException e) { e.printStackTrace(); @@ -91,7 +91,7 @@ public class IOResourceInspection { } } public void interrupting() throws IOException { - FileInputStream str = new FileInputStream("xxxx"); + FileInputStream str = new FileInputStream("xxxx"); str.read(); try { str.read(); @@ -145,11 +145,11 @@ public class IOResourceInspection { } void resourceAsStream() { - String.class.getResourceAsStream("bla"); + String.class.getResourceAsStream("bla"); } public static void c() throws IOException { - InputStream in = new FileInputStream(""); + InputStream in = new FileInputStream(""); OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("asd")); try { writer.write(0); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/A.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/InsideTry.java similarity index 84% rename from plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/A.java rename to plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/InsideTry.java index e5ebfe2dd2d6..8587239e1645 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/io/inside_try/A.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/resources/ioresource/InsideTry.java @@ -1,8 +1,8 @@ -package com.siyeh.igtest.resources.io.inside_try; +package com.siyeh.igtest.resources.ioresource; import java.io.*; -public class A { +public class InsideTry { void foo() throws IOException { InputStream in = null; diff --git a/plugins/InspectionGadgets/testsrc/com/resources/IOResourceInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/resources/IOResourceInspectionTest.java index 6161130004a6..b9b7fc833525 100644 --- a/plugins/InspectionGadgets/testsrc/com/resources/IOResourceInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/resources/IOResourceInspectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * 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. @@ -15,32 +15,30 @@ */ package com.resources; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.testFramework.IdeaTestUtil; -import com.siyeh.ig.IGInspectionTestCase; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; import com.siyeh.ig.resources.IOResourceInspection; +import org.jetbrains.annotations.Nullable; /** * @author Alexey */ -public class IOResourceInspectionTest extends IGInspectionTestCase { +public class IOResourceInspectionTest extends LightInspectionTestCase { - @Override - protected Sdk getTestProjectSdk() { - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7); - return IdeaTestUtil.getMockJdk17(); - } - - public void test() throws Exception { - doTest("com/siyeh/igtest/resources/io/plain", new IOResourceInspection()); + public void testIOResource() { + doTest(); } public void testInsideTry() throws Exception { final IOResourceInspection inspection = new IOResourceInspection(); inspection.insideTryAllowed = true; - doTest("com/siyeh/igtest/resources/io/inside_try", inspection); + myFixture.enableInspections(inspection); + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new IOResourceInspection(); } }