ARTEMIS-3820 Fix browsing original queue of AMQP messages
This commit is contained in:
parent
f3954961e3
commit
15d839a6b0
|
@ -339,7 +339,7 @@ var Artemis;
|
|||
itemField: 'StringProperties',
|
||||
header: 'Original Queue',
|
||||
templateFn: function(value) {
|
||||
return value._AMQ_ORIG_QUEUE;
|
||||
return (value['_AMQ_ORIG_QUEUE'] ? value['_AMQ_ORIG_QUEUE'] : value['extraProperties._AMQ_ORIG_QUEUE']);
|
||||
}
|
||||
};
|
||||
ctrl.tableColumns.push(origQueue);
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
|
||||
package org.apache.activemq.artemis.tests.smoke.console;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
|
||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
|
||||
import org.apache.activemq.artemis.cli.commands.messages.Producer;
|
||||
|
@ -26,11 +29,14 @@ import org.apache.activemq.artemis.tests.smoke.console.pages.QueuePage;
|
|||
import org.apache.activemq.artemis.tests.smoke.console.pages.QueuesPage;
|
||||
import org.apache.activemq.artemis.tests.smoke.console.pages.StatusPage;
|
||||
import org.apache.activemq.artemis.utils.Wait;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.openqa.selenium.MutableCapabilities;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class QueuesTest extends ConsoleTest {
|
||||
|
||||
|
@ -101,4 +107,61 @@ public class QueuesTest extends ConsoleTest {
|
|||
Wait.assertEquals(1, () -> afterQueuesPage.countQueue("DLQ"));
|
||||
Wait.assertEquals(0, () -> afterQueuesPage.getMessagesCount(queueName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpiryQueue() throws Exception {
|
||||
final int messages = 1;
|
||||
final String expiryQueueName = "ExpiryQueue";
|
||||
final String testQueueName = "TEST";
|
||||
final String messageText = "TEST";
|
||||
final ObjectNameBuilder objectNameBuilder = ObjectNameBuilder.create(null, "0.0.0.0", true);
|
||||
final ObjectName expiryQueueObjectName = objectNameBuilder.getQueueObjectName(
|
||||
SimpleString.toSimpleString(expiryQueueName),
|
||||
SimpleString.toSimpleString(expiryQueueName),
|
||||
RoutingType.ANYCAST);
|
||||
final ObjectName testQueueObjectName = objectNameBuilder.getQueueObjectName(
|
||||
SimpleString.toSimpleString(testQueueName),
|
||||
SimpleString.toSimpleString(testQueueName),
|
||||
RoutingType.ANYCAST);
|
||||
|
||||
driver.get(serverUrl + "/console");
|
||||
LoginPage loginPage = new LoginPage(driver);
|
||||
StatusPage statusPage = loginPage.loginValidUser(
|
||||
SERVER_ADMIN_USERNAME, SERVER_ADMIN_PASSWORD, DEFAULT_TIMEOUT);
|
||||
Assert.assertTrue(statusPage.postJolokiaExecRequest(expiryQueueObjectName.getCanonicalName(),
|
||||
"removeAllMessages()", "").toString().contains("\"status\":200"));
|
||||
|
||||
QueuesPage beforeQueuesPage = statusPage.getQueuesPage(DEFAULT_TIMEOUT);
|
||||
Wait.assertEquals(1, () -> beforeQueuesPage.countQueue("ExpiryQueue"));
|
||||
Wait.assertEquals(0, () -> beforeQueuesPage.countQueue(testQueueName));
|
||||
|
||||
Producer producer = new Producer();
|
||||
producer.setUser(SERVER_ADMIN_USERNAME);
|
||||
producer.setPassword(SERVER_ADMIN_PASSWORD);
|
||||
producer.setDestination(testQueueName);
|
||||
producer.setMessageCount(messages);
|
||||
producer.setMessage(messageText);
|
||||
producer.setSilentInput(true);
|
||||
producer.setProtocol("amqp");
|
||||
producer.execute(new ActionContext());
|
||||
|
||||
beforeQueuesPage.refresh(DEFAULT_TIMEOUT);
|
||||
Wait.assertEquals(1, () -> beforeQueuesPage.countQueue(expiryQueueName));
|
||||
assertEquals(0, beforeQueuesPage.getMessagesCount(expiryQueueName));
|
||||
Wait.assertEquals(1, () -> beforeQueuesPage.countQueue(testQueueName));
|
||||
assertEquals(messages, beforeQueuesPage.getMessagesCount(testQueueName));
|
||||
|
||||
QueuePage queuePage = beforeQueuesPage.getQueuePage(testQueueName, DEFAULT_TIMEOUT);
|
||||
Assert.assertTrue(queuePage.postJolokiaExecRequest(testQueueObjectName.getCanonicalName(), "expireMessage(long)",
|
||||
String.valueOf(queuePage.getMessageId(0))).toString().contains("\"status\":200"));
|
||||
|
||||
QueuesPage afterQueuesPage = queuePage.getQueuesPage(DEFAULT_TIMEOUT);
|
||||
Wait.assertEquals(1, () -> afterQueuesPage.countQueue(expiryQueueName));
|
||||
assertEquals(messages, afterQueuesPage.getMessagesCount(expiryQueueName));
|
||||
Wait.assertEquals(1, () -> beforeQueuesPage.countQueue(testQueueName));
|
||||
assertEquals(0, afterQueuesPage.getMessagesCount(testQueueName));
|
||||
|
||||
QueuePage dlqPage = afterQueuesPage.getQueuePage(expiryQueueName, DEFAULT_TIMEOUT);
|
||||
assertEquals(testQueueName, dlqPage.getMessageOriginalQueue(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ import java.util.List;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.activemq.artemis.utils.StringEscapeUtils;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
|
@ -75,4 +77,21 @@ public abstract class ArtemisPage extends ConsolePage {
|
|||
|
||||
return new QueuesPage(driver);
|
||||
}
|
||||
|
||||
public Object postJolokiaExecRequest(String mbean, String operation, String arguments) {
|
||||
Object response = ((JavascriptExecutor) driver).executeAsyncScript(
|
||||
"var callback = arguments[arguments.length - 1];" +
|
||||
"var xhr = new XMLHttpRequest();" +
|
||||
"xhr.open('POST', '/console/jolokia', true);" +
|
||||
"xhr.onreadystatechange = function() {" +
|
||||
" if (xhr.readyState == 4) {" +
|
||||
" callback(xhr.responseText);" +
|
||||
" }" +
|
||||
"};" +
|
||||
"xhr.send('{\"type\":\"exec\",\"mbean\":\"" + StringEscapeUtils.escapeString(StringEscapeUtils.escapeString(mbean)) +
|
||||
"\",\"operation\":\"" + StringEscapeUtils.escapeString(StringEscapeUtils.escapeString(operation)) +
|
||||
"\",\"arguments\":[" + StringEscapeUtils.escapeString(arguments) + "]}');");
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,13 @@ package org.apache.activemq.artemis.tests.smoke.console.pages;
|
|||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QueuePage extends ArtemisPage {
|
||||
private By messageRowLocator = By.cssSelector("tr[role='row'][class='ng-scope odd']");
|
||||
|
||||
public QueuePage(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
@ -32,4 +37,35 @@ public class QueuePage extends ArtemisPage {
|
|||
|
||||
return new MessagePage(driver);
|
||||
}
|
||||
|
||||
public long getMessageId(int index) {
|
||||
WebElement messageRowWebElement = driver.findElements(messageRowLocator).get(index);
|
||||
|
||||
String messageIdText = messageRowWebElement.findElements(By.tagName("td")).get(
|
||||
getIndexOfColumn("Message ID")).findElement(By.tagName("span")).getText();
|
||||
|
||||
return Long.parseLong(messageIdText);
|
||||
}
|
||||
|
||||
public String getMessageOriginalQueue(int index) {
|
||||
WebElement messageRowWebElement = driver.findElements(messageRowLocator).get(index);
|
||||
|
||||
String messageOriginalQueue = messageRowWebElement.findElements(By.tagName("td")).get(
|
||||
getIndexOfColumn("Original Queue")).findElement(By.tagName("span")).getText();
|
||||
|
||||
return messageOriginalQueue;
|
||||
}
|
||||
|
||||
public int getIndexOfColumn(String name) {
|
||||
WebElement headerRowWebElement = driver.findElement(By.cssSelector("tr[role='row']"));
|
||||
|
||||
List<WebElement> columnWebElements = headerRowWebElement.findElements(By.tagName("th"));
|
||||
for (int i = 0; i < columnWebElements.size(); i++) {
|
||||
if (name.equals(columnWebElements.get(i).getText())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue