From: David ‘Bombe’ Roden Date: Wed, 30 Jul 2014 14:04:37 +0000 (+0200) Subject: Increase test coverage. X-Git-Tag: 0.9-rc1^2~3^2~193 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fe9f4dae729fa402178990dc717f0ca8d5f5cdb0;p=Sone.git Increase test coverage. --- diff --git a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java index fb2b9f2..b3f8c08 100644 --- a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java +++ b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java @@ -93,6 +93,7 @@ public class UpdateCheckerTest { assertThat(updateFoundEvent.getValue().releaseTime(), is(11865368297000L)); assertThat(updateChecker.getLatestVersion(), is(new Version(99, 0, 0))); assertThat(updateChecker.getLatestVersionDate(), is(11865368297000L)); + assertThat(updateChecker.hasLatestVersion(), is(true)); } private FetchResult createFutureFetchResult() { @@ -198,4 +199,35 @@ public class UpdateCheckerTest { return new FetchResult(clientMetadata, fetched); } + @Test + public void invalidPropertiesDoesNotCauseAnUpdateToBeFound() { + setupFetchResult(createMissingTimeFetchResult()); + setupCallbackWithEdition(MAX_VALUE, true, false); + verifyAFreenetUriIsFetched(); + verifyNoUpdateFoundEventIsFired(); + } + + private FetchResult createMissingTimeFetchResult() { + ClientMetadata clientMetadata = new ClientMetadata("application/xml"); + Bucket fetched = new StringBucket("# MapConfigurationBackendVersion=1\n" + + "CurrentVersion/Version: 0.2\n"); + return new FetchResult(clientMetadata, fetched); + } + + @Test + public void invalidVersionDoesNotCauseAnUpdateToBeFound() { + setupFetchResult(createInvalidVersionFetchResult()); + setupCallbackWithEdition(MAX_VALUE, true, false); + verifyAFreenetUriIsFetched(); + verifyNoUpdateFoundEventIsFired(); + } + + private FetchResult createInvalidVersionFetchResult() { + ClientMetadata clientMetadata = new ClientMetadata("application/xml"); + Bucket fetched = new StringBucket("# MapConfigurationBackendVersion=1\n" + + "CurrentVersion/Version: foo\n" + + "CurrentVersion/ReleaseTime: 1289417883000"); + return new FetchResult(clientMetadata, fetched); + } + }