@Test public void testAvailable() throws Exception { byte[] myData = "myData".getBytes(StandardCharsets.UTF_8); DeliveryImpl deliveyImpl = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null); deliveyImpl.append(myData); Delivery delivery = deliveyImpl; assertNotNull("expected the delivery to be present", delivery); assertEquals("unexpectd available count", myData.length, delivery.available()); int partLength = 2; int remainderLength = myData.length - partLength; assertTrue(partLength < myData.length); byte[] myRecievedData1 = new byte[partLength]; int received = deliveyImpl.recv(myRecievedData1, 0, myRecievedData1.length); assertEquals("Unexpected data length received", partLength, received); assertEquals("Unexpected data length available", remainderLength, delivery.available()); byte[] myRecievedData2 = new byte[remainderLength]; received = deliveyImpl.recv(myRecievedData2, 0, remainderLength); assertEquals("Unexpected data length received", remainderLength, received); assertEquals("Expected no data to remain available", 0, delivery.available()); }
@Override public int available() { return _dataView == null ? 0 : _dataView.remaining(); }
DeliveryImpl implements Delivery { @Override public int available() { return _dataView == null ? 0 : _dataView.remaining(); } }
DeliveryImpl implements Delivery { @Override public int available() { return _dataView == null ? 0 : _dataView.remaining(); } DeliveryImpl(final byte[] tag, final LinkImpl link, DeliveryImpl previous); }
DeliveryImpl implements Delivery { @Override public int available() { return _dataView == null ? 0 : _dataView.remaining(); } DeliveryImpl(final byte[] tag, final LinkImpl link, DeliveryImpl previous); @Override byte[] getTag(); @Override LinkImpl getLink(); @Override DeliveryState getLocalState(); @Override DeliveryState getRemoteState(); @Override boolean remotelySettled(); @Override void setMessageFormat(int messageFormat); @Override int getMessageFormat(); @Override void disposition(final DeliveryState state); @Override void settle(); @Override DeliveryImpl next(); @Override void free(); @Override DeliveryImpl getWorkNext(); @Override boolean isSettled(); @Override int available(); @Override boolean isWritable(); @Override boolean isReadable(); @Override boolean isAborted(); @Override boolean isPartial(); @Override boolean isUpdated(); @Override void clear(); @Override boolean isBuffered(); @Override Object getContext(); @Override void setContext(Object context); @Override Record attachments(); @Override String toString(); @Override int pending(); @Override void setDefaultDeliveryState(DeliveryState state); @Override DeliveryState getDefaultDeliveryState(); }
DeliveryImpl implements Delivery { @Override public int available() { return _dataView == null ? 0 : _dataView.remaining(); } DeliveryImpl(final byte[] tag, final LinkImpl link, DeliveryImpl previous); @Override byte[] getTag(); @Override LinkImpl getLink(); @Override DeliveryState getLocalState(); @Override DeliveryState getRemoteState(); @Override boolean remotelySettled(); @Override void setMessageFormat(int messageFormat); @Override int getMessageFormat(); @Override void disposition(final DeliveryState state); @Override void settle(); @Override DeliveryImpl next(); @Override void free(); @Override DeliveryImpl getWorkNext(); @Override boolean isSettled(); @Override int available(); @Override boolean isWritable(); @Override boolean isReadable(); @Override boolean isAborted(); @Override boolean isPartial(); @Override boolean isUpdated(); @Override void clear(); @Override boolean isBuffered(); @Override Object getContext(); @Override void setContext(Object context); @Override Record attachments(); @Override String toString(); @Override int pending(); @Override void setDefaultDeliveryState(DeliveryState state); @Override DeliveryState getDefaultDeliveryState(); static final int DEFAULT_MESSAGE_FORMAT; }