Files
openide/java/java-tests/testSrc/com/resources/IOResourceInspectionTest.java
Tagir Valeev 4f22d33eac [java-tests] Test sources moved from InspectionGadgets/IntentionPowerPak to java-tests
GitOrigin-RevId: 6740376193d319be31f0ae52679a06b5379d5467
2023-08-01 13:06:36 +00:00

50 lines
1.4 KiB
Java

// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.resources;
import com.intellij.codeInspection.InspectionProfileEntry;
import com.siyeh.ig.LightJavaInspectionTestCase;
import com.siyeh.ig.resources.IOResourceInspection;
import org.jetbrains.annotations.Nullable;
/**
* @author Alexey
*/
public class IOResourceInspectionTest extends LightJavaInspectionTestCase {
public void testIOResource() {
doTest();
}
public void testInsideTry() {
final IOResourceInspection inspection = new IOResourceInspection();
inspection.insideTryAllowed = true;
myFixture.enableInspections(inspection);
doTest();
}
public void testNoEscapingThroughMethodCalls() {
final IOResourceInspection inspection = new IOResourceInspection();
inspection.anyMethodMayClose = false;
myFixture.enableInspections(inspection);
doTest();
}
@Nullable
@Override
protected InspectionProfileEntry getInspection() {
return new IOResourceInspection();
}
@Override
protected String[] getEnvironmentClasses() {
return new String[] {
"package org.apache.commons.io;" +
"import java.io.InputStream;" +
"public class IOUtils {" +
" public static void closeQuietly(InputStream input) {}" +
"}"
};
}
}