cache: try-with-resources the rest of the Stores in tests

This commit is contained in:
Adam
2017-03-26 12:35:27 -04:00
parent 7146d4da93
commit cdbbe9f5d4
5 changed files with 85 additions and 72 deletions

View File

@@ -46,7 +46,8 @@ public class NpcDumperTest
File dumpDir = folder.newFolder(), File dumpDir = folder.newFolder(),
javaDir = folder.newFolder(); javaDir = folder.newFolder();
Store store = new Store(StoreLocation.LOCATION); try (Store store = new Store(StoreLocation.LOCATION))
{
store.load(); store.load();
NpcDumper dumper = new NpcDumper( NpcDumper dumper = new NpcDumper(
@@ -57,6 +58,7 @@ public class NpcDumperTest
dumper.load(); dumper.load();
dumper.dump(); dumper.dump();
dumper.java(); dumper.java();
}
logger.info("Dumped to {}, java {}", dumpDir, javaDir); logger.info("Dumped to {}, java {}", dumpDir, javaDir);
} }

View File

@@ -46,7 +46,8 @@ public class ObjectDumperTest
File dumpDir = folder.newFolder(), File dumpDir = folder.newFolder(),
javaDir = folder.newFolder(); javaDir = folder.newFolder();
Store store = new Store(StoreLocation.LOCATION); try (Store store = new Store(StoreLocation.LOCATION))
{
store.load(); store.load();
ObjectDumper dumper = new ObjectDumper( ObjectDumper dumper = new ObjectDumper(
@@ -57,6 +58,7 @@ public class ObjectDumperTest
dumper.load(); dumper.load();
dumper.dump(); dumper.dump();
dumper.java(); dumper.java();
}
logger.info("Dumped to {}, java {}", dumpDir, javaDir); logger.info("Dumped to {}, java {}", dumpDir, javaDir);
} }

View File

@@ -49,7 +49,8 @@ public class CacheClientTest
@Ignore @Ignore
public void test() throws Exception public void test() throws Exception
{ {
Store store = new Store(new File("d:/temp")); try (Store store = new Store(new File("d:/temp")))
{
store.load(); store.load();
CacheClient c = new CacheClient(store); CacheClient c = new CacheClient(store);
@@ -67,12 +68,14 @@ public class CacheClientTest
store.save(); store.save();
} }
}
@Test @Test
@Ignore @Ignore
public void testTree() throws Exception public void testTree() throws Exception
{ {
Store store = new Store(new File("C:\\rs\\temp")); try (Store store = new Store(new File("C:\\rs\\temp")))
{
store.loadTree(new File("C:\\rs\\runescape-data\\cache")); store.loadTree(new File("C:\\rs\\runescape-data\\cache"));
CacheClient c = new CacheClient(store); CacheClient c = new CacheClient(store);
@@ -91,3 +94,4 @@ public class CacheClientTest
store.saveTree(new File("C:\\rs\\temp\\t")); store.saveTree(new File("C:\\rs\\temp\\t"));
} }
} }
}

View File

@@ -29,7 +29,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import net.runelite.cache.StoreLocation; import net.runelite.cache.StoreLocation;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
@@ -40,10 +39,11 @@ public class IndexFileTest
public TemporaryFolder folder = StoreLocation.getTemporaryFolder(); public TemporaryFolder folder = StoreLocation.getTemporaryFolder();
@Test @Test
public void test1() throws IOException public void test() throws IOException
{ {
File file = folder.newFile(); File file = folder.newFile();
Store store = new Store(folder.getRoot()); try (Store store = new Store(folder.getRoot()))
{
IndexFile index = new IndexFile(store, 5, file); IndexFile index = new IndexFile(store, 5, file);
IndexEntry entry = new IndexEntry(index, 7, 8, 9); IndexEntry entry = new IndexEntry(index, 7, 8, 9);
index.write(entry); index.write(entry);
@@ -51,3 +51,4 @@ public class IndexFileTest
Assert.assertEquals(entry, entry2); Assert.assertEquals(entry, entry2);
} }
} }
}

View File

@@ -52,7 +52,8 @@ public class StoreLoadTest
@Test @Test
public void testSave() throws IOException public void testSave() throws IOException
{ {
Store store = new Store(StoreLocation.LOCATION); try (Store store = new Store(StoreLocation.LOCATION))
{
store.load(); store.load();
java.io.File testStoreFile = folder.newFolder(); java.io.File testStoreFile = folder.newFolder();
@@ -61,7 +62,8 @@ public class StoreLoadTest
Files.copy(f, new java.io.File(testStoreFile, f.getName())); Files.copy(f, new java.io.File(testStoreFile, f.getName()));
} }
Store testStore = new Store(testStoreFile); try (Store testStore = new Store(testStoreFile))
{
testStore.load(); testStore.load();
Assert.assertTrue(store.equals(testStore)); Assert.assertTrue(store.equals(testStore));
@@ -71,6 +73,8 @@ public class StoreLoadTest
Assert.assertTrue(store.equals(testStore)); Assert.assertTrue(store.equals(testStore));
} }
}
}
@Test @Test
@Ignore @Ignore