Package org.apache.qpid.systest.rest

Examples of org.apache.qpid.systest.rest.RestTestHelper


        stopBroker();

        _monitor.markDiscardPoint();

        RestTestHelper restTestHelper = new RestTestHelper(findFreePort());
        TestBrokerConfiguration config = getBrokerConfiguration();
        config.addHttpManagementConfiguration();
        config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.PORT, restTestHelper.getHttpPort());
        config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_JMX_PORT);
        config.removeObjectConfiguration(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT);

        Map<String, Object> anonymousProviderAttributes = new HashMap<String, Object>();
        anonymousProviderAttributes.put(AuthenticationProvider.TYPE, AnonymousAuthenticationManager.PROVIDER_TYPE);
        anonymousProviderAttributes.put(AuthenticationProvider.NAME, "testAnonymous");
        config.addObjectConfiguration(AuthenticationProvider.class, anonymousProviderAttributes);

        // set password authentication provider on http port for the tests
        config.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_PORT, Port.AUTHENTICATION_PROVIDER,
                TestBrokerConfiguration.ENTRY_NAME_AUTHENTICATION_PROVIDER);
        config.setObjectAttribute(Plugin.class, TestBrokerConfiguration.ENTRY_NAME_HTTP_MANAGEMENT, HttpManagement.HTTP_BASIC_AUTHENTICATION_ENABLED, true);
        config.setSaved(false);
        restTestHelper.setUsernameAndPassword("webadmin", "webadmin");

        startBroker();

        setupConnection();

        // Validate the queue depth is as expected
        long messageCount = ((AMQSession<?, ?>) _session).getQueueDepth((AMQDestination) _destination);
        assertEquals("Broker has invalid message count for test", 2, messageCount);

        // Ensure the alert has not occurred yet
        assertLoggingNotYetOccured(MESSAGE_COUNT_ALERT);

        // Change max message count to 5, start broker and make sure that that's triggered at the right time
        TestBrokerConfiguration brokerConfiguration = getBrokerConfiguration();
        setTestSystemProperty("queue.alertThresholdQueueDepthMessages","5");
        brokerConfiguration.setSaved(false);

        restTestHelper.submitRequest("queue/test/test/" + getTestQueueName(), "PUT", Collections.<String, Object>singletonMap(org.apache.qpid.server.model.Queue.ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, 5));
        // Trigger the new value
        sendMessage(_session, _destination, 3);
        _session.commit();

        // Validate that the alert occurred.
View Full Code Here


    }

    public void setNodeAttributes(int localNodePort, int remoteNodePort, Map<String, Object> attributeMap)
            throws Exception
    {
        RestTestHelper restHelper = createRestTestHelper(localNodePort);
        String url = getNodeRestUrl(localNodePort, remoteNodePort);
        int status = restHelper.submitRequest(url, "PUT", attributeMap);
        if (status != 200)
        {
            throw new Exception("Unexpected http status when updating " + getNodeNameForBrokerPort(remoteNodePort) + " attribute(s) : " + status);
        }
    }
View Full Code Here

        return getNodeAttributes(brokerPort, brokerPort);
    }

    public Map<String, Object> getNodeAttributes(int localNodePort, int remoteNodePort) throws IOException
    {
        RestTestHelper restHelper = createRestTestHelper(localNodePort);
        List<Map<String, Object>> results= restHelper.getJsonAsList(getNodeRestUrl(localNodePort, remoteNodePort));
        int size = results.size();
        if (size == 0)
        {
            return Collections.emptyMap();
        }
View Full Code Here

    }

    public RestTestHelper createRestTestHelper(int brokerPort)
    {
        int httpPort = _testcase.getHttpManagementPort(brokerPort);
        RestTestHelper helper = new RestTestHelper(httpPort);
        helper.setUsernameAndPassword("webadmin", "webadmin");
        return helper;
    }
View Full Code Here

    public void awaitVirtualHostAtNode(int brokerPort) throws Exception
    {
        final long startTime = System.currentTimeMillis();
        Map<String, Object> data = Collections.emptyMap();
        String nodeName = _clusterCreator.getNodeNameForBrokerPort(brokerPort);
        RestTestHelper restHelper = _clusterCreator.createRestTestHelper(brokerPort);
        while(!State.ACTIVE.name().equals(data.get(VirtualHost.STATE)) && (System.currentTimeMillis() - startTime) < 30000)
        {
            LOGGER.debug("Awaiting virtual host '" + nodeName + "' to transit into active state");
            List<Map<String, Object>> results= restHelper.getJsonAsList("virtualhost/" + nodeName + "/" + VIRTUAL_HOST);
            if (results.size()== 1)
            {
                data = results.get(0);
            }
View Full Code Here

    }

    public void setNodeAttributes(int localNodePort, int remoteNodePort, Map<String, Object> attributeMap)
            throws Exception
    {
        RestTestHelper restHelper = createRestTestHelper(localNodePort);
        String url = getNodeRestUrl(localNodePort, remoteNodePort);
        int status = restHelper.submitRequest(url, "PUT", attributeMap);
        if (status != 200)
        {
            throw new Exception("Unexpected http status when updating " + getNodeNameForBrokerPort(remoteNodePort) + " attribute(s) : " + status);
        }
    }
View Full Code Here

        return getNodeAttributes(brokerPort, brokerPort);
    }

    public Map<String, Object> getNodeAttributes(int localNodePort, int remoteNodePort) throws IOException
    {
        RestTestHelper restHelper = createRestTestHelper(localNodePort);
        List<Map<String, Object>> results= restHelper.getJsonAsList(getNodeRestUrl(localNodePort, remoteNodePort));
        int size = results.size();
        if (size == 0)
        {
            return Collections.emptyMap();
        }
View Full Code Here

    }

    public RestTestHelper createRestTestHelper(int brokerPort)
    {
        int httpPort = _testcase.getHttpManagementPort(brokerPort);
        RestTestHelper helper = new RestTestHelper(httpPort);
        helper.setUsernameAndPassword("webadmin", "webadmin");
        return helper;
    }
View Full Code Here

    public void awaitVirtualHostAtNode(int brokerPort) throws Exception
    {
        final long startTime = System.currentTimeMillis();
        Map<String, Object> data = Collections.emptyMap();
        String nodeName = _clusterCreator.getNodeNameForBrokerPort(brokerPort);
        RestTestHelper restHelper = _clusterCreator.createRestTestHelper(brokerPort);
        while(!State.ACTIVE.name().equals(data.get(VirtualHost.STATE)) && (System.currentTimeMillis() - startTime) < 30000)
        {
            LOGGER.debug("Awaiting virtual host '" + nodeName + "' to transit into active state");
            List<Map<String, Object>> results= restHelper.getJsonAsList("virtualhost/" + nodeName + "/" + VIRTUAL_HOST);
            if (results.size()== 1)
            {
                data = results.get(0);
            }
View Full Code Here

TOP

Related Classes of org.apache.qpid.systest.rest.RestTestHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.