org.apache.qpid.proton.amqp.DescribedType Java Examples
The following examples show how to use
org.apache.qpid.proton.amqp.DescribedType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractMessageSectionMatcher.java From qpid-jms with Apache License 2.0 | 6 votes |
/** * @param receivedBinary * The received Binary value that should be validated. * * @return the number of bytes consumed from the provided Binary * * @throws RuntimeException if the provided Binary does not match expectation in some way */ public int verify(Binary receivedBinary) throws RuntimeException { int length = receivedBinary.getLength(); Data data = Data.Factory.create(); long decoded = data.decode(receivedBinary.asByteBuffer()); if(decoded > Integer.MAX_VALUE) { throw new IllegalStateException("Decoded more bytes than Binary supports holding"); } if(decoded < length && !_expectTrailingBytes) { throw new IllegalArgumentException("Expected to consume all bytes, but trailing bytes remain: Got " + length + ", consumed "+ decoded); } DescribedType decodedDescribedType = data.getDescribedType(); verifyReceivedDescribedType(decodedDescribedType); //Need to cast to int, but verified earlier that it is < Integer.MAX_VALUE return (int) decoded; }
Example #2
Source File: DescribedTypeImpl.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || ! (o instanceof DescribedType)) { return false; } DescribedType that = (DescribedType) o; if (_described != null ? !_described.equals(that.getDescribed()) : that.getDescribed() != null) { return false; } if (_descriptor != null ? !_descriptor.equals(that.getDescriptor()) : that.getDescriptor() != null) { return false; } return true; }
Example #3
Source File: EncoderImpl.java From qpid-proton-j with Apache License 2.0 | 6 votes |
private void writeUnregisteredType(final Object o) { if(o.getClass().isArray()) { writeArrayType(o); } else if(o instanceof List) { writeList((List<?>)o); } else if(o instanceof Map) { writeMap((Map<?, ?>)o); } else if(o instanceof DescribedType) { writeDescribedType((DescribedType)o); } else { throw new IllegalArgumentException( "Do not know how to write Objects of class " + o.getClass().getName()); } }
Example #4
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 6 votes |
public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType, final MessageAnnotationsDescribedType messageAnnotationsDescribedType, final PropertiesDescribedType propertiesDescribedType, ApplicationPropertiesDescribedType appPropertiesDescribedType, final DescribedType content, final int count, final boolean drain, final boolean sendDrainFlowResponse, Matcher<UnsignedInteger> creditMatcher, final Integer nextIncomingId, final boolean sendSettled, boolean addMessageNumberProperty) { expectLinkFlowAndSendBackMessages(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType, appPropertiesDescribedType, content, count, drain, sendDrainFlowResponse, creditMatcher, nextIncomingId, sendSettled, addMessageNumberProperty, 0, false); }
Example #5
Source File: AmqpSupport.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Search for a particular filter using a set of known indentification values * in the Map of filters. * * @param filters The filters map that should be searched. * @param filterIds The aliases for the target filter to be located. * @return the filter if found in the mapping or null if not found. */ public static Map.Entry<Symbol, DescribedType> findFilter(Map<Symbol, Object> filters, Object[] filterIds) { if (filterIds == null || filterIds.length == 0) { throw new IllegalArgumentException("Invalid empty Filter Ids array passed: "); } if (filters == null || filters.isEmpty()) { return null; } for (Map.Entry<Symbol, Object> filter : filters.entrySet()) { if (filter.getValue() instanceof DescribedType) { DescribedType describedType = ((DescribedType) filter.getValue()); Object descriptor = describedType.getDescriptor(); for (Object filterId : filterIds) { if (descriptor.equals(filterId)) { return new AbstractMap.SimpleImmutableEntry<>(filter.getKey(), describedType); } } } } return null; }
Example #6
Source File: TransactionalStateMatcher.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(Object received) { try { assertThat(received, instanceOf(DescribedType.class)); descriptor = ((DescribedType)received).getDescriptor(); if(!coreMatcher.descriptorMatches(descriptor)) { mismatchTextAddition = "Descriptor mismatch"; return false; } described = ((DescribedType)received).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> fields = (List<Object>) described; coreMatcher.verifyFields(fields); } catch (AssertionError ae) { mismatchTextAddition = "AssertionFailure: " + ae.getMessage(); return false; } return true; }
Example #7
Source File: DeleteOnNoMessagesMatcher.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(Object received) { try { assertThat(received, instanceOf(DescribedType.class)); descriptor = ((DescribedType)received).getDescriptor(); if(!coreMatcher.descriptorMatches(descriptor)) { mismatchTextAddition = "Descriptor mismatch"; return false; } described = ((DescribedType)received).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> fields = (List<Object>) described; coreMatcher.verifyFields(fields); } catch (AssertionError ae) { mismatchTextAddition = "AssertionFailure: " + ae.getMessage(); return false; } return true; }
Example #8
Source File: ConsumerIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Test that a message is received when calling receive with a timeout * of 0, which means wait indefinitely. * * @throws Exception if an error occurs during the test. */ @Test(timeout = 20000) public void testReceiveMessageWithReceiveZeroTimeout() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(0); assertNotNull("A message should have been recieved", receivedMessage); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(2000); } }
Example #9
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 5 votes |
private Source createSourceObjectFromDescribedType(Object o) { assertThat(o, instanceOf(DescribedType.class)); Object described = ((DescribedType) o).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> sourceFields = (List<Object>) described; return new Source(sourceFields.toArray()); }
Example #10
Source File: DeleteOnNoLinksMatcher.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(Object received) { try { assertThat(received, instanceOf(DescribedType.class)); descriptor = ((DescribedType)received).getDescriptor(); if(!coreMatcher.descriptorMatches(descriptor)) { mismatchTextAddition = "Descriptor mismatch"; return false; } described = ((DescribedType)received).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> fields = (List<Object>) described; coreMatcher.verifyFields(fields); } catch (AssertionError ae) { mismatchTextAddition = "AssertionFailure: " + ae.getMessage(); return false; } return true; }
Example #11
Source File: JMSConsumerIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testReceiveBodyTextMessage() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { JMSContext context = testFixture.createJMSContext(testPeer); testPeer.expectBegin(); final String content = "Message-Content"; Queue queue = context.createQueue("myQueue"); DescribedType amqpValueContent = new AmqpValueDescribedType(content); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); testPeer.expectEnd(); testPeer.expectClose(); JMSConsumer messageConsumer = context.createConsumer(queue); String received = messageConsumer.receiveBody(String.class, 3000); assertNotNull(received); assertEquals(content, received); context.close(); testPeer.waitForAllHandlersToComplete(3000); } }
Example #12
Source File: ModifiedMatcher.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(Object received) { try { assertThat(received, instanceOf(DescribedType.class)); descriptor = ((DescribedType)received).getDescriptor(); if(!coreMatcher.descriptorMatches(descriptor)) { mismatchTextAddition = "Descriptor mismatch"; return false; } described = ((DescribedType)received).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> fields = (List<Object>) described; coreMatcher.verifyFields(fields); } catch (AssertionError ae) { mismatchTextAddition = "AssertionFailure: " + ae.getMessage(); return false; } return true; }
Example #13
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 5 votes |
public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType, final MessageAnnotationsDescribedType messageAnnotationsDescribedType, final PropertiesDescribedType propertiesDescribedType, final ApplicationPropertiesDescribedType appPropertiesDescribedType, final DescribedType content) { expectLinkFlowRespondWithTransfer(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType, appPropertiesDescribedType, content, 1); }
Example #14
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 5 votes |
public void expectLinkFlowRespondWithTransfer(final HeaderDescribedType headerDescribedType, final MessageAnnotationsDescribedType messageAnnotationsDescribedType, final PropertiesDescribedType propertiesDescribedType, final ApplicationPropertiesDescribedType appPropertiesDescribedType, final DescribedType content, final boolean sendSettled) { expectLinkFlowRespondWithTransfer(headerDescribedType, messageAnnotationsDescribedType, propertiesDescribedType, appPropertiesDescribedType, content, 1, false, false, Matchers.greaterThanOrEqualTo(UnsignedInteger.valueOf(1)), 1, sendSettled, false); }
Example #15
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testReceiveMessageAndGetBody() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); testPeer.expectClose(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); assertTrue(receivedMessage.isBodyAssignableTo(Object.class)); assertTrue(receivedMessage.isBodyAssignableTo(String.class)); assertTrue(receivedMessage.isBodyAssignableTo(byte[].class)); assertTrue(receivedMessage.isBodyAssignableTo(Serializable.class)); assertTrue(receivedMessage.isBodyAssignableTo(Map.class)); assertNull(receivedMessage.getBody(Object.class)); assertNull(receivedMessage.getBody(String.class)); assertNull(receivedMessage.getBody(byte[].class)); assertNull(receivedMessage.getBody(Serializable.class)); assertNull(receivedMessage.getBody(Map.class)); connection.close(); testPeer.waitForAllHandlersToComplete(3000); } }
Example #16
Source File: DeleteOnCloseMatcher.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(Object received) { try { assertThat(received, instanceOf(DescribedType.class)); descriptor = ((DescribedType)received).getDescriptor(); if(!coreMatcher.descriptorMatches(descriptor)) { mismatchTextAddition = "Descriptor mismatch"; return false; } described = ((DescribedType)received).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> fields = (List<Object>) described; coreMatcher.verifyFields(fields); } catch (AssertionError ae) { mismatchTextAddition = "AssertionFailure: " + ae.getMessage(); return false; } return true; }
Example #17
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 5 votes |
void receiveFrame(int type, int channel, int frameSize, DescribedType describedType, Binary payload) { Handler handler = getFirstHandler(); while (handler instanceof FrameHandler && ((FrameHandler) handler).isOptional()) { FrameHandler frameHandler = (FrameHandler) handler; if(frameHandler.descriptorMatches(describedType.getDescriptor())){ LOGGER.info("Optional frame handler matches the descriptor, proceeding to verify it"); break; } else { LOGGER.info("Skipping non-matching optional frame handler, received frame descriptor (" + describedType.getDescriptor() + ") does not match handler: " + frameHandler); removeFirstHandler(); handler = getFirstHandler(); } } if(handler == null) { Object actualDescriptor = describedType.getDescriptor(); Object mappedDescriptor = FrameDescriptorMapping.lookupMapping(actualDescriptor); throw new IllegalStateException("No handler! Received frame, descriptor=" + actualDescriptor + "/" + mappedDescriptor); } if(handler instanceof FrameHandler) { ((FrameHandler)handler).frame(type, channel, frameSize, describedType, payload, this); removeFirstHandler(); } else { throw new IllegalStateException("Received frame but the next handler is a " + handler); } }
Example #18
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Tests that lack of the reply-to set on a message results in it returning null for JMSReplyTo * and not the consumer destination as happens for JMSDestination. * * @throws Exception if an error occurs during the test. */ @Test(timeout = 20000) public void testReceivedMessageFromQueueWithNoReplyToReturnsNull() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); PropertiesDescribedType props = new PropertiesDescribedType(); props.setMessageId("myMessageIDString"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); assertNull(receivedMessage.getJMSReplyTo()); } }
Example #19
Source File: Declare.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if(obj == this) { return true; } if(!(obj instanceof DescribedType)) { return false; } DescribedType d = (DescribedType) obj; if(!(DESCRIPTOR_CODE.equals(d.getDescriptor()) || DESCRIPTOR_SYMBOL.equals(d.getDescriptor()))) { return false; } Object described = getDescribed(); Object described2 = d.getDescribed(); if(described == null) { return described2 == null; } else { return described.equals(described2); } }
Example #20
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Tests that lack of any destination type annotation value (via either * {@link AmqpDestinationHelper#JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL} * or {@link AmqpMessageSupport#LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL}) set * on a message to indicate type of its 'reply-to' address results in it * being classed as the same type as the consumer destination. * * @throws Exception if an error occurs during the test. */ @Test(timeout = 20000) public void testReceivedMessageFromTopicWithReplyToWithoutTypeAnnotationResultsInUseOfConsumerDestinationType() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic("myTopic"); String myReplyTopicAddress = "myReplyTopicAddress"; PropertiesDescribedType props = new PropertiesDescribedType(); props.setReplyTo(myReplyTopicAddress); props.setMessageId("myMessageIDString"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(topic); Message receivedMessage = messageConsumer.receive(3000); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); Destination dest = receivedMessage.getJMSReplyTo(); assertNotNull("JMSReplyTo should not be null", dest); assertTrue("Destination not of expected type: " + dest.getClass(), dest instanceof Topic); assertEquals(myReplyTopicAddress, ((Topic)dest).getTopicName()); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example #21
Source File: Discharge.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if(obj == this) { return true; } if(!(obj instanceof DescribedType)) { return false; } DescribedType d = (DescribedType) obj; if(!(DESCRIPTOR_CODE.equals(d.getDescriptor()) || DESCRIPTOR_SYMBOL.equals(d.getDescriptor()))) { return false; } Object described = getDescribed(); Object described2 = d.getDescribed(); if(described == null) { return described2 == null; } else { return described.equals(described2); } }
Example #22
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Tests that lack of the absolute-expiry-time and ttl fields on a message results * in it returning 0 for for JMSExpiration * * @throws Exception if an error occurs during the test. */ @Test(timeout = 20000) public void testReceivedMessageFromQueueWithNoAbsoluteExpiryOrTtlReturnsJMSExpirationZero() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); PropertiesDescribedType props = new PropertiesDescribedType(); props.setMessageId("myMessageIDString"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); assertEquals(0L, receivedMessage.getJMSExpiration()); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example #23
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
/** * Tests that setting a non-zero value in the absolute-expiry-time field on a * message results in it returning this value for JMSExpiration * * @throws Exception if an error occurs during the test. */ @Test(timeout = 20000) public void testReceivedMessageFromQueueWithAbsoluteExpiryReturnsJMSExpirationNonZero() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { //Disable local expiration checking in consumer Connection connection = testFixture.establishConnecton(testPeer, "?jms.localMessageExpiry=false"); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); long timestamp = System.currentTimeMillis(); PropertiesDescribedType props = new PropertiesDescribedType(); props.setAbsoluteExpiryTime(new Date(timestamp)); props.setMessageId("myMessageIDString"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); assertEquals(timestamp, receivedMessage.getJMSExpiration()); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example #24
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout = 20000) public void testReceiveMessageWithoutMessageId() throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.waitForAllHandlersToComplete(2000); assertNull(receivedMessage.getJMSMessageID()); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example #25
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
private void receivedMessageWithMessageIdTestImpl(Object underlyingAmqpMessageId, String expected) throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); PropertiesDescribedType props = new PropertiesDescribedType(); props.setMessageId(underlyingAmqpMessageId); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); assertEquals(expected, receivedMessage.getJMSMessageID()); assertTrue(receivedMessage.getJMSMessageID().startsWith("ID:")); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(1000); } }
Example #26
Source File: MessageIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
private void receivedMessageWithCorrelationIdTestImpl(Object underlyingCorrelationId, String expected) throws Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); PropertiesDescribedType props = new PropertiesDescribedType(); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); props.setMessageId("myMessageIdString"); props.setCorrelationId(underlyingCorrelationId); testPeer.expectReceiverAttach(); testPeer.expectLinkFlowRespondWithTransfer(null, null, props, null, amqpValueNullContent); testPeer.expectDispositionThatIsAcceptedAndSettled(); MessageConsumer messageConsumer = session.createConsumer(queue); Message receivedMessage = messageConsumer.receive(3000); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(3000); assertNotNull(receivedMessage); assertEquals(expected, receivedMessage.getJMSCorrelationID()); } }
Example #27
Source File: TestAmqpPeer.java From qpid-jms with Apache License 2.0 | 5 votes |
private Object createTargetObjectFromDescribedType(Object o) { assertThat(o, instanceOf(DescribedType.class)); Object described = ((DescribedType) o).getDescribed(); assertThat(described, instanceOf(List.class)); @SuppressWarnings("unchecked") List<Object> targetFields = (List<Object>) described; Object descriptor = ((DescribedType) o).getDescriptor(); if (descriptor == Target.DESCRIPTOR_CODE || descriptor.equals(Target.DESCRIPTOR_SYMBOL)) { return new Target(targetFields.toArray()); } else if (descriptor == Coordinator.DESCRIPTOR_CODE || descriptor.equals(Coordinator.DESCRIPTOR_SYMBOL)) { return new Coordinator(targetFields.toArray()); } else { throw new IllegalArgumentException("Unexpected target descriptor: " + descriptor); } }
Example #28
Source File: Rejected.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if(obj == this) { return true; } if(!(obj instanceof DescribedType)) { return false; } DescribedType d = (DescribedType) obj; if(!(DESCRIPTOR_CODE.equals(d.getDescriptor()) || DESCRIPTOR_SYMBOL.equals(d.getDescriptor()))) { return false; } Object described = getDescribed(); Object described2 = d.getDescribed(); if(described == null) { return described2 == null; } else { return described.equals(described2); } }
Example #29
Source File: Modified.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object obj) { if(obj == this) { return true; } if(!(obj instanceof DescribedType)) { return false; } DescribedType d = (DescribedType) obj; if(!(DESCRIPTOR_CODE.equals(d.getDescriptor()) || DESCRIPTOR_SYMBOL.equals(d.getDescriptor()))) { return false; } Object described = getDescribed(); Object described2 = d.getDescribed(); if(described == null) { return described2 == null; } else { return described.equals(described2); } }
Example #30
Source File: QueueBrowserIntegrationTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test(timeout=30000) public void testCreateQueueBrowserClientAckSession() throws IOException, Exception { try (TestAmqpPeer testPeer = new TestAmqpPeer();) { Connection connection = testFixture.establishConnecton(testPeer); connection.start(); testPeer.expectBegin(); Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); Queue queue = session.createQueue("myQueue"); DescribedType amqpValueNullContent = new AmqpValueDescribedType(null); // Expected the browser to create a consumer and send credit testPeer.expectQueueBrowserAttach(); testPeer.expectLinkFlow(false, equalTo(UnsignedInteger.valueOf(JmsDefaultPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH))); // Then expect it to drain it when no message arrives before hasMoreElements is called, // at which point we send one, and a response flow to indicate the rest of the credit was drained. testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent, 1, true, true, equalTo(UnsignedInteger.valueOf(JmsDefaultPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH)), 1, true, false); // Expect the credit window to be opened again, but accounting for the message we just prefetched. testPeer.expectLinkFlow(false, equalTo(UnsignedInteger.valueOf(JmsDefaultPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH - 1))); testPeer.expectDetach(true, true, true); QueueBrowser browser = session.createBrowser(queue); Enumeration<?> queueView = browser.getEnumeration(); assertNotNull(queueView); assertTrue(queueView.hasMoreElements()); browser.close(); testPeer.expectEnd(); session.close(); testPeer.expectClose(); connection.close(); testPeer.waitForAllHandlersToComplete(3000); } }