Search in sources :

Example 16 with FrameTransport

use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.

the class ProtocolHeaderTimeoutTest method incompleteProtocolHeader.

@Test
public void incompleteProtocolHeader() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final byte[] protocolHeader = transport.getProtocolHeader();
        byte[] buf = new byte[1];
        for (int i = 0; i < (protocolHeader.length - 1); i++) {
            System.arraycopy(protocolHeader, i, buf, 0, 1);
            transport.sendBytes(buf);
            transport.flush();
        }
        transport.assertNoMoreResponsesAndChannelClosed();
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 17 with FrameTransport

use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.

the class TransactionTimeoutTest method publishTransactionTimeout.

@Test
public void publishTransactionTimeout() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.openAnonymousConnection().channel().open().consumeResponse(ChannelOpenOkBody.class).tx().select().consumeResponse(TxSelectOkBody.class).basic().contentHeaderPropertiesContentType("text/plain").contentHeaderPropertiesHeaders(Collections.singletonMap("test", "testValue")).contentHeaderPropertiesDeliveryMode((byte) 1).contentHeaderPropertiesPriority((byte) 1).publishExchange("").publishRoutingKey(BrokerAdmin.TEST_QUEUE_NAME).content("Test").publishMessage().exchange().declarePassive(true).declare().consumeResponse(ExchangeDeclareOkBody.class);
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
        final ConnectionCloseBody close = interaction.consumeResponse().getLatestResponse(ConnectionCloseBody.class);
        assertThat(close.getReplyCode(), is(equalTo(ErrorCodes.RESOURCE_ERROR)));
        assertThat(close.getReplyText().toString(), containsString("transaction timed out"));
        interaction.connection().closeOk();
        assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v0_8.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v0_8.Interaction) TxSelectOkBody(org.apache.qpid.server.protocol.v0_8.transport.TxSelectOkBody) ConnectionCloseBody(org.apache.qpid.server.protocol.v0_8.transport.ConnectionCloseBody) Test(org.junit.Test)

Example 18 with FrameTransport

use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.

the class AnonymousTerminusTest method transferPreSettledToKnownDestination.

@SpecificationTest(section = "Using the Anonymous Terminus for Message Routing. 2.2. Sending A Message", description = "Messages sent over links into a routing node will be" + " forwarded to the node referenced in the to field of properties of the message" + " just as if a direct link has been established to that node.")
@Test
public void transferPreSettledToKnownDestination() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(generateMessagePayloadToDestination(BrokerAdmin.TEST_QUEUE_NAME)).transferSettled(Boolean.TRUE).transferDeliveryTag(_deliveryTag).transfer().sync();
        Object receivedMessage = Utils.receiveMessage(_brokerAddress, BrokerAdmin.TEST_QUEUE_NAME);
        assertThat(receivedMessage, is(equalTo(TEST_MESSAGE_CONTENT)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 19 with FrameTransport

use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.

the class AnonymousTerminusTest method transferUnsettledInTransactionToUnknownDestinationWhenRejectedOutcomeSupportedBySource.

@Test
public void transferUnsettledInTransactionToUnknownDestinationWhenRejectedOutcomeSupportedBySource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        final UnsignedInteger linkHandle = UnsignedInteger.ONE;
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        interaction.begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL, Rejected.REJECTED_SYMBOL).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayload(generateMessagePayloadToDestination("Unknown")).transferDeliveryTag(_deliveryTag).transferTransactionalState(txnState.getCurrentTransactionId()).transferSettled(Boolean.FALSE).transfer();
        Disposition disposition = interaction.consumeResponse().getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(true));
        DeliveryState dispositionState = disposition.getState();
        assertThat(dispositionState, is(instanceOf(TransactionalState.class)));
        final TransactionalState receivedTxnState = (TransactionalState) dispositionState;
        assertThat(receivedTxnState.getOutcome(), is(instanceOf(Rejected.class)));
        final Error rejectedError = ((Rejected) receivedTxnState.getOutcome()).getError();
        assertThat(rejectedError.getCondition(), is(equalTo(AmqpError.NOT_FOUND)));
        assertThat(rejectedError.getInfo(), is(notNullValue()));
        assertThat(rejectedError.getInfo().get(DELIVERY_TAG), is(equalTo(_deliveryTag)));
        interaction.txnDischarge(txnState, false);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) DeliveryState(org.apache.qpid.server.protocol.v1_0.type.DeliveryState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) TransactionalState(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionalState) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 20 with FrameTransport

use of org.apache.qpid.tests.protocol.v0_8.FrameTransport in project qpid-broker-j by apache.

the class AnonymousTerminusTest method transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource.

@SpecificationTest(section = "Using the Anonymous Terminus for Message Routing. 2.2.2 Routing Errors", description = "It is possible that a message sent to a routing node has an address in the to field" + " of properties which, if used in the address field of target of an attach," + " would result in an unsuccessful link establishment (for example," + " if the address cannot be resolved to a node). In this case the routing node" + " MUST communicate the error back to the sender of the message." + " [...]" + " If the source of the link does not support the rejected outcome," + " [...] then the routing node MUST detach the link with an error." + " [...] the info field of error MUST contain an entry with symbolic key delivery-tag" + " and binary value of the delivery-tag of the message which caused the failure.")
@Test
public void transferUnsettledToUnknownDestinationWhenRejectedOutcomeNotSupportedBySource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        interaction.begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferPayload(generateMessagePayloadToDestination("Unknown")).transferDeliveryTag(_deliveryTag).transfer();
        Detach detach = interaction.consumeResponse().getLatestResponse(Detach.class);
        Error error = detach.getError();
        assertThat(error, is(notNullValue()));
        assertThat(error.getCondition(), is(equalTo(AmqpError.NOT_FOUND)));
        assertThat(error.getInfo(), is(notNullValue()));
        assertThat(error.getInfo().get(DELIVERY_TAG), is(equalTo(_deliveryTag)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

Test (org.junit.Test)136 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)125 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)116 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)100 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)57 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)56 InetSocketAddress (java.net.InetSocketAddress)45 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)39 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)37 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)35 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)32 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)29 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)24 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)18 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)16 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)16 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)14 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)11 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)10