File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/test/java/com/adobe/campaign/tests/logparser/utils Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -242,4 +242,24 @@ public void testExportAnomalyReport_WhenFileExists() throws IOException {
242242 assertThat ("Should not have old content" ,
243243 report .containsKey ("test" ), is (false ));
244244 }
245+
246+ @ Test
247+ public void testExportAnomalyReport_WhenIOExceptionOccurs () throws IOException {
248+ // Create some anomalies
249+ ParseGuardRails .HEAP_LIMIT = 1 ;
250+ ParseGuardRails .HEAP_SIZE_AT_START = -20 ;
251+ ParseGuardRails .checkMemoryLimits ();
252+
253+ // Create a file that will cause an IOException when trying to write
254+ File reportFile = new File (ANOMALY_REPORT_PATH );
255+ reportFile .createNewFile ();
256+ reportFile .setReadOnly ();
257+
258+ // This should log an error but not throw an exception
259+ ParseGuardRails .exportAnomalyReport ();
260+
261+ // Clean up
262+ reportFile .setWritable (true );
263+ reportFile .delete ();
264+ }
245265}
You can’t perform that action at this time.
0 commit comments