From fe9f4dae729fa402178990dc717f0ca8d5f5cdb0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 Jul 2014 16:04:37 +0200 Subject: [PATCH] Increase test coverage. --- .../pterodactylus/sone/core/UpdateCheckerTest.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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); + } + } -- 2.7.4