Search in sources :

Example 1 with AmqpManagementFacade

use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.

the class HttpTestBase method setUpTestBase.

@Before
public void setUpTestBase() throws Exception {
    System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
    HttpRequestConfig config = getHttpRequestConfig();
    _helper = new HttpTestHelper(getBrokerAdmin(), config != null && config.useVirtualHostAsHost() ? getVirtualHost() : null);
    Protocol protocol = getProtocol();
    AmqpManagementFacade managementFacade = new AmqpManagementFacade(protocol);
    if (protocol == Protocol.AMQP_1_0) {
        _jmsProvider = new QpidJmsClientProvider(managementFacade);
    } else {
        _jmsProvider = new QpidJmsClient0xProvider();
    }
}
Also used : QpidJmsClient0xProvider(org.apache.qpid.systests.QpidJmsClient0xProvider) QpidJmsClientProvider(org.apache.qpid.systests.QpidJmsClientProvider) AmqpManagementFacade(org.apache.qpid.systests.AmqpManagementFacade) Protocol(org.apache.qpid.server.model.Protocol) Before(org.junit.Before)

Example 2 with AmqpManagementFacade

use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.

the class QpidBrokerTestCase method runBare.

@Override
public void runBare() throws Throwable {
    try {
        _managementFacade = new AmqpManagementFacade(BROKER_PROTOCOL);
        _jmsProvider = isBroker10() ? new QpidJmsClientProvider(_managementFacade) : new QpidJmsClient0xProvider();
        _defaultBroker = new BrokerHolderFactory().create(DEFAULT_BROKER_TYPE, DEFAULT_PORT, this);
        super.runBare();
    } catch (Exception e) {
        LOGGER.error("exception", e);
        throw e;
    } finally {
        stopAllBrokers();
        // reset properties used in the test
        revertSystemProperties();
        LOGGER.info("==========  stop " + getTestName() + " ==========");
    }
}
Also used : QpidJmsClient0xProvider(org.apache.qpid.systests.QpidJmsClient0xProvider) QpidJmsClientProvider(org.apache.qpid.systests.QpidJmsClientProvider) AmqpManagementFacade(org.apache.qpid.systests.AmqpManagementFacade) URISyntaxException(java.net.URISyntaxException) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException)

Example 3 with AmqpManagementFacade

use of org.apache.qpid.systests.AmqpManagementFacade in project qpid-broker-j by apache.

the class AmqpManagementTest method testInvokeSecureOperation.

@Test
public void testInvokeSecureOperation() throws Exception {
    assumeThat(isSupportedClient(), is(true));
    // // a secure operation
    String secureOperation = "publishMessage";
    Map<String, String> operationArg = new HashMap<>();
    operationArg.put("address", ExchangeDefaults.FANOUT_EXCHANGE_NAME);
    operationArg.put("content", "Hello, world!");
    Connection unsecuredConnection = getConnection();
    try {
        setUp(unsecuredConnection);
        MapMessage plainRequest = _session.createMapMessage();
        plainRequest.setStringProperty("type", "org.apache.qpid.VirtualHost");
        plainRequest.setStringProperty("operation", secureOperation);
        plainRequest.setStringProperty("index", "object-path");
        plainRequest.setStringProperty("key", "");
        plainRequest.setStringProperty("message", new ObjectMapper().writeValueAsString(operationArg));
        plainRequest.setJMSReplyTo(_replyAddress);
        _producer.send(plainRequest);
        Message responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 403);
    } finally {
        unsecuredConnection.close();
    }
    int tlsPort = TlsTest.createTlsPort(getTestName() + "TlsPort", false, false, false, getConnectionBuilder(), new AmqpManagementFacade(getProtocol()), getBrokerAdmin().getBrokerAddress(BrokerAdmin.PortType.AMQP).getPort());
    Connection connection = getConnectionBuilder().setTls(true).setSslPort(tlsPort).setTrustStoreLocation(TRUSTSTORE).setTrustStorePassword(TRUSTSTORE_PASSWORD).build();
    try {
        setUp(connection);
        MapMessage secureRequest = _session.createMapMessage();
        secureRequest.setStringProperty("type", "org.apache.qpid.VirtualHost");
        secureRequest.setStringProperty("operation", secureOperation);
        secureRequest.setStringProperty("index", "object-path");
        secureRequest.setStringProperty("key", "");
        secureRequest.setStringProperty("message", new ObjectMapper().writeValueAsString(operationArg));
        secureRequest.setJMSReplyTo(_replyAddress);
        _producer.send(secureRequest);
        Message responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 200);
    } finally {
        connection.close();
    }
}
Also used : MapMessage(javax.jms.MapMessage) ObjectMessage(javax.jms.ObjectMessage) Message(javax.jms.Message) HashMap(java.util.HashMap) MapMessage(javax.jms.MapMessage) Connection(javax.jms.Connection) AmqpManagementFacade(org.apache.qpid.systests.AmqpManagementFacade) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TlsTest(org.apache.qpid.systests.jms_1_1.extensions.tls.TlsTest) Test(org.junit.Test)

Aggregations

AmqpManagementFacade (org.apache.qpid.systests.AmqpManagementFacade)3 QpidJmsClient0xProvider (org.apache.qpid.systests.QpidJmsClient0xProvider)2 QpidJmsClientProvider (org.apache.qpid.systests.QpidJmsClientProvider)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Connection (javax.jms.Connection)1 JMSException (javax.jms.JMSException)1 MapMessage (javax.jms.MapMessage)1 Message (javax.jms.Message)1 ObjectMessage (javax.jms.ObjectMessage)1 NamingException (javax.naming.NamingException)1 Protocol (org.apache.qpid.server.model.Protocol)1 TlsTest (org.apache.qpid.systests.jms_1_1.extensions.tls.TlsTest)1 Before (org.junit.Before)1 Test (org.junit.Test)1