@Test(expected = QblNetworkInvalidResponseException.class) public void sendDropMessageFailTest() throws Exception { Collection<DropURL> collection = new ArrayList<>(); DropURL drpoUrl = new DropURL(fakeURL); collection.add(drpoUrl); i = identityBuilderFactory.factory().withAlias("TestAlias").build(); c = new Contact(i.getAlias(), collection, i.getEcPublicKey()); DropMessage dropMessage = new DropMessage(i, text, "dropMessage"); connector.send(c, dropMessage); }
@Override public void send(Contact c, DropMessage d) throws QblNetworkInvalidResponseException { BinaryDropMessageV0 binaryMessage; try { binaryMessage = new BinaryDropMessageV0(d); final byte[] messageByteArray = binaryMessage.assembleMessageFor(c, (Identity)d.getSender()); DropURL dropURL = convertCollectionIntoDropUrl(c.getDropUrls()); HTTPResult<?> dropResult = dHTTP.send(dropURL.getUri(), messageByteArray); if (dropResult.getResponseCode() >= 300 || dropResult.getResponseCode() < 200) { throw new QblNetworkInvalidResponseException(); } } catch (QblDropPayloadSizeException e) { throw new IllegalStateException("drop payload too big: " + e.getMessage(), e); } }
HttpDropConnector implements DropConnector { @Override public void send(Contact c, DropMessage d) throws QblNetworkInvalidResponseException { BinaryDropMessageV0 binaryMessage; try { binaryMessage = new BinaryDropMessageV0(d); final byte[] messageByteArray = binaryMessage.assembleMessageFor(c, (Identity)d.getSender()); DropURL dropURL = convertCollectionIntoDropUrl(c.getDropUrls()); HTTPResult<?> dropResult = dHTTP.send(dropURL.getUri(), messageByteArray); if (dropResult.getResponseCode() >= 300 || dropResult.getResponseCode() < 200) { throw new QblNetworkInvalidResponseException(); } } catch (QblDropPayloadSizeException e) { throw new IllegalStateException("drop payload too big: " + e.getMessage(), e); } } }
HttpDropConnector implements DropConnector { @Override public void send(Contact c, DropMessage d) throws QblNetworkInvalidResponseException { BinaryDropMessageV0 binaryMessage; try { binaryMessage = new BinaryDropMessageV0(d); final byte[] messageByteArray = binaryMessage.assembleMessageFor(c, (Identity)d.getSender()); DropURL dropURL = convertCollectionIntoDropUrl(c.getDropUrls()); HTTPResult<?> dropResult = dHTTP.send(dropURL.getUri(), messageByteArray); if (dropResult.getResponseCode() >= 300 || dropResult.getResponseCode() < 200) { throw new QblNetworkInvalidResponseException(); } } catch (QblDropPayloadSizeException e) { throw new IllegalStateException("drop payload too big: " + e.getMessage(), e); } } HttpDropConnector(NetworkStatus networkStatus, DropHTTP dHTTP); }
HttpDropConnector implements DropConnector { @Override public void send(Contact c, DropMessage d) throws QblNetworkInvalidResponseException { BinaryDropMessageV0 binaryMessage; try { binaryMessage = new BinaryDropMessageV0(d); final byte[] messageByteArray = binaryMessage.assembleMessageFor(c, (Identity)d.getSender()); DropURL dropURL = convertCollectionIntoDropUrl(c.getDropUrls()); HTTPResult<?> dropResult = dHTTP.send(dropURL.getUri(), messageByteArray); if (dropResult.getResponseCode() >= 300 || dropResult.getResponseCode() < 200) { throw new QblNetworkInvalidResponseException(); } } catch (QblDropPayloadSizeException e) { throw new IllegalStateException("drop payload too big: " + e.getMessage(), e); } } HttpDropConnector(NetworkStatus networkStatus, DropHTTP dHTTP); @Override void send(Contact c, DropMessage d); @Override DropPollResponse receive(Identity i, Date since); }
HttpDropConnector implements DropConnector { @Override public void send(Contact c, DropMessage d) throws QblNetworkInvalidResponseException { BinaryDropMessageV0 binaryMessage; try { binaryMessage = new BinaryDropMessageV0(d); final byte[] messageByteArray = binaryMessage.assembleMessageFor(c, (Identity)d.getSender()); DropURL dropURL = convertCollectionIntoDropUrl(c.getDropUrls()); HTTPResult<?> dropResult = dHTTP.send(dropURL.getUri(), messageByteArray); if (dropResult.getResponseCode() >= 300 || dropResult.getResponseCode() < 200) { throw new QblNetworkInvalidResponseException(); } } catch (QblDropPayloadSizeException e) { throw new IllegalStateException("drop payload too big: " + e.getMessage(), e); } } HttpDropConnector(NetworkStatus networkStatus, DropHTTP dHTTP); @Override void send(Contact c, DropMessage d); @Override DropPollResponse receive(Identity i, Date since);  }