Beispiel #1
0
 @Test
 public void shouldLoadDiskDumpFromStorageRoot() throws IOException, ClassNotFoundException {
   baseDir.mkdirs();
   File file = new File(baseDir, EntryRepoFactory.name("foo", LATEST_VERSION, SUBSET_SIZE));
   FileUtils.writeStringToFile(file, "1\n2\n3\n");
   SubsetSizeRepo repo = factory.createSubsetRepo("foo", LATEST_VERSION);
   assertThat(
       repo.list(),
       is(
           (Collection<SubsetSizeEntry>)
               Arrays.asList(
                   new SubsetSizeEntry(1), new SubsetSizeEntry(2), new SubsetSizeEntry(3))));
 }
Beispiel #2
0
 @Test
 public void shouldNotLoadDiskDumpWhenUsingARepoThatIsAlreadyCreated()
     throws ClassNotFoundException, IOException {
   SubsetSizeRepo fooRepo = factory.createSubsetRepo("foo", LATEST_VERSION);
   File file = new File(baseDir, EntryRepoFactory.name("foo", LATEST_VERSION, SUBSET_SIZE));
   ObjectOutputStream outStream = new ObjectOutputStream(new FileOutputStream(file));
   outStream.writeObject(
       new ArrayList<SubsetSizeEntry>(
           Arrays.asList(new SubsetSizeEntry(1), new SubsetSizeEntry(2), new SubsetSizeEntry(3))));
   outStream.close();
   assertThat(fooRepo.list().size(), is(0));
   assertThat(factory.createSubsetRepo("foo", LATEST_VERSION).list().size(), is(0));
 }
Beispiel #3
0
 @Test
 public void shouldUseWorkingDirAsDiskStorageRootWhenNotGiven()
     throws IOException, ClassNotFoundException {
   final File workingDirStorage = new File(TlbConstants.Server.DEFAULT_TLB_DATA_DIR);
   workingDirStorage.mkdirs();
   File file =
       new File(workingDirStorage, EntryRepoFactory.name("foo", LATEST_VERSION, SUBSET_SIZE));
   FileUtils.writeStringToFile(file, "1\n2\n3\n");
   EntryRepoFactory factory =
       new EntryRepoFactory(new SystemEnvironment(new HashMap<String, String>()));
   SubsetSizeRepo repo = factory.createSubsetRepo("foo", LATEST_VERSION);
   assertThat(
       repo.list(),
       is(
           (Collection<SubsetSizeEntry>)
               Arrays.asList(
                   new SubsetSizeEntry(1), new SubsetSizeEntry(2), new SubsetSizeEntry(3))));
 }