}
if (fetching) {
core.lockSone(sone);
- FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).setMetaString(new String[] { "sone.xml" });
+ FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + getNextEdition()).setMetaString(new String[] { "sone.xml" });
System.out.println("URI: " + soneUri);
Sone fetchedSone = soneDownloader.fetchSone(sone, soneUri, true);
System.out.println("Sone: " + fetchedSone);
public class SoneRescuerTest {
private static final long CURRENT_EDITION = 12L;
- private static final long SOME_OTHER_EDITION = 15L;
private final Core core = mock(Core.class);
private final SoneDownloader soneDownloader = mock(SoneDownloader.class);
private final Sone sone = mock(Sone.class);
}
@Test
- public void currentEditionCanBeSet() {
- soneRescuer.setEdition(SOME_OTHER_EDITION);
- assertThat(soneRescuer.getCurrentEdition(), is(SOME_OTHER_EDITION));
- }
-
- @Test
public void lastFetchOfANewSoneRescuerWasSuccessful() {
assertThat(soneRescuer.isLastFetchSuccessful(), is(true));
}
FreenetURI keyWithDocName = mock(FreenetURI.class);
FreenetURI keyWithMetaStrings = mock(FreenetURI.class);
when(keyWithDocName.setMetaString(eq(new String[] { "sone.xml" }))).thenReturn(keyWithMetaStrings);
- when(sskKey.setDocName(eq("Sone-" + CURRENT_EDITION))).thenReturn(keyWithDocName);
+ when(sskKey.setDocName(eq("Sone-" + (CURRENT_EDITION - 1)))).thenReturn(keyWithDocName);
when(sone.getRequestUri().setKeyType(eq("SSK"))).thenReturn(sskKey);
return keyWithMetaStrings;
}