Files
openide/java/java-tests/testSrc/com/intellij/execution/impl/JavaRunnerRestrictedMethodCallConsoleFoldingTest.java
Mikhail Pyltsin 85d38f47ea [java-runner] IJ-CR-154797 IDEA-363985 Temporary workaround for JNI restriction
(cherry picked from commit 636caa3aaf46f8bbe6b37ca474662bb95f705f97)

GitOrigin-RevId: dda8badbd17ef8a6f23930282779e482f12c10e4
2025-02-13 17:08:27 +00:00

37 lines
2.2 KiB
Java

// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.execution.impl;
import com.intellij.execution.JavaRunnerRestrictedMethodCallConsoleFolding;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import java.util.List;
public class JavaRunnerRestrictedMethodCallConsoleFoldingTest extends LightJavaCodeInsightFixtureTestCase {
public void testFold() {
String actualText = """
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.intellij.rt.execution.application.AppMainV2 in an unnamed module (file:/C:/projects-idea/intellij/out/classes/production/intellij.java.rt/)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
""";
List<String> lines = StringUtil.split(actualText, "\n");
JavaRunnerRestrictedMethodCallConsoleFolding consoleFolding = new JavaRunnerRestrictedMethodCallConsoleFolding();
for (String line : lines) {
assertTrue(consoleFolding.shouldFoldLine(getProject(), line));
}
assertNotNull(consoleFolding.getPlaceholderText(getProject(), lines));
}
public void testNotFold() {
String actualText = """
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.intellij.rt.execution.application.AppMainV in an unnamed module (file:/C:/projects-idea/intellij/out/classes/production/intellij.java.rt/)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
""";
List<String> lines = StringUtil.split(actualText, "\n");
JavaRunnerRestrictedMethodCallConsoleFolding consoleFolding = new JavaRunnerRestrictedMethodCallConsoleFolding();
assertNull(consoleFolding.getPlaceholderText(getProject(), lines));
}
}