Source:
public void afterTestMethod(TestContext testContext) throws Exception { JUnitCollector config = findCollectorAnnotation(testContext); if (config == null) { return; } boolean shouldIgnoreNonExistent = testContext.getTestException() != null; if (config.anticipateRrds().length > 0) { for (String rrdFile : config.anticipateRrds()) { m_fileAnticipator.expectingFileWithPrefix(m_snmpRrdDirectory, rrdFile, ".meta"); if (config.anticipateMetaFiles()) { m_fileAnticipator.expecting(m_snmpRrdDirectory, rrdFile + ".meta"); } } } if (config.anticipateFiles().length > 0) { for (String file : config.anticipateFiles()) { m_fileAnticipator.expecting(m_snmpRrdDirectory, file); } } Exception e = null; if (m_fileAnticipator.isInitialized()) { final long finished = System.currentTimeMillis() + config.timeout(); while (System.currentTimeMillis() <= finished) { if (m_fileAnticipator.foundExpected()) { break; } try { Thread.sleep(200); } catch (final InterruptedException ie) { break; } } try { m_fileAnticipator.deleteExpected(shouldIgnoreNonExistent); } catch (Throwable t) { e = new RuntimeException(t); } } try { FileUtils.deleteDirectory(m_snmpRrdDirectory); } catch (Exception deletionException) { deletionException.printStackTrace(); String os = System.getProperty("os.name"); if (os == null || !os.contains("Windows")) { throw deletionException; } } m_fileAnticipator.tearDown(); if (e != null) { throw e; } }

Target:
public void afterTestMethod(TestContext testContext) throws Exception { JUnitCollector config = findCollectorAnnotation(testContext); if (config == null) { return; } boolean shouldIgnoreNonExistent = testContext.getTestException() != null; if (config.anticipateRrds().length > 0) { for (String rrdFile : config.anticipateRrds()) { m_fileAnticipator.expectingFileWithPrefix(m_snmpRrdDirectory, rrdFile, ".meta"); if (config.anticipateMetaFiles()) { m_fileAnticipator.expecting(m_snmpRrdDirectory, rrdFile + ".meta"); } } } if (config.anticipateFiles().length > 0) { for (String file : config.anticipateFiles()) { m_fileAnticipator.expecting(m_snmpRrdDirectory, file); } } Exception e = null; if (m_fileAnticipator.isInitialized()) { final long finished = System.currentTimeMillis() + config.timeout(); while (System.currentTimeMillis() <= finished) { if (m_fileAnticipator.foundExpected()) { break; } try { Thread.sleep(200); } catch (final InterruptedException ie) { break; } } try { m_fileAnticipator.deleteExpected(shouldIgnoreNonExistent); } catch (Throwable t) { e = new RuntimeException(t); } } try { FileUtils.deleteDirectory(m_snmpRrdDirectory); } catch (IOException deleteDirectoryException) { LOG.warn("Failed to delete during cleanup.", m_snmpRrdDirectory, deleteDirectoryException); String os = System.getProperty("os.name"); if (os == null || !os.contains("Windows")) { throw deleteDirectoryException; } } try { m_fileAnticipator.tearDown(); } catch (RuntimeException anticipatorTeardownException) { LOG.warn("Failed to delete during cleanup.", m_fileAnticipator.getTempDir(), anticipatorTeardownException); String os = System.getProperty("os.name"); if (os == null || !os.contains("Windows")) { throw anticipatorTeardownException; } } if (e != null) { throw e; } }