Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,14 @@

import javax.swing.text.html.HTML.Tag;

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.NoSuchElementException;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
Expand Down Expand Up @@ -164,39 +157,6 @@ void testendElementAlreadyClosed() {
}
}

/**
* Issue #51: <a href="https://github.com/codehaus-plexus/plexus-utils/issues/51">...</a> Purpose: test if concatenation string
* optimization bug is present. Target environment: Java 7 (u79 and u80 verified) running on Windows. Detection
* strategy: Tries to build a big XML file (~750MB size) and with many nested tags to force the JVM to trigger the
* concatenation string optimization bug that throws a NoSuchElementException when calling endElement() method.
*
* @throws IOException if an I/O error occurs
*/
@Disabled("This test is only relevant on JDK 1.7, which is not supported anymore")
@Test
void issue51DetectJava7ConcatenationBug() throws IOException {
File dir = new File("target/test-xml");
if (!dir.exists()) {
assertTrue(dir.mkdir(), "cannot create directory test-xml");
}
File xmlFile = new File(dir, "test-issue-51.xml");

int iterations = 20000;
try (OutputStreamWriter osw =
new OutputStreamWriter(Files.newOutputStream(xmlFile.toPath()), StandardCharsets.UTF_8)) {
writer = new PrettyPrintXMLWriter(osw);
for (int i = 0; i < iterations; ++i) {
writer.startElement(Tag.DIV.toString() + i);
writer.addAttribute("class", "someattribute");
}
for (int i = 0; i < iterations; ++i) {
writer.endElement(); // closes Tag.DIV + i
}
} catch (NoSuchElementException e) {
fail("Should not throw a NoSuchElementException");
}
}

private void writeXhtmlHead(XMLWriter writer) {
writer.startElement(Tag.HEAD.toString());
writer.startElement(Tag.TITLE.toString());
Expand Down
Loading