diff options
Diffstat (limited to 'xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java')
-rw-r--r-- | xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java | 170 |
1 files changed, 89 insertions, 81 deletions
diff --git a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java index 51e0ff29c816..0809eeb6d6eb 100644 --- a/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/daemon/XmlHighlightingTest.java @@ -17,7 +17,7 @@ import com.intellij.ide.DataManager; import com.intellij.ide.highlighter.HighlighterFactory; import com.intellij.ide.highlighter.XmlHighlighterFactory; import com.intellij.javaee.ExternalResourceManagerEx; -import com.intellij.javaee.ExternalResourceManagerImpl; +import com.intellij.javaee.ExternalResourceManagerExImpl; import com.intellij.javaee.UriUtil; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.lang.ant.dom.AntResolveInspection; @@ -35,7 +35,7 @@ import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; import com.intellij.psi.*; @@ -121,8 +121,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String url = "http://www.foo.org/schema"; final String url2 = "http://www.bar.org/foo"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, getTestName(false) + ".xsd", getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily(url2, getTestName(false) + ".xsd", getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, getTestName(false) + ".xsd", getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url2, getTestName(false) + ".xsd", getTestRootDisposable()); try { final Collection<HighlightInfo> infoCollection = doDoTest(true, false, true); final TextRange startTagNameRange = XmlTagUtil.getStartTagNameElement(((XmlFile)myFile).getDocument().getRootTag()).getTextRange(); @@ -243,8 +243,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { String url = "http://drools.org/rules"; String url2 = "http://drools.org/semantics/groovy"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily(url2, location2, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url2, location2, getTestRootDisposable()); final String basePath = BASE_PATH + testName; configureByFiles(null, getVirtualFile(basePath + ".xml"), getVirtualFile(basePath + ".xsd"), getVirtualFile(basePath + "_2.xsd")); doDoTest(true,false); @@ -327,8 +327,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { if (resources != null) { int curResource = 0; for(String[] resource:resources) { - ExternalResourceManagerImpl - .registerResourceTemporarily(resource[0], getTestDataPath() + BASE_PATH + resource[1], getTestRootDisposable()); + ExternalResourceManagerExImpl + .registerResourceTemporarily(resource[0], getTestDataPath() + BASE_PATH + resource[1], getTestRootDisposable()); testNames[++curResource] = BASE_PATH + resource[1]; } } @@ -484,8 +484,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { String url = "parent"; String url2 = "child"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily(url2, location2, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url2, location2, getTestRootDisposable()); configureByFiles(null, getVirtualFile(BASE_PATH + getTestName(false) + ".xml"), getVirtualFile(BASE_PATH + location), getVirtualFile(BASE_PATH + location2)); @@ -498,7 +498,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { configureByFiles(null, getVirtualFile(BASE_PATH + getTestName(false) + ".xml"), getVirtualFile(BASE_PATH + schemaLocation)); - ExternalResourceManagerImpl.registerResourceTemporarily(schemaLocation, schemaLocation, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(schemaLocation, schemaLocation, getTestRootDisposable()); doDoTest(true, false); } @@ -602,7 +602,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testXercesMessagesBinding2() throws Exception { final String url = getTestName(false) + ".xsd"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, url, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, url, getTestRootDisposable()); doTest( new VirtualFile[] { @@ -615,7 +615,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final String url2 = getTestName(false) + "_2.xsd"; - ExternalResourceManagerImpl.registerResourceTemporarily(url2, url2, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url2, url2, getTestRootDisposable()); doTest( new VirtualFile[] { @@ -682,14 +682,14 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testStackOverflow() throws Exception { String location = "relaxng.xsd"; String url = "http://relaxng.org/ns/structure/fake/1.0"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); doTest(new VirtualFile[]{getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)}, false, false); } public void testStackOverflow2() throws Exception { final String url = "urn:aaa"; final String location = getTestName(false) + ".xsd"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); doTest(getFullRelativeTestName(".xsd"), false, false); } @@ -707,7 +707,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testComplexDtdValidation() throws Exception { String location = "Tapestry_3_0.dtd"; String url = "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); myTestJustJaxpValidation = true; doTest(new VirtualFile[] { getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location) }, false,false); @@ -716,7 +716,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testComplexDtdValidation2() throws Exception { String location = getTestName(false)+".dtd"; - ExternalResourceManagerImpl.registerResourceTemporarily(location, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(location, location, getTestRootDisposable()); myTestJustJaxpValidation = true; doTest(new VirtualFile[] { getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location) }, false,false); @@ -734,7 +734,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final VirtualFile virtualFile = getVirtualFile(BASE_PATH + "ComplexSchemaValidation3Schemas"); ContainerUtil.addAll(files, virtualFile.getChildren()); - doTest(VfsUtil.toVirtualFileArray(files), true, false); + doTest(VfsUtilCore.toVirtualFileArray(files), true, false); } public void testComplexSchemaValidation4() throws Exception { @@ -749,7 +749,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testComplexSchemaValidation5() throws Exception { String location = getTestName(false)+".xsd"; String url = "http://www.etas.com/TELEGY/Test"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); doTest(new VirtualFile[] { getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location) }, false,false); final XmlTag[] subTags = ((XmlFile)myFile).getDocument().getRootTag().getSubTags(); @@ -771,7 +771,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testComplexSchemaValidation6() throws Exception { String location = getTestName(false)+".xsd"; String url = "http://abcde/pg.html"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); doTest(new VirtualFile[]{getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)}, true, false); } @@ -792,7 +792,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public boolean process(final List<VirtualFile> files) { try { files.set(0, getVirtualFile(BASE_PATH + getTestName(false) + "_2.xml")); - doTest(VfsUtil.toVirtualFileArray(files), true, false); + doTest(VfsUtilCore.toVirtualFileArray(files), true, false); return true; } catch (Exception e) { @@ -821,7 +821,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testErrorInDtd() throws Exception { String location = "def_xslt.dtd"; String url = "http://www.w3.org/1999/XSL/Transform"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); doTest(new VirtualFile[]{getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)}, false, false); } @@ -1064,7 +1064,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testNonEnumeratedValuesHighlighting() throws Exception { final String url = "http://www.w3.org/1999/XSL/Format"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, "fop.xsd", getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, "fop.xsd", getTestRootDisposable()); configureByFiles(null, getVirtualFile(BASE_PATH + getTestName(false) + ".xml"), getVirtualFile(BASE_PATH + "fop.xsd")); doDoTest(true, false); } @@ -1314,9 +1314,9 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final VirtualFile virtualFile = getVirtualFile(BASE_PATH + getTestName(false)); ContainerUtil.addAll(files, virtualFile.getChildren()); - ExternalResourceManagerImpl - .registerResourceTemporarily(url, UriUtil.findRelativeFile(mainDtdName, virtualFile).getPath(), getTestRootDisposable()); - doTest(VfsUtil.toVirtualFileArray(files), true, false); + ExternalResourceManagerExImpl + .registerResourceTemporarily(url, UriUtil.findRelativeFile(mainDtdName, virtualFile).getPath(), getTestRootDisposable()); + doTest(VfsUtilCore.toVirtualFileArray(files), true, false); if (additionalTestAction != null) additionalTestAction.run(); @@ -1337,7 +1337,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { final VirtualFile virtualFile = getVirtualFile(base + filename); usedFiles.add(virtualFile); - if (url != null) ExternalResourceManagerImpl.registerResourceTemporarily(url, virtualFile.getPath(), getTestRootDisposable()); + if (url != null) ExternalResourceManagerExImpl.registerResourceTemporarily(url, virtualFile.getPath(), getTestRootDisposable()); files.add( virtualFile ); } @@ -1347,7 +1347,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { } } - doTest(VfsUtil.toVirtualFileArray(files), true, false); + doTest(VfsUtilCore.toVirtualFileArray(files), true, false); if (additionalTestingProcessor != null) additionalTestingProcessor.process(files); } @@ -1391,7 +1391,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testSchemaUpdate() throws IOException { String location = getTestName(false)+".xsd"; String url = "http://example.org/ns/books/"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); configureByFiles(null, getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)); doDoTest(true,false); @@ -1425,7 +1425,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { public void testSchemaValidation6() throws Exception { String location = getTestName(false)+".xsd"; String url = "aaa"; - ExternalResourceManagerImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily(url, location, getTestRootDisposable()); configureByFiles(null, getVirtualFile(getFullRelativeTestName()), getVirtualFile(BASE_PATH + location)); doDoTest(true,false); @@ -1794,8 +1794,8 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { } public void testSubstitutionFromInclude() throws Exception { - ExternalResourceManagerImpl - .registerResourceTemporarily("http://www.omg.org/spec/BPMN/20100524/MODEL", "BPMN20.xsd", getTestRootDisposable()); + ExternalResourceManagerExImpl + .registerResourceTemporarily("http://www.omg.org/spec/BPMN/20100524/MODEL", "BPMN20.xsd", getTestRootDisposable()); doTest( new VirtualFile[] { @@ -1819,7 +1819,7 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { {"http://www.w3.org/1999/xlink",path + "mylib.jar!/xlink.xsd"} }; - for(String[] s:urls) ExternalResourceManagerImpl.registerResourceTemporarily(s[0], s[1], getTestRootDisposable()); + for(String[] s:urls) ExternalResourceManagerExImpl.registerResourceTemporarily(s[0], s[1], getTestRootDisposable()); doDoTest(true, false); } @@ -1997,6 +1997,14 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { doDoTest(true, false); } + public void testSubstitution() throws Exception { + doTest(new VirtualFile[]{ + getVirtualFile(BASE_PATH + "Substitute/test.xml"), + getVirtualFile(BASE_PATH + "Substitute/schema-b.xsd"), + getVirtualFile(BASE_PATH + "Substitute/schema-a.xsd") + }, true, true); + } + @Override protected void setUp() throws Exception { super.setUp(); @@ -2004,54 +2012,54 @@ public class XmlHighlightingTest extends DaemonAnalyzerTestCase { old = XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS; XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS = false; - ExternalResourceManagerImpl.registerResourceTemporarily("http://www.springframework.org/schema/beans/spring-beans-2.5.xsd", - getTestDataPath() + BASE_PATH + "spring-beans-2.5.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", - getTestDataPath() + BASE_PATH + "web-app_2_4.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", - getTestDataPath() + BASE_PATH + "web-app_2_4.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/dtd/web-app_2_3.dtd", - getTestDataPath() + BASE_PATH + "web-app_2_3.dtd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://struts.apache.org/dtds/struts-config_1_2.dtd", - getTestDataPath() + BASE_PATH + "struts-config_1_2.dtd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/dtd/ejb-jar_2_0.dtd", - getTestDataPath() + BASE_PATH + "ejb-jar_2_0.dtd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/wsdl/", - getTestDataPath() + BASE_PATH + "wsdl11.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/wsdl/soap/", - getTestDataPath() + BASE_PATH + "wsdl11_soapbinding.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/soap/encoding/", - getTestDataPath() + BASE_PATH + "soap-encoding.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd", - getTestDataPath() + BASE_PATH + "application-client_1_4.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd", - getTestDataPath() + BASE_PATH + "hibernate-mapping-3.0.dtd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://maven.apache.org/maven-v4_0_0.xsd", - getTestDataPath() + BASE_PATH + "maven-4.0.0.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd", - getTestDataPath() + BASE_PATH + "web-jsptaglibrary_1_2.dtd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/JSP/Page", - getTestDataPath() + BASE_PATH + "jsp_2_0.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd", - getTestDataPath() + BASE_PATH + "web-jsptaglibrary_2_0.xsd", - getTestRootDisposable()); - ExternalResourceManagerImpl.registerResourceTemporarily("http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd", - getTestDataPath() + BASE_PATH + "hibernate-configuration-3.0.dtd", - getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://www.springframework.org/schema/beans/spring-beans-2.5.xsd", + getTestDataPath() + BASE_PATH + "spring-beans-2.5.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", + getTestDataPath() + BASE_PATH + "web-app_2_4.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", + getTestDataPath() + BASE_PATH + "web-app_2_4.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/dtd/web-app_2_3.dtd", + getTestDataPath() + BASE_PATH + "web-app_2_3.dtd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://struts.apache.org/dtds/struts-config_1_2.dtd", + getTestDataPath() + BASE_PATH + "struts-config_1_2.dtd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/dtd/ejb-jar_2_0.dtd", + getTestDataPath() + BASE_PATH + "ejb-jar_2_0.dtd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/wsdl/", + getTestDataPath() + BASE_PATH + "wsdl11.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/wsdl/soap/", + getTestDataPath() + BASE_PATH + "wsdl11_soapbinding.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://schemas.xmlsoap.org/soap/encoding/", + getTestDataPath() + BASE_PATH + "soap-encoding.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/application-client_1_4.xsd", + getTestDataPath() + BASE_PATH + "application-client_1_4.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd", + getTestDataPath() + BASE_PATH + "hibernate-mapping-3.0.dtd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://maven.apache.org/maven-v4_0_0.xsd", + getTestDataPath() + BASE_PATH + "maven-4.0.0.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd", + getTestDataPath() + BASE_PATH + "web-jsptaglibrary_1_2.dtd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/JSP/Page", + getTestDataPath() + BASE_PATH + "jsp_2_0.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd", + getTestDataPath() + BASE_PATH + "web-jsptaglibrary_2_0.xsd", + getTestRootDisposable()); + ExternalResourceManagerExImpl.registerResourceTemporarily("http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd", + getTestDataPath() + BASE_PATH + "hibernate-configuration-3.0.dtd", + getTestRootDisposable()); } private void disableHtmlSupport() { |