Repository: cassandra Updated Branches: refs/heads/trunk e7064b2d4 -> eaa06942a
fail fast if the system property 'legacy-sstable-root' is not set properly Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/eaa06942 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eaa06942 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eaa06942 Branch: refs/heads/trunk Commit: eaa06942a6b5f54fb72bc7fe53d469cd034c2106 Parents: e7064b2 Author: Dave Brosius <dbros...@mebigfatguy.com> Authored: Sat Jul 23 20:52:07 2016 -0400 Committer: Dave Brosius <dbros...@mebigfatguy.com> Committed: Sat Jul 23 20:52:07 2016 -0400 ---------------------------------------------------------------------- .../cassandra/io/sstable/LegacySSTableTest.java | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/eaa06942/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java b/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java index 9a37f66..cc2011f 100644 --- a/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java +++ b/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java @@ -90,6 +90,12 @@ public class LegacySSTableTest @BeforeClass public static void defineSchema() throws ConfigurationException { + String scp = System.getProperty(LEGACY_SSTABLE_PROP); + Assert.assertNotNull("System property " + LEGACY_SSTABLE_ROOT + " not set", scp); + + LEGACY_SSTABLE_ROOT = new File(scp).getAbsoluteFile(); + Assert.assertTrue("System property " + LEGACY_SSTABLE_ROOT + " does not specify a directory", LEGACY_SSTABLE_ROOT.isDirectory()); + SchemaLoader.prepareServer(); StorageService.instance.initServer(); Keyspace.setInitialized(); @@ -98,10 +104,7 @@ public class LegacySSTableTest { createTables(legacyVersion); } - String scp = System.getProperty(LEGACY_SSTABLE_PROP); - assert scp != null; - LEGACY_SSTABLE_ROOT = new File(scp).getAbsoluteFile(); - assert LEGACY_SSTABLE_ROOT.isDirectory(); + } @After @@ -454,7 +457,9 @@ public class LegacySSTableTest private static void copySstablesToTestData(String legacyVersion, String table, File cfDir) throws IOException { - for (File file : getTableDir(legacyVersion, table).listFiles()) + File tableDir = getTableDir(legacyVersion, table); + Assert.assertTrue("The table directory " + tableDir + " was not found", tableDir.isDirectory()); + for (File file : tableDir.listFiles()) { copyFile(cfDir, file); } @@ -472,10 +477,11 @@ public class LegacySSTableTest { File target = new File(cfDir, file.getName()); int rd; - FileInputStream is = new FileInputStream(file); - FileOutputStream os = new FileOutputStream(target); - while ((rd = is.read(buf)) >= 0) - os.write(buf, 0, rd); + try (FileInputStream is = new FileInputStream(file); + FileOutputStream os = new FileOutputStream(target);) { + while ((rd = is.read(buf)) >= 0) + os.write(buf, 0, rd); + } } } }