@Test(expected = ProtocolVersion.InvalidFrameException.class) public void Protocol_should_refuse_bad_greetings_frame_3() throws ProtocolVersion.InvalidFrameException, ProtocolVersion.InvalidProtocolVersionException { byte[] bad = new byte[]{0, 0, 3, 1}; ProtocolVersion.checkVersion(bad); }
public static void checkVersion(byte[] greetings) throws InvalidFrameException, InvalidProtocolVersionException { if (greetings[0] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[1] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[2] != 'V') throw new InvalidFrameException("cannot extract version from server greetings"); if (!AUTHORIZED_RELEASE.contains(greetings[3])) { throw new InvalidProtocolVersionException(VERSION, greetings[3]); } }
ProtocolVersion { public static void checkVersion(byte[] greetings) throws InvalidFrameException, InvalidProtocolVersionException { if (greetings[0] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[1] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[2] != 'V') throw new InvalidFrameException("cannot extract version from server greetings"); if (!AUTHORIZED_RELEASE.contains(greetings[3])) { throw new InvalidProtocolVersionException(VERSION, greetings[3]); } } }
ProtocolVersion { public static void checkVersion(byte[] greetings) throws InvalidFrameException, InvalidProtocolVersionException { if (greetings[0] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[1] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[2] != 'V') throw new InvalidFrameException("cannot extract version from server greetings"); if (!AUTHORIZED_RELEASE.contains(greetings[3])) { throw new InvalidProtocolVersionException(VERSION, greetings[3]); } } protected  ProtocolVersion(); }
ProtocolVersion { public static void checkVersion(byte[] greetings) throws InvalidFrameException, InvalidProtocolVersionException { if (greetings[0] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[1] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[2] != 'V') throw new InvalidFrameException("cannot extract version from server greetings"); if (!AUTHORIZED_RELEASE.contains(greetings[3])) { throw new InvalidProtocolVersionException(VERSION, greetings[3]); } } protected  ProtocolVersion(); static void checkVersion(byte[] greetings); }
ProtocolVersion { public static void checkVersion(byte[] greetings) throws InvalidFrameException, InvalidProtocolVersionException { if (greetings[0] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[1] != 0) throw new InvalidFrameException("cannot extract version from server greetings"); if (greetings[2] != 'V') throw new InvalidFrameException("cannot extract version from server greetings"); if (!AUTHORIZED_RELEASE.contains(greetings[3])) { throw new InvalidProtocolVersionException(VERSION, greetings[3]); } } protected  ProtocolVersion(); static void checkVersion(byte[] greetings); static final byte VERSION; static final byte[] GREETINGS; }