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();
}
}
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);
}
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);
}
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();
}
}
Aggregations