Search in sources :

Example 1 with Interaction

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

the class MixedPolicy method firstRefuseThenClose.

@Test
public void firstRefuseThenClose() throws Exception {
    try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction1 = transport1.newInteraction();
        interaction1.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse(Open.class);
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, CLOSE_EXISTING)).open().consumeResponse(Open.class).consumeResponse(Close.class);
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test)

Example 2 with Interaction

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

the class RefuseConnectionPolicy method strongDetection.

@Test
public void strongDetection() throws Exception {
    try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction1 = transport1.newInteraction();
        final Open responseOpen = interaction1.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse().getLatestResponse(Open.class);
        assertThat(Arrays.asList(responseOpen.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
        if (responseOpen.getProperties().containsKey(SOLE_CONNECTION_DETECTION_POLICY)) {
            assumeThat(responseOpen.getProperties().get(SOLE_CONNECTION_DETECTION_POLICY), is(equalTo(SoleConnectionDetectionPolicy.STRONG.getValue())));
        }
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            // Omit setting the desired capability to test strong detection
            final Open responseOpen2 = interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").open().consumeResponse().getLatestResponse(Open.class);
            assertThat(Arrays.asList(responseOpen2.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
            assertThat(responseOpen2.getProperties(), hasKey(Symbol.valueOf("amqp:connection-establishment-failed")));
            assertThat(responseOpen2.getProperties().get(Symbol.valueOf("amqp:connection-establishment-failed")), is(true));
            final Close close2 = interaction2.consumeResponse().getLatestResponse(Close.class);
            assertThat(close2.getError(), is(notNullValue()));
            assertThat(close2.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
            assertThat(close2.getError().getInfo(), is(equalTo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")))));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test)

Example 3 with Interaction

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

the class RefuseConnectionPolicy method newConnectionRefused.

@Test
public void newConnectionRefused() throws Exception {
    try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction1 = transport1.newInteraction();
        interaction1.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse(Open.class);
        try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
            final Interaction interaction2 = transport2.newInteraction();
            final Open responseOpen2 = interaction2.negotiateProtocol().consumeResponse().openContainerId("testContainerId").openDesiredCapabilities(SOLE_CONNECTION_FOR_CONTAINER).openProperties(Collections.singletonMap(SOLE_CONNECTION_ENFORCEMENT_POLICY, REFUSE_CONNECTION)).open().consumeResponse().getLatestResponse(Open.class);
            assertThat(Arrays.asList(responseOpen2.getOfferedCapabilities()), hasItem(SOLE_CONNECTION_FOR_CONTAINER));
            assertThat(responseOpen2.getProperties(), hasKey(Symbol.valueOf("amqp:connection-establishment-failed")));
            assertThat(responseOpen2.getProperties().get(Symbol.valueOf("amqp:connection-establishment-failed")), is(true));
            final Close close2 = interaction2.consumeResponse().getLatestResponse(Close.class);
            assertThat(close2.getError(), is(notNullValue()));
            assertThat(close2.getError().getCondition(), is(equalTo(AmqpError.INVALID_FIELD)));
            assertThat(close2.getError().getInfo(), is(equalTo(Collections.singletonMap(Symbol.valueOf("invalid-field"), Symbol.valueOf("container-id")))));
        }
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) Test(org.junit.Test)

Example 4 with Interaction

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

the class TransferTest method transferWithoutDeliveryTag.

@Test
@SpecificationTest(section = "2.7.5", description = "[delivery-tag] MUST be specified for the first transfer " + "[...] and can only be omitted for continuation transfers.")
public void transferWithoutDeliveryTag() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        Interaction interaction = transport.newInteraction().negotiateProtocol().consumeResponse().open().consumeResponse(Open.class).begin().consumeResponse(Begin.class).attachRole(Role.SENDER).attachTargetAddress(BrokerAdmin.TEST_QUEUE_NAME).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferDeliveryTag(null).transferPayloadData("testData").transfer();
        interaction.consumeResponse(Detach.class, End.class, Close.class);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Flow(org.apache.qpid.server.protocol.v1_0.type.transport.Flow) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with Interaction

use of org.apache.qpid.tests.protocol.v0_8.Interaction in project libSBOLj by SynBioDex.

the class ModuleDefinitionOutput method createInverter.

private static void createInverter(SBOLDocument document, ModuleDefinition moduleDef, ComponentDefinition promoter, ComponentDefinition TF) throws Exception {
    FunctionalComponent laciInverterModuleDef_promoter = moduleDef.createFunctionalComponent("promoter", AccessType.PUBLIC, promoter.getIdentity(), DirectionType.INOUT);
    FunctionalComponent laciInverterModuleDef_TF = moduleDef.createFunctionalComponent("TF", AccessType.PUBLIC, TF.getIdentity(), DirectionType.INOUT);
    Interaction interaction = moduleDef.createInteraction("LacI_pLacI", new HashSet<URI>(Arrays.asList(toURI(Terms.interactionTypes.transcriptionalRepression))));
    Participation participation = interaction.createParticipation(promoter.getDisplayId(), laciInverterModuleDef_promoter.getIdentity(), toURI(Terms.participantRoles.promoter));
    Participation participation2 = interaction.createParticipation(TF.getDisplayId(), laciInverterModuleDef_TF.getIdentity(), toURI(Terms.participantRoles.inhibitor));
}
Also used : Participation(org.sbolstandard.core2.Participation) Interaction(org.sbolstandard.core2.Interaction) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) URI(java.net.URI)

Aggregations

Test (org.junit.Test)170 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)142 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)141 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)115 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)80 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)50 UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)48 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)43 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)35 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)29 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)27 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)26 Accepted (org.apache.qpid.server.protocol.v1_0.type.messaging.Accepted)25 Interaction (org.apache.qpid.tests.protocol.v0_8.Interaction)24 FrameTransport (org.apache.qpid.tests.protocol.v0_8.FrameTransport)23 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)22 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)20 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)16 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)13 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)13