use of org.apache.qpid.proton.amqp.messaging.Source in project azure-iot-sdk-java by Azure.
the class AmqpFileUploadNotificationReceivedHandlerTest method createProtonObjects.
private void createProtonObjects() {
final String exceptionMessage = "Not expected function called";
message = Proton.message();
receiver = new Receiver() {
@Override
public void flow(int i) {
}
@Override
public int recv(byte[] bytes, int i, int i1) {
return 0;
}
@Override
public int recv(WritableBuffer writableBuffer) {
return 0;
}
@Override
public void drain(int i) {
}
@Override
public boolean advance() {
return false;
}
@Override
public boolean draining() {
return false;
}
@Override
public void setDrain(boolean b) {
}
@Override
public String getName() {
return "filenotificationreceiver";
}
@Override
public Delivery delivery(byte[] bytes) {
return null;
}
@Override
public Delivery delivery(byte[] bytes, int i, int i1) {
return null;
}
@Override
public Delivery head() {
return null;
}
@Override
public Delivery current() {
return delivery;
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getTarget() {
return null;
}
@Override
public void setSource(org.apache.qpid.proton.amqp.transport.Source source) {
}
@Override
public void setTarget(org.apache.qpid.proton.amqp.transport.Target target) {
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getRemoteSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getRemoteTarget() {
return null;
}
@Override
public Link next(EnumSet<EndpointState> enumSet, EnumSet<EndpointState> enumSet1) {
return null;
}
@Override
public int getCredit() {
return 0;
}
@Override
public int getQueued() {
return 0;
}
@Override
public int getUnsettled() {
return 0;
}
@Override
public Session getSession() {
return session;
}
@Override
public SenderSettleMode getSenderSettleMode() {
return null;
}
@Override
public void setSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public SenderSettleMode getRemoteSenderSettleMode() {
return null;
}
@Override
public ReceiverSettleMode getReceiverSettleMode() {
return null;
}
@Override
public void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode) {
}
@Override
public ReceiverSettleMode getRemoteReceiverSettleMode() {
return null;
}
@Override
public void setRemoteSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public Map<Symbol, Object> getProperties() {
return null;
}
@Override
public void setProperties(Map<Symbol, Object> map) {
}
@Override
public Map<Symbol, Object> getRemoteProperties() {
return null;
}
@Override
public int drained() {
return 0;
}
@Override
public int getRemoteCredit() {
return 0;
}
@Override
public boolean getDrain() {
return false;
}
@Override
public void detach() {
}
@Override
public boolean detached() {
return false;
}
@Override
public void setOfferedCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getOfferedCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteOfferedCapabilities() {
return new Symbol[0];
}
@Override
public void setDesiredCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getDesiredCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteDesiredCapabilities() {
return new Symbol[0];
}
@Override
public EndpointState getLocalState() {
return null;
}
@Override
public EndpointState getRemoteState() {
return null;
}
@Override
public ErrorCondition getCondition() {
return null;
}
@Override
public void setCondition(ErrorCondition errorCondition) {
}
@Override
public ErrorCondition getRemoteCondition() {
return null;
}
@Override
public void free() {
}
@Override
public void open() {
}
@Override
public void close() {
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public Record attachments() {
return null;
}
};
event = new Event() {
@Override
public EventType getEventType() {
return null;
}
@Override
public Type getType() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Object getContext() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Handler getRootHandler() {
return null;
}
@Override
public void dispatch(Handler hndlr) throws HandlerException {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public void redispatch(EventType eventType, Handler handler) throws HandlerException {
}
@Override
public void delegate() throws HandlerException {
}
@Override
public Connection getConnection() {
return connection;
}
@Override
public Session getSession() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Link getLink() {
return receiver;
}
@Override
public Sender getSender() {
return null;
}
@Override
public Receiver getReceiver() {
return null;
}
@Override
public Delivery getDelivery() {
return delivery;
}
@Override
public Transport getTransport() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Reactor getReactor() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Selectable getSelectable() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Task getTask() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Event copy() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Record attachments() {
throw new UnsupportedOperationException(exceptionMessage);
}
};
delivery = new Delivery() {
@Override
public byte[] getTag() {
return new byte[0];
}
@Override
public Link getLink() {
return receiver;
}
@Override
public DeliveryState getLocalState() {
return null;
}
@Override
public DeliveryState getRemoteState() {
return null;
}
@Override
public int getMessageFormat() {
return 0;
}
@Override
public int available() {
return 0;
}
@Override
public void disposition(DeliveryState deliveryState) {
}
@Override
public void settle() {
}
@Override
public boolean isSettled() {
return false;
}
@Override
public boolean remotelySettled() {
return false;
}
@Override
public void free() {
}
@Override
public Delivery getWorkNext() {
return null;
}
@Override
public Delivery next() {
return null;
}
@Override
public boolean isWritable() {
return false;
}
@Override
public boolean isReadable() {
return true;
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public boolean isUpdated() {
return false;
}
@Override
public void clear() {
}
@Override
public boolean isPartial() {
return false;
}
@Override
public int pending() {
return 0;
}
@Override
public boolean isBuffered() {
return false;
}
@Override
public void setDefaultDeliveryState(DeliveryState deliveryState) {
}
@Override
public DeliveryState getDefaultDeliveryState() {
return null;
}
@Override
public void setMessageFormat(int i) {
}
@Override
public Record attachments() {
return null;
}
};
}
use of org.apache.qpid.proton.amqp.messaging.Source in project azure-iot-sdk-java by Azure.
the class AmqpReceiveHandlerTest method createProtonObjects.
private void createProtonObjects() {
final String exceptionMessage = "Not expected function called";
message = Proton.message();
receiver = new Receiver() {
@Override
public void flow(int i) {
}
@Override
public int recv(byte[] bytes, int i, int i1) {
return 0;
}
@Override
public int recv(WritableBuffer writableBuffer) {
return 0;
}
@Override
public void drain(int i) {
}
@Override
public boolean advance() {
return false;
}
@Override
public boolean draining() {
return false;
}
@Override
public void setDrain(boolean b) {
}
@Override
public String getName() {
return RECEIVE_TAG;
}
@Override
public Delivery delivery(byte[] bytes) {
return null;
}
@Override
public Delivery delivery(byte[] bytes, int i, int i1) {
return null;
}
@Override
public Delivery head() {
return null;
}
@Override
public Delivery current() {
return delivery;
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getTarget() {
return null;
}
@Override
public void setSource(org.apache.qpid.proton.amqp.transport.Source source) {
}
@Override
public void setTarget(org.apache.qpid.proton.amqp.transport.Target target) {
}
@Override
public org.apache.qpid.proton.amqp.transport.Source getRemoteSource() {
return null;
}
@Override
public org.apache.qpid.proton.amqp.transport.Target getRemoteTarget() {
return null;
}
@Override
public Link next(EnumSet<EndpointState> enumSet, EnumSet<EndpointState> enumSet1) {
return null;
}
@Override
public int getCredit() {
return 0;
}
@Override
public int getQueued() {
return 0;
}
@Override
public int getUnsettled() {
return 0;
}
@Override
public Session getSession() {
return session;
}
@Override
public SenderSettleMode getSenderSettleMode() {
return null;
}
@Override
public void setSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public SenderSettleMode getRemoteSenderSettleMode() {
return null;
}
@Override
public ReceiverSettleMode getReceiverSettleMode() {
return null;
}
@Override
public void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode) {
}
@Override
public ReceiverSettleMode getRemoteReceiverSettleMode() {
return null;
}
@Override
public void setRemoteSenderSettleMode(SenderSettleMode senderSettleMode) {
}
@Override
public Map<Symbol, Object> getProperties() {
return null;
}
@Override
public void setProperties(Map<Symbol, Object> map) {
}
@Override
public Map<Symbol, Object> getRemoteProperties() {
return null;
}
@Override
public int drained() {
return 0;
}
@Override
public int getRemoteCredit() {
return 0;
}
@Override
public boolean getDrain() {
return false;
}
@Override
public void detach() {
}
@Override
public boolean detached() {
return false;
}
@Override
public void setOfferedCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getOfferedCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteOfferedCapabilities() {
return new Symbol[0];
}
@Override
public void setDesiredCapabilities(Symbol[] symbols) {
}
@Override
public Symbol[] getDesiredCapabilities() {
return new Symbol[0];
}
@Override
public Symbol[] getRemoteDesiredCapabilities() {
return new Symbol[0];
}
@Override
public EndpointState getLocalState() {
return null;
}
@Override
public EndpointState getRemoteState() {
return null;
}
@Override
public ErrorCondition getCondition() {
return null;
}
@Override
public void setCondition(ErrorCondition errorCondition) {
}
@Override
public ErrorCondition getRemoteCondition() {
return null;
}
@Override
public void free() {
}
@Override
public void open() {
}
@Override
public void close() {
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public Record attachments() {
return null;
}
};
event = new Event() {
@Override
public EventType getEventType() {
return null;
}
@Override
public Event.Type getType() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Object getContext() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Handler getRootHandler() {
return null;
}
@Override
public void dispatch(Handler hndlr) throws HandlerException {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public void redispatch(EventType eventType, Handler handler) throws HandlerException {
}
@Override
public void delegate() throws HandlerException {
}
@Override
public Connection getConnection() {
return connection;
}
@Override
public Session getSession() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Link getLink() {
return receiver;
}
@Override
public Sender getSender() {
return null;
}
@Override
public Receiver getReceiver() {
return null;
}
@Override
public Delivery getDelivery() {
return delivery;
}
@Override
public Transport getTransport() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Reactor getReactor() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Selectable getSelectable() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Task getTask() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Event copy() {
throw new UnsupportedOperationException(exceptionMessage);
}
@Override
public Record attachments() {
throw new UnsupportedOperationException(exceptionMessage);
}
};
delivery = new Delivery() {
@Override
public byte[] getTag() {
return new byte[0];
}
@Override
public Link getLink() {
return receiver;
}
@Override
public DeliveryState getLocalState() {
return null;
}
@Override
public DeliveryState getRemoteState() {
return null;
}
@Override
public int getMessageFormat() {
return 0;
}
@Override
public int available() {
return 0;
}
@Override
public void disposition(DeliveryState deliveryState) {
}
@Override
public void settle() {
}
@Override
public boolean isSettled() {
return false;
}
@Override
public boolean remotelySettled() {
return false;
}
@Override
public void free() {
}
@Override
public Delivery getWorkNext() {
return null;
}
@Override
public Delivery next() {
return null;
}
@Override
public boolean isWritable() {
return false;
}
@Override
public boolean isReadable() {
return true;
}
@Override
public void setContext(Object o) {
}
@Override
public Object getContext() {
return null;
}
@Override
public boolean isUpdated() {
return false;
}
@Override
public void clear() {
}
@Override
public boolean isPartial() {
return false;
}
@Override
public int pending() {
return 0;
}
@Override
public boolean isBuffered() {
return false;
}
@Override
public void setDefaultDeliveryState(DeliveryState deliveryState) {
}
@Override
public DeliveryState getDefaultDeliveryState() {
return null;
}
@Override
public void setMessageFormat(int i) {
}
@Override
public Record attachments() {
return null;
}
};
}
use of org.apache.qpid.proton.amqp.messaging.Source in project azure-iot-sdk-java by Azure.
the class AmqpsIotHubConnectionTest method onLinkInitReceive.
// Tests_SRS_AMQPSIOTHUBCONNECTION_14_046: [If the link is the Receiver link, the event handler shall create a new Source (Proton) object using the receiver endpoint address member variable.]
// Tests_SRS_AMQPSIOTHUBCONNECTION_14_047: [If the link is the Receiver link, the event handler shall set its source to the created Source (Proton) object.]
@Test
public void onLinkInitReceive() throws IOException {
baseExpectations();
new NonStrictExpectations() {
{
mockEvent.getLink();
result = mockReceiver;
mockReceiver.getName();
result = "receiver";
new Source();
result = mockSource;
mockSource.setAddress(anyString);
mockReceiver.setSource(mockSource);
}
};
final AmqpsIotHubConnection connection = new AmqpsIotHubConnection(mockConfig, false);
connection.onLinkInit(mockEvent);
new Verifications() {
{
mockEvent.getLink();
times = 1;
mockReceiver.getName();
times = 1;
new Source();
times = 1;
mockSource.setAddress(anyString);
times = 1;
mockReceiver.setSource((org.apache.qpid.proton.amqp.transport.Source) any);
times = 1;
}
};
}
use of org.apache.qpid.proton.amqp.messaging.Source in project azure-iot-sdk-java by Azure.
the class AmqpFileUploadNotificationReceivedHandler method onLinkInit.
@Override
public void onLinkInit(Event event) {
// Codes_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_015: [The event handler shall create a new Target (Proton) object using the given endpoint address]
// Codes_SRS_SERVICE_SDK_JAVA_AMQPFILEUPLOADNOTIFICATIONRECEIVEDHANDLER_25_016: [The event handler shall get the Link (Proton) object and set its target to the created Target (Proton) object]
Link link = event.getLink();
if (event.getLink().getName().equals(FILE_NOTIFICATION_RECEIVE_TAG)) {
Target t = new Target();
t.setAddress(FILENOTIFICATION_ENDPOINT);
Source source = new Source();
source.setAddress(FILENOTIFICATION_ENDPOINT);
link.setTarget(t);
link.setSource(source);
}
}
use of org.apache.qpid.proton.amqp.messaging.Source in project azure-service-bus-java by Azure.
the class CoreMessageReceiver method onOpenComplete.
@Override
public void onOpenComplete(Exception exception) {
if (exception == null) {
TRACE_LOGGER.info("Receive link to '{}' opened.", this.receivePath);
if (this.isSessionReceiver) {
Map remoteSourceFilter = ((Source) this.receiveLink.getRemoteSource()).getFilter();
if (remoteSourceFilter != null && remoteSourceFilter.containsKey(ClientConstants.SESSION_FILTER)) {
String remoteSessionId = (String) remoteSourceFilter.get(ClientConstants.SESSION_FILTER);
this.sessionId = remoteSessionId;
if (this.receiveLink.getRemoteProperties() != null && this.receiveLink.getRemoteProperties().containsKey(ClientConstants.LOCKED_UNTIL_UTC)) {
this.sessionLockedUntilUtc = Util.convertDotNetTicksToInstant((long) this.receiveLink.getRemoteProperties().get(ClientConstants.LOCKED_UNTIL_UTC));
} else {
TRACE_LOGGER.warn("Accepted a session with id '{}', from '{}' which didn't set '{}' property on the receive link.", this.sessionId, this.receivePath, ClientConstants.LOCKED_UNTIL_UTC);
this.sessionLockedUntilUtc = Instant.ofEpochMilli(0);
}
TRACE_LOGGER.info("Accepted session with id '{}', lockedUntilUtc '{}' from '{}'.", this.sessionId, this.sessionLockedUntilUtc, this.receivePath);
} else {
exception = new ServiceBusException(false, "SessionId filter not set on the remote source.");
}
}
}
if (exception == null) {
this.underlyingFactory.registerForConnectionError(this.receiveLink);
if (this.linkOpen != null && !this.linkOpen.getWork().isDone()) {
AsyncUtil.completeFuture(this.linkOpen.getWork(), this);
}
if (this.receiveLinkReopenFuture != null && !this.receiveLinkReopenFuture.isDone()) {
AsyncUtil.completeFuture(this.receiveLinkReopenFuture, null);
this.receiveLinkReopenFuture = null;
}
this.lastKnownLinkError = null;
this.underlyingFactory.getRetryPolicy().resetRetryCount(this.underlyingFactory.getClientId());
this.sendFlow(this.prefetchCount - this.currentPrefetechedMessagesCount.get());
TRACE_LOGGER.debug("receiverPath:{}, linkname:{}, updated-link-credit:{}, sentCredits:{}", this.receivePath, this.receiveLink.getName(), this.receiveLink.getCredit(), this.prefetchCount);
} else {
this.cancelSASTokenRenewTimer();
if (this.linkOpen != null && !this.linkOpen.getWork().isDone()) {
TRACE_LOGGER.error("Opening receive link to '{}' failed.", this.receivePath, exception);
this.setClosed();
ExceptionUtil.completeExceptionally(this.linkOpen.getWork(), exception, this, true);
}
if (this.receiveLinkReopenFuture != null && !this.receiveLinkReopenFuture.isDone()) {
TRACE_LOGGER.warn("Opening receive link to '{}' failed.", this.receivePath, exception);
AsyncUtil.completeFutureExceptionally(this.receiveLinkReopenFuture, exception);
this.receiveLinkReopenFuture = null;
if (this.isSessionReceiver && (exception instanceof SessionLockLostException || exception instanceof SessionCannotBeLockedException)) {
// No point in retrying to establish a link.. SessionLock is lost
TRACE_LOGGER.warn("SessionId '{}' lock lost. Closing receiver.", this.sessionId);
this.isSessionLockLost = true;
this.closeAsync();
}
}
this.lastKnownLinkError = exception;
}
}
Aggregations