@After public void tearDown() throws Exception { EasyMock.verify(m_filterDao); m_fileAnticipator.deleteExpected(true); m_fileAnticipator.tearDown(); }
public static File anticipatePath(FileAnticipator fa, File rootDir, String... pathElements) { File parent = rootDir; assertTrue(pathElements.length > 0); for (String pathElement : pathElements) { parent = fa.expecting(parent, pathElement); } return parent; }
if (!isInitialized()) { return; deleteExpected(true); fail(b.toString()); assertFalse(m_tempDir + " exists", m_tempDir.exists());
assertInitialized(); List<Path> matches = getMatches(f); if (matches.size() < 1 && !ignoreNonExistantFiles) { errors.add("Expected prefix that needs to be deleted does not exist: " + f.getAbsolutePath()); assertEquals("No expected files left over", m_expecting.size(), 0); if (errors.size() > 0) { StringBuffer errorString = new StringBuffer(); errorString.append(error).append("\n"); fail("Errors occurred inside FileAnticipator:\n" + errorString.toString().trim());
m_fileAnticipator.expectingFileWithPrefix(m_snmpRrdDirectory, rrdFile, ".meta"); m_fileAnticipator.expecting(m_snmpRrdDirectory, rrdFile + ".meta"); m_fileAnticipator.expecting(m_snmpRrdDirectory, file); if (m_fileAnticipator.isInitialized()) { final long finished = System.currentTimeMillis() + config.timeout(); while (System.currentTimeMillis() <= finished) { if (m_fileAnticipator.foundExpected()) { break; m_fileAnticipator.deleteExpected(shouldIgnoreNonExistent); } catch (Throwable t) { e = new RuntimeException(t); m_fileAnticipator.tearDown();
@Test public void generateSchema() throws Exception { File schemaFile = fa.expecting("foreign-sources.xsd"); c.generateSchema(new TestOutputResolver(schemaFile)); if (fa.isInitialized()) { fa.deleteExpected(); } }
@Override public void beforeTestMethod(TestContext testContext) throws Exception { m_fileAnticipator = new FileAnticipator(); m_snmpRrdDirectory = m_fileAnticipator.tempDir("snmp"); m_snmpRrdDirectory.mkdirs(); testContext.setAttribute("fileAnticipator", m_fileAnticipator);
@Test public void testPersistStringAttributeWithParentDirectory() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.tempDir(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.expecting(nodeDir, RrdResourceAttributeUtils.STRINGS_PROPERTIES_FILE_NAME); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }
/** * Delete expected files, throwing an AssertionFailedError if any of * the expected files don't exist. */ public void deleteExpected() { deleteExpected(false); }
m_fileAnticipator = new FileAnticipator(); m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
/** * <p>tempDir</p> * * @param name a {@link java.lang.String} object. * @return a {@link java.io.File} object. * @throws java.io.IOException if any. */ public File tempDir(String name) throws IOException { if (name == null) { throw new IllegalArgumentException("name argument cannot be null"); } return tempDir(m_tempDir, name); }
@Before public void setUp() throws IOException { m_fileAnticipator = new FileAnticipator(); }
/** {@inheritDoc} * @throws Throwable */ @Override protected void finalize() throws Throwable { tearDown(); super.finalize(); }
@Test public void testPersistStringAttributeWithExistingPropertiesFile() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.tempDir(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.tempFile(nodeDir, RrdResourceAttributeUtils.STRINGS_PROPERTIES_FILE_NAME, "#just a test"); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }
private void assertInitialized() { if (!isInitialized()) { throw new IllegalStateException("not initialized"); } }
m_fileAnticipator.expectingFileWithPrefix(m_snmpRrdDirectory, rrdFile, ".meta"); m_fileAnticipator.expecting(m_snmpRrdDirectory, rrdFile + ".meta"); m_fileAnticipator.expecting(m_snmpRrdDirectory, file); if (m_fileAnticipator.isInitialized()) { final long finished = System.currentTimeMillis() + config.timeout(); while (System.currentTimeMillis() <= finished) { if (m_fileAnticipator.foundExpected()) { break; m_fileAnticipator.deleteExpected(shouldIgnoreNonExistent); } catch (Throwable t) { e = new RuntimeException(t); m_fileAnticipator.tearDown();
@Override public void beforeTestMethod(TestContext testContext) throws Exception { m_fileAnticipator = new FileAnticipator(); m_snmpRrdDirectory = m_fileAnticipator.tempDir("snmp"); m_snmpRrdDirectory.mkdirs(); testContext.setAttribute("fileAnticipator", m_fileAnticipator);
@After public void checkWarnings() throws Throwable { // MockLogAppender.assertNoWarningsOrGreater(); m_fileAnticipator.deleteExpected(); }
m_fileAnticipator = new FileAnticipator(); m_hrStorageProperties = new HashMap<Integer, File>(); m_resourceStorageDao.setRrdDirectory(new File(m_fileAnticipator.getTempDir(), "snmp"));
private File getSnmpRrdDirectory() throws IOException { if (m_snmpDirectory == null) { m_snmpDirectory = m_fileAnticipator.tempDir("snmp"); } return m_snmpDirectory; } }