mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[tests] properly close written files in tests
GitOrigin-RevId: 0a954e234f3217d60c4eee0a44a119590f3b517a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1f71eff0df
commit
7eec197140
+54
-50
@@ -633,25 +633,27 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
File output = FileUtil.createTempFile("output", "");
|
||||
FileUtilRt.createParentDirs(output);
|
||||
handler.setResult(new StreamResult(new FileWriter(output, StandardCharsets.UTF_8)));
|
||||
MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
|
||||
TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
|
||||
try (FileWriter writer = new FileWriter(output, StandardCharsets.UTF_8)) {
|
||||
handler.setResult(new StreamResult(writer));
|
||||
MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
|
||||
TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
|
||||
String savedText = FileUtil.loadFile(output);
|
||||
assertTrue(savedText.split("\n").length > 550);
|
||||
|
||||
String savedText = FileUtil.loadFile(output);
|
||||
assertTrue(savedText.split("\n").length > 550);
|
||||
myEventsProcessor.onStartTesting();
|
||||
ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
myEventsProcessor.onStartTesting();
|
||||
ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
|
||||
myEventsProcessor.onFinishTesting();
|
||||
List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
|
||||
assertSize(1, children);
|
||||
SMTestProxy testProxy = children.get(0);
|
||||
MockPrinter mockPrinter = new MockPrinter();
|
||||
testProxy.printOn(mockPrinter);
|
||||
String allOut = mockPrinter.getAllOut();
|
||||
assertSize(559, allOut.split("\n"));
|
||||
assertTrue(allOut.contains("a < b"));
|
||||
}
|
||||
|
||||
List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
|
||||
assertSize(1, children);
|
||||
SMTestProxy testProxy = children.get(0);
|
||||
MockPrinter mockPrinter = new MockPrinter();
|
||||
testProxy.printOn(mockPrinter);
|
||||
String allOut = mockPrinter.getAllOut();
|
||||
assertSize(559, allOut.split("\n"));
|
||||
assertTrue(allOut.contains("a < b"));
|
||||
}
|
||||
|
||||
public void testComparisonFailureImport() throws Exception {
|
||||
@@ -668,42 +670,44 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
|
||||
handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
File output = FileUtil.createTempFile("output", "");
|
||||
FileUtilRt.createParentDirs(output);
|
||||
handler.setResult(new StreamResult(new FileWriter(output, StandardCharsets.UTF_8)));
|
||||
MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
|
||||
TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
|
||||
try (FileWriter writer = new FileWriter(output, StandardCharsets.UTF_8)) {
|
||||
handler.setResult(new StreamResult(writer));
|
||||
MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
|
||||
TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
|
||||
|
||||
String savedText = FileUtil.loadFile(output);
|
||||
assertTrue(StringUtil.convertLineSeparators(savedText)
|
||||
.endsWith("<count name=\"total\" value=\"1\"/>\n" +
|
||||
" <count name=\"failed\" value=\"1\"/>\n" +
|
||||
" <config configId=\"MockRuntimeConfiguration\" name=\"\">\n" +
|
||||
" <method v=\"2\"/>\n" +
|
||||
" </config>\n" +
|
||||
" <test locationUrl=\"file://test.text\" name=\"test\" status=\"failed\">\n" +
|
||||
" <diff actual=\"actual\" expected=\"expected\"/>\n" +
|
||||
" <output type=\"stdout\">message\n" +
|
||||
"</output>\n" +
|
||||
" <output type=\"stderr\">localizedstacktrace\n" +
|
||||
"</output>\n" +
|
||||
" </test>\n" +
|
||||
"</testrun>\n"));
|
||||
String savedText = FileUtil.loadFile(output);
|
||||
assertTrue(StringUtil.convertLineSeparators(savedText)
|
||||
.endsWith("<count name=\"total\" value=\"1\"/>\n" +
|
||||
" <count name=\"failed\" value=\"1\"/>\n" +
|
||||
" <config configId=\"MockRuntimeConfiguration\" name=\"\">\n" +
|
||||
" <method v=\"2\"/>\n" +
|
||||
" </config>\n" +
|
||||
" <test locationUrl=\"file://test.text\" name=\"test\" status=\"failed\">\n" +
|
||||
" <diff actual=\"actual\" expected=\"expected\"/>\n" +
|
||||
" <output type=\"stdout\">message\n" +
|
||||
"</output>\n" +
|
||||
" <output type=\"stderr\">localizedstacktrace\n" +
|
||||
"</output>\n" +
|
||||
" </test>\n" +
|
||||
"</testrun>\n"));
|
||||
|
||||
myEventsProcessor.onStartTesting();
|
||||
ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
|
||||
myEventsProcessor.onFinishTesting();
|
||||
myEventsProcessor.onStartTesting();
|
||||
ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
|
||||
myEventsProcessor.onFinishTesting();
|
||||
|
||||
List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
|
||||
assertSize(1, children);
|
||||
SMTestProxy testProxy = children.get(0);
|
||||
MockPrinter mockPrinter = new MockPrinter();
|
||||
testProxy.printOn(mockPrinter);
|
||||
assertEquals("message\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"Expected :expected\n" +
|
||||
"Actual :actual\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"localizedstacktrace", StringUtil.convertLineSeparators(mockPrinter.getAllOut().trim()));
|
||||
List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
|
||||
assertSize(1, children);
|
||||
SMTestProxy testProxy = children.get(0);
|
||||
MockPrinter mockPrinter = new MockPrinter();
|
||||
testProxy.printOn(mockPrinter);
|
||||
assertEquals("message\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"Expected :expected\n" +
|
||||
"Actual :actual\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"localizedstacktrace", StringUtil.convertLineSeparators(mockPrinter.getAllOut().trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user