@Test public void shouldTakeDirectoryLocationFromConfig() throws Exception { String expected = testDirectory.directory().getAbsolutePath(); addProperty(Configurator.RRDB_LOCATION_PROPERTY_KEY, expected); TestableRrdFactory factory = createRrdFactory(); factory.createRrdDbAndSampler(db, new NullJobScheduler()); assertThat(factory.directoryUsed, is(expected)); }
@Test public void shouldCreateRrdFileInTempLocationForImpermanentDatabases() throws IOException { // Given String expected = testDirectory.directory().getAbsolutePath(); TestableRrdFactory factory = createRrdFactory(expected); // When factory.createRrdDbAndSampler(db, new NullJobScheduler()); // Then assertThat(factory.directoryUsed, is(expected)); }
@Test public void shouldCreateRrdFileInDbSubdirectory() throws Exception { String storeDir = testDirectory.directory().getAbsolutePath(); db = new WrappedDatabase( (InternalAbstractGraphDatabase) new TestGraphDatabaseFactory().newEmbeddedDatabase(storeDir)); TestableRrdFactory factory = createRrdFactory(); // When factory.createRrdDbAndSampler(db, new NullJobScheduler()); // Then String rrdParent = new File(factory.directoryUsed).getParent(); assertThat(rrdParent, is(storeDir)); }
@Test public void shouldMoveAwayInvalidRrdFile() throws IOException { // Given String expected = new File(testDirectory.directory(), "rrd-test").getAbsolutePath(); addProperty(Configurator.RRDB_LOCATION_PROPERTY_KEY, expected); TestableRrdFactory factory = createRrdFactory(); createInvalidRrdFile(expected); // When RrdDbWrapper rrdDbAndSampler = factory.createRrdDbAndSampler(db, new NullJobScheduler()); // Then assertSubdirectoryExists("rrd-test-invalid", factory.directoryUsed); rrdDbAndSampler.close(); }