@Test(expectedExceptions = IOException.class) public void testEncryptedMessageNoPublicKey() throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); MessageOutputStream mos = new MessageOutputStream(bos); Message msg = MESSAGE_REGISTRY.createMessage("TestEncryptedMessage"); msg.setArgument("encryptedString", "FooBar"); mos.writeMessage(msg); }
public void writeMessage(Message message) throws IOException { if (closed) { throw new IOException("Cannot write message: stream closed"); } Object[] args = message.getArgs(); MessageType messageType = messageRegistry.getMessageType(message.getID()); List<ArgumentType> argumentTypes = messageType.getArguments(); int id = message.getID(); writeShort(id); for (int i = 0; i < args.length; i++) writeArgument(args[i], argumentTypes.get(i).isEncrypt()); }
MessageOutputStream extends DataOutputStream { public void writeMessage(Message message) throws IOException { if (closed) { throw new IOException("Cannot write message: stream closed"); } Object[] args = message.getArgs(); MessageType messageType = messageRegistry.getMessageType(message.getID()); List<ArgumentType> argumentTypes = messageType.getArguments(); int id = message.getID(); writeShort(id); for (int i = 0; i < args.length; i++) writeArgument(args[i], argumentTypes.get(i).isEncrypt()); } }
MessageOutputStream extends DataOutputStream { public void writeMessage(Message message) throws IOException { if (closed) { throw new IOException("Cannot write message: stream closed"); } Object[] args = message.getArgs(); MessageType messageType = messageRegistry.getMessageType(message.getID()); List<ArgumentType> argumentTypes = messageType.getArguments(); int id = message.getID(); writeShort(id); for (int i = 0; i < args.length; i++) writeArgument(args[i], argumentTypes.get(i).isEncrypt()); } MessageOutputStream(OutputStream out); }
MessageOutputStream extends DataOutputStream { public void writeMessage(Message message) throws IOException { if (closed) { throw new IOException("Cannot write message: stream closed"); } Object[] args = message.getArgs(); MessageType messageType = messageRegistry.getMessageType(message.getID()); List<ArgumentType> argumentTypes = messageType.getArguments(); int id = message.getID(); writeShort(id); for (int i = 0; i < args.length; i++) writeArgument(args[i], argumentTypes.get(i).isEncrypt()); } MessageOutputStream(OutputStream out); void writeMessage(Message message); boolean isClosed(); void setPublicKey(Key publicKey); @Override void close(); }
MessageOutputStream extends DataOutputStream { public void writeMessage(Message message) throws IOException { if (closed) { throw new IOException("Cannot write message: stream closed"); } Object[] args = message.getArgs(); MessageType messageType = messageRegistry.getMessageType(message.getID()); List<ArgumentType> argumentTypes = messageType.getArguments(); int id = message.getID(); writeShort(id); for (int i = 0; i < args.length; i++) writeArgument(args[i], argumentTypes.get(i).isEncrypt()); } MessageOutputStream(OutputStream out); void writeMessage(Message message); boolean isClosed(); void setPublicKey(Key publicKey); @Override void close();  }