Search in sources :

Example 1 with HttpRequestConfig

use of org.apache.qpid.tests.http.HttpRequestConfig in project qpid-broker-j by apache.

the class StatisticsReportingTest method brokerStatistics.

@Test
@HttpRequestConfig(useVirtualHostAsHost = false)
public void brokerStatistics() throws Exception {
    String logDownloadUrl = configureLogger(false);
    Connection conn = getConnection();
    try {
        final Map<String, Object> args1 = new HashMap<>();
        args1.put("name", "qpid.broker.statisticsReportPattern");
        args1.put("value", "messagesIn=${messagesIn}");
        getHelper().submitRequest("broker/setContextVariable", "POST", args1, SC_OK);
        final Map<String, Object> attrs = Collections.singletonMap(Broker.STATISTICS_REPORTING_PERIOD, STATISTICS_REPORTING_PERIOD_IN_SEC);
        getHelper().submitRequest("broker", "POST", attrs, SC_OK);
        getBrokerAdmin().createQueue(QUEUE1_NAME);
        Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
        assertThat("Pre-enqueue statistics report not found", countLogFileMatches(logDownloadUrl, "messagesIn=0", LOG_TIMEOUT_IN_MS), is(greaterThan(0)));
        // Enqueue a single message to queue 1
        Utils.sendMessages(session, session.createQueue(QUEUE1_NAME), 1);
        assertThat("Post-enqueue statistics report not found", countLogFileMatches(logDownloadUrl, "messagesIn=1", LOG_TIMEOUT_IN_MS), is(greaterThan(0)));
    } finally {
        getHelper().submitRequest("broker/removeContextVariable", "POST", singletonMap("name", "qpid.broker.statisticsReportPattern"), SC_OK);
        getHelper().submitRequest("broker/removeContextVariable", "POST", singletonMap("name", Broker.STATISTICS_REPORTING_PERIOD), SC_OK);
        getHelper().submitRequest("brokerlogger/statslogger", "DELETE", SC_OK);
        conn.close();
    }
}
Also used : HashMap(java.util.HashMap) HttpURLConnection(java.net.HttpURLConnection) Connection(javax.jms.Connection) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Session(javax.jms.Session) Test(org.junit.Test) HttpRequestConfig(org.apache.qpid.tests.http.HttpRequestConfig)

Example 2 with HttpRequestConfig

use of org.apache.qpid.tests.http.HttpRequestConfig in project qpid-broker-j by apache.

the class VirtualHostRecoveryTest method virtualHostNodeRestart.

@Test
@HttpRequestConfig(useVirtualHostAsHost = false)
public void virtualHostNodeRestart() throws Exception {
    final TextMessage sentMessage = putMessageOnQueue();
    final String url = String.format("virtualhostnode/%s", getVirtualHostNode());
    changeState(url, "STOPPED");
    assertState(url, "STOPPED");
    changeState(url, "ACTIVE");
    assertState(url, "ACTIVE");
    verifyMessagesOnQueue(sentMessage);
}
Also used : TextMessage(javax.jms.TextMessage) Test(org.junit.Test) HttpRequestConfig(org.apache.qpid.tests.http.HttpRequestConfig)

Example 3 with HttpRequestConfig

use of org.apache.qpid.tests.http.HttpRequestConfig in project qpid-broker-j by apache.

the class VirtualHostRecoveryTest method virtualHostRestart.

@Test
@HttpRequestConfig(useVirtualHostAsHost = true)
public void virtualHostRestart() throws Exception {
    final TextMessage sentMessage = putMessageOnQueue();
    final String url = "virtualhost";
    changeState(url, "STOPPED");
    assertState(url, "STOPPED");
    changeState(url, "ACTIVE");
    assertState(url, "ACTIVE");
    verifyMessagesOnQueue(sentMessage);
}
Also used : TextMessage(javax.jms.TextMessage) Test(org.junit.Test) HttpRequestConfig(org.apache.qpid.tests.http.HttpRequestConfig)

Example 4 with HttpRequestConfig

use of org.apache.qpid.tests.http.HttpRequestConfig in project qpid-broker-j by apache.

the class ReadTest method valueFilteredSecureAttributes.

@Test
@HttpRequestConfig(useVirtualHostAsHost = false)
public void valueFilteredSecureAttributes() throws Exception {
    final KeyCertificatePair keyCertPair = generateCertKeyPair();
    final byte[] privateKey = keyCertPair.getPrivateKey().getEncoded();
    final byte[] cert = keyCertPair.getCertificate().getEncoded();
    final String privateKeyUrl = DataUrlUtils.getDataUrlForBytes(privateKey);
    final String certUrl = DataUrlUtils.getDataUrlForBytes(cert);
    final File privateKeyFile = File.createTempFile("foo" + System.currentTimeMillis(), "key");
    privateKeyFile.deleteOnExit();
    FileUtils.copy(new ByteArrayInputStream(privateKey), privateKeyFile);
    Map<String, Object> base = new HashMap<>();
    base.put(NonJavaKeyStore.TYPE, "NonJavaKeyStore");
    base.put(NonJavaKeyStore.CERTIFICATE_URL, certUrl);
    try {
        {
            final String storeUrl = "keystore/mystoreDataUrl";
            final Map<String, Object> attrs = new HashMap<>(base);
            attrs.put(NonJavaKeyStore.PRIVATE_KEY_URL, privateKeyUrl);
            getHelper().submitRequest(storeUrl, "PUT", attrs, SC_CREATED);
            final Map<String, Object> store = getHelper().getJsonAsMap(storeUrl);
            assertThat(store.get(NonJavaKeyStore.PRIVATE_KEY_URL), is(equalTo(AbstractConfiguredObject.SECURED_STRING_VALUE)));
            getHelper().submitRequest(storeUrl, "DELETE", SC_OK);
        }
        {
            final String privateKeyFileUrl = privateKeyFile.toURI().toString();
            final String storeUrl = "keystore/mystoreFileUrl";
            final Map<String, Object> attrs = new HashMap<>(base);
            attrs.put(NonJavaKeyStore.TYPE, "NonJavaKeyStore");
            attrs.put(NonJavaKeyStore.PRIVATE_KEY_URL, privateKeyFileUrl);
            getHelper().submitRequest(storeUrl, "PUT", attrs, SC_CREATED);
            final Map<String, Object> store = getHelper().getJsonAsMap(String.format("%s?oversize=%d", storeUrl, privateKeyFileUrl.length()));
            assertThat(store.get(NonJavaKeyStore.PRIVATE_KEY_URL), is(equalTo(privateKeyFileUrl)));
            getHelper().submitRequest(storeUrl, "DELETE", SC_OK);
        }
    } finally {
        privateKeyFile.delete();
    }
}
Also used : KeyCertificatePair(org.apache.qpid.test.utils.tls.KeyCertificatePair) ByteArrayInputStream(java.io.ByteArrayInputStream) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Test(org.junit.Test) HttpRequestConfig(org.apache.qpid.tests.http.HttpRequestConfig)

Aggregations

HttpRequestConfig (org.apache.qpid.tests.http.HttpRequestConfig)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)2 TextMessage (javax.jms.TextMessage)2 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 HttpURLConnection (java.net.HttpURLConnection)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Map (java.util.Map)1 Connection (javax.jms.Connection)1 Session (javax.jms.Session)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 KeyCertificatePair (org.apache.qpid.test.utils.tls.KeyCertificatePair)1