@Test public void testEncryptedMessageNoKey() throws IOException { DataInputStreamMock mock = new DataInputStreamMock(); mock.mockReadShort((short) -3); mock.mockReadBoolean(true); mock.mockReadUtf("FooBar"); InputStream is = mock.getIn(); MessageInputStream mis = new MessageInputStream(is); Message msg = mis.readMessage(); mis.close(); Assert.assertEquals(msg.getArgument("encryptedString"), "FooBar", "Arguments do not match."); }
public Message readMessage() throws IOException { short id = readShort(); MessageType messageType = messageRegistry.getMessageType(id); if (messageType == null) { throw new MessageTypeException(id); } LinkedList<Class> classes = new LinkedList<>(); for (ArgumentType argumentType : messageType.getArguments()) { Class typeForName = Message.getTypeForName(argumentType.getType()); classes.add(typeForName); } Class<?>[] classArray = new Class[classes.size()]; classes.toArray(classArray); Object[] args = readMessageArgs(classes); return new Message(messageType, args); }
MessageInputStream extends DataInputStream { public Message readMessage() throws IOException { short id = readShort(); MessageType messageType = messageRegistry.getMessageType(id); if (messageType == null) { throw new MessageTypeException(id); } LinkedList<Class> classes = new LinkedList<>(); for (ArgumentType argumentType : messageType.getArguments()) { Class typeForName = Message.getTypeForName(argumentType.getType()); classes.add(typeForName); } Class<?>[] classArray = new Class[classes.size()]; classes.toArray(classArray); Object[] args = readMessageArgs(classes); return new Message(messageType, args); } }
MessageInputStream extends DataInputStream { public Message readMessage() throws IOException { short id = readShort(); MessageType messageType = messageRegistry.getMessageType(id); if (messageType == null) { throw new MessageTypeException(id); } LinkedList<Class> classes = new LinkedList<>(); for (ArgumentType argumentType : messageType.getArguments()) { Class typeForName = Message.getTypeForName(argumentType.getType()); classes.add(typeForName); } Class<?>[] classArray = new Class[classes.size()]; classes.toArray(classArray); Object[] args = readMessageArgs(classes); return new Message(messageType, args); } MessageInputStream(InputStream inputStream); }
MessageInputStream extends DataInputStream { public Message readMessage() throws IOException { short id = readShort(); MessageType messageType = messageRegistry.getMessageType(id); if (messageType == null) { throw new MessageTypeException(id); } LinkedList<Class> classes = new LinkedList<>(); for (ArgumentType argumentType : messageType.getArguments()) { Class typeForName = Message.getTypeForName(argumentType.getType()); classes.add(typeForName); } Class<?>[] classArray = new Class[classes.size()]; classes.toArray(classArray); Object[] args = readMessageArgs(classes); return new Message(messageType, args); } MessageInputStream(InputStream inputStream); Message readMessage(); void setPrivateKey(Key privateKey); }
MessageInputStream extends DataInputStream { public Message readMessage() throws IOException { short id = readShort(); MessageType messageType = messageRegistry.getMessageType(id); if (messageType == null) { throw new MessageTypeException(id); } LinkedList<Class> classes = new LinkedList<>(); for (ArgumentType argumentType : messageType.getArguments()) { Class typeForName = Message.getTypeForName(argumentType.getType()); classes.add(typeForName); } Class<?>[] classArray = new Class[classes.size()]; classes.toArray(classArray); Object[] args = readMessageArgs(classes); return new Message(messageType, args); } MessageInputStream(InputStream inputStream); Message readMessage(); void setPrivateKey(Key privateKey);  }