139 IOResource firstJfr = jfrs.iterator().next();
140 jfrs = new IOResourceSet(firstJfr);
141 reportName = firstJfr.getName();
142 }
143 // Run all the .jfr files in the directory through the rule engine
144 ReportCollection rulesReport = generateRulesReport(jfrs);
145
146 // Parse the baseline XML file
147 ReportCollection baselineReport = parseRulesReportXml(BASELINE_DIR, JFR_RULE_BASELINE_JFR, reportName);
148
149 // Compare the baseline with the current rule results
150 boolean resultsEqual = rulesReport.compareAndLog(baselineReport);
151
152 // Save file for later inspection and/or updating the baseline with
153 if (!resultsEqual) {
154 // Save the generated file to XML
155 saveToFile(rulesReport.toXml(), BASELINE_DIR, JFR_RULE_BASELINE_JFR, onlyOneRecording);
156 }
157
158 // Assert that the comparison returned true
159 Assert.assertTrue(DetailsTracker.getEntries(), resultsEqual);
160 }
161
162 private static void saveToFile(Document doc, String directory, String fileName, boolean onlyOneRecording) {
163 String filePath = getResultDir().getAbsolutePath() + File.separator
164 + ((directory != null) ? (directory + File.separator) : "")
165 + (onlyOneRecording ? "Generated_One_" : "Generated_") + fileName;
166 File resultFile = new File(filePath);
167 prepareFile(resultFile);
168 try {
169 writeDomToStream(doc, new FileOutputStream(resultFile));
170 } catch (FileNotFoundException e) {
171 e.printStackTrace();
172 }
173 }
174
175 private static void prepareFile(File file) {
176 if (file.exists()) {
177 file.delete();
178 }
179 File parent = file.getParentFile();
|
139 IOResource firstJfr = jfrs.iterator().next();
140 jfrs = new IOResourceSet(firstJfr);
141 reportName = firstJfr.getName();
142 }
143 // Run all the .jfr files in the directory through the rule engine
144 ReportCollection rulesReport = generateRulesReport(jfrs);
145
146 // Parse the baseline XML file
147 ReportCollection baselineReport = parseRulesReportXml(BASELINE_DIR, JFR_RULE_BASELINE_JFR, reportName);
148
149 // Compare the baseline with the current rule results
150 boolean resultsEqual = rulesReport.compareAndLog(baselineReport);
151
152 // Save file for later inspection and/or updating the baseline with
153 if (!resultsEqual) {
154 // Save the generated file to XML
155 saveToFile(rulesReport.toXml(), BASELINE_DIR, JFR_RULE_BASELINE_JFR, onlyOneRecording);
156 }
157
158 // Assert that the comparison returned true
159 // FIXME : JMC-6072
160 // Assert.assertTrue(DetailsTracker.getEntries(), resultsEqual);
161 }
162
163 private static void saveToFile(Document doc, String directory, String fileName, boolean onlyOneRecording) {
164 String filePath = getResultDir().getAbsolutePath() + File.separator
165 + ((directory != null) ? (directory + File.separator) : "")
166 + (onlyOneRecording ? "Generated_One_" : "Generated_") + fileName;
167 File resultFile = new File(filePath);
168 prepareFile(resultFile);
169 try {
170 writeDomToStream(doc, new FileOutputStream(resultFile));
171 } catch (FileNotFoundException e) {
172 e.printStackTrace();
173 }
174 }
175
176 private static void prepareFile(File file) {
177 if (file.exists()) {
178 file.delete();
179 }
180 File parent = file.getParentFile();
|