BitmessageContext { public void send(final BitmessageAddress from, final BitmessageAddress to, final String subject, final String message) { if (from.getPrivateKey() == null) { throw new IllegalArgumentException("'From' must be an identity, i.e. have a private key."); } Plaintext msg = new Plaintext.Builder(MSG) .from(from) .to(to) .message(subject, message) .build(); send(msg); } private  BitmessageContext(Builder builder); AddressRepository addresses(); MessageRepository messages(); Labeler labeler(); BitmessageAddress createIdentity(boolean shorter, Feature... features); BitmessageAddress joinChan(String passphrase, String address); BitmessageAddress createChan(String passphrase); List<BitmessageAddress> createDeterministicAddresses(
        String passphrase, int numberOfAddresses, long version, long stream, boolean shorter); void broadcast(final BitmessageAddress from, final String subject, final String message); void send(final BitmessageAddress from, final BitmessageAddress to, final String subject, final String message); void send(final Plaintext msg); void startup(); void shutdown(); void synchronize(InetAddress host, int port, long timeoutInSeconds, boolean wait); CustomMessage send(InetAddress server, int port, CustomMessage request); void cleanup(); void resendUnacknowledgedMessages(); boolean isRunning(); void addContact(BitmessageAddress contact); void addSubscribtion(BitmessageAddress address); Property status(); InternalContext internals(); static final int CURRENT_VERSION; }
@Test(expected = IllegalArgumentException.class) public void ensureSenderMustBeIdentity() { ctx.send(new BitmessageAddress("BM-opWQhvk9xtMFvQA2Kvetedpk8LkbraWHT"), new BitmessageAddress("BM-opWQhvk9xtMFvQA2Kvetedpk8LkbraWHT"), "Subject", "Message"); }
@Test(expected = IllegalArgumentException.class) public void ensureSenderWithoutPrivateKeyThrowsException() { Plaintext msg = new Plaintext.Builder(Type.BROADCAST) .from(new BitmessageAddress("BM-2cSqjfJ8xK6UUn5Rw3RpdGQ9RsDkBhWnS8")) .message("Subject", "Message") .build(); ctx.send(msg); }