### Question:
Authentication extends PGMessage { public static Authentication loadFromPacket(byte[] packet) { PGProto proto = new PGProto(packet, 5); AuthType authType = AuthType.getAuthType(proto.readInt32()); switch (authType) { case AuthenticationMD5Password: return AuthenticationMD5Password.loadFromPacket(packet); case AuthenticationOk: return AuthenticationOk.loadFromPacket(packet); default: throw new IllegalArgumentException("not implement auth method " + authType); } } Authentication(AuthType authType); static Authentication loadFromPacket(byte[] packet);  }### Answer:
@Test public void testLoadFromPacket() throws Exception { Authentication md5Auth = Authentication.loadFromPacket(md5Packet); assertTrue(md5Auth instanceof AuthenticationMD5Password); Authentication okAuth = Authentication.loadFromPacket(okPacket); assertTrue(okAuth instanceof AuthenticationOk); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "not implement auth method.*") public void testLoadFromPacketException() { byte[] errorPacket = new byte[] {(byte) 0x52, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02}; Authentication.loadFromPacket(errorPacket); }