List of usage examples for com.intellij.openapi.vfs JarFileSystem PROTOCOL_PREFIX
String PROTOCOL_PREFIX
To view the source code for com.intellij.openapi.vfs JarFileSystem PROTOCOL_PREFIX.
Click Source Link
From source file:com.intellij.codeInsight.documentation.RefConvertorsTest.java
License:Apache License
public void testImgInsideJar() throws Exception { String imgJarName = "test-img"; File imgJar = new File(myExtractedImagesDir, imgJarName + ".jar"); boolean exist = FileUtil.createIfDoesntExist(imgJar); assertTrue(exist);/*from w w w .j a v a2s . c o m*/ JarOutputStream out = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(imgJar))); try { out.putNextEntry(new JarEntry("resources/inherit.gif")); FileInputStream fIn = new FileInputStream( JavaTestUtil.getJavaTestDataPath() + "/codeInsight/documentation/inherit.gif"); try { FileUtil.copy(fIn, out); } finally { fIn.close(); } } finally { out.close(); } String textBefore = "<HTML>" + "java.lang.Object\n" + " <IMG SRC=\"../../../resources/inherit.gif\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + "</HTML>"; File f = new File(myExtractedImagesDir, imgJarName); f = new File(f, "resources"); File extractedImgFile = new File(f, "inherit.gif"); String expectedTextAfter = String.format("<HTML>" + "java.lang.Object\n" + " <IMG SRC=\"%s%s\" ALT=\"extended by \"><B>org.bouncycastle.asn1.BERSequenceParser</B>\n" + "</HTML>", LocalFileSystem.PROTOCOL_PREFIX, extractedImgFile.getAbsolutePath()); JavaDocExternalFilter filter = new JavaDocExternalFilter(getProject()); String textAfter = filter.correctRefs(String.format("%s%s!/org/bouncycastle/asn1/BERSequenceParser.html", JarFileSystem.PROTOCOL_PREFIX, imgJar.getAbsolutePath()), textBefore); assertEquals(expectedTextAfter, textAfter); assertTrue(extractedImgFile.isFile()); }