Throw a different exception if a Sone is too new.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 25 Oct 2013 05:20:11 +0000 (07:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:38 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/core/SoneParser.java
src/test/java/net/pterodactylus/sone/core/SoneParserTest.java

index a658ae1..98af5b6 100644 (file)
@@ -97,7 +97,7 @@ public class SoneParser {
                        }
                        if (protocolVersion.get() > MAX_PROTOCOL_VERSION) {
                                logger.log(Level.WARNING, String.format("Unknown protocol version: %d! Not parsing Sone.", protocolVersion.get()));
-                               throw new InvalidProtocolVersion();
+                               throw new SoneTooNew();
                        }
                }
 
@@ -338,6 +338,10 @@ public class SoneParser {
 
        }
 
+       public static class SoneTooNew extends RuntimeException {
+
+       }
+
        public static class MalformedXml extends RuntimeException {
 
        }
index e785a4d..03bce54 100644 (file)
@@ -24,6 +24,7 @@ import net.pterodactylus.sone.core.SoneParser.InvalidXml;
 import net.pterodactylus.sone.core.SoneParser.MalformedDimension;
 import net.pterodactylus.sone.core.SoneParser.MalformedTime;
 import net.pterodactylus.sone.core.SoneParser.MalformedXml;
+import net.pterodactylus.sone.core.SoneParser.SoneTooNew;
 import net.pterodactylus.sone.data.Client;
 import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Post;
@@ -76,7 +77,7 @@ public class SoneParserTest {
                soneParser.parseSone(database, originalSone, getXml("negative-protocol-version"));
        }
 
-       @Test(expected = InvalidProtocolVersion.class)
+       @Test(expected = SoneTooNew.class)
        public void verifyThatATooLargeProtocolVersionCausesAnError() {
                soneParser.parseSone(database, originalSone, getXml("too-large-protocol-version"));
        }