mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-133425 Add simple test for JSON injection in Java string
This commit is contained in:
@@ -12,6 +12,6 @@
|
||||
<orderEntry type="module" module-name="json" scope="TEST" />
|
||||
<orderEntry type="module" module-name="testFramework-java" scope="TEST" />
|
||||
<orderEntry type="module" module-name="spellchecker" scope="TEST" />
|
||||
<orderEntry type="module" module-name="codeInsight-tests" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.intellij.json;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.injected.InjectedLanguageTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.json.codeinsight.JsonStandardComplianceInspection;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public class JsonInjectionTest extends InjectedLanguageTestCase {
|
||||
// PY-133425
|
||||
public void testJsonFragmentInjectedInJavaString() {
|
||||
configureByFile("/injected/" + getTestName(false) + ".java");
|
||||
final List<HighlightInfo> highlightInfos = doHighlighting(HighlightSeverity.WARNING);
|
||||
assertNull(ContainerUtil.find(highlightInfos, new Condition<HighlightInfo>() {
|
||||
@Override
|
||||
public boolean value(HighlightInfo info) {
|
||||
return info.getDescription().equals(JsonBundle.message("msg.compliance.problem.illegal.property.key"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new JsonStandardComplianceInspection()};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/json/tests/testData";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class JsonFragmentInjectedInJavaString {
|
||||
// language=JSON
|
||||
String json = "{\"foo\": null}";
|
||||
}
|
||||
Reference in New Issue
Block a user