diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java index 27010b81e038..5cf7581acaf0 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/NullableStuffInspectionTest.java @@ -9,6 +9,12 @@ package com.intellij.codeInspection; import com.intellij.JavaTestUtil; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.nullable.NullableStuffInspection; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.SdkModificator; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.roots.OrderRootType; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.testFramework.InspectionTestCase; public class NullableStuffInspectionTest extends InspectionTestCase { @@ -26,7 +32,13 @@ public class NullableStuffInspectionTest extends InspectionTestCase { doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection),"java 1.5"); } private void doTest14() throws Exception { - doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection),"java 1.4"); + myExcludeAnnotations = true; + try { + doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection),"java 1.4"); + } + finally { + myExcludeAnnotations = false; + } } public void testProblems() throws Exception{ doTest(); } @@ -38,4 +50,28 @@ public class NullableStuffInspectionTest extends InspectionTestCase { myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true; doTest(); } + + private boolean myExcludeAnnotations = false; + + @Override + protected void setupRootModel(String testDir, VirtualFile[] sourceDir, String sdkName) { + super.setupRootModel(testDir, sourceDir, sdkName); + + if (myExcludeAnnotations) { + final Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk(); + assert sdk != null; + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + final SdkModificator sdkMod = sdk.getSdkModificator(); + for (VirtualFile file : sdkMod.getRoots(OrderRootType.CLASSES)) { + if ("annotations.jar".equals(file.getName())) { + sdkMod.removeRoot(file, OrderRootType.CLASSES); + break; + } + } + sdkMod.commitChanges(); + } + }); + } + } } \ No newline at end of file