You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/03/27 19:42:35 UTC
[activemq-artemis] branch master updated: ARTEMIS-2681 timestamp
not set on notif msgs
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 59e07c9 ARTEMIS-2681 timestamp not set on notif msgs
new 9659824 This closes #3049
59e07c9 is described below
commit 59e07c97800363a07d0e3a5ff32f4cdc75e50852
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Wed Mar 25 10:22:21 2020 -0500
ARTEMIS-2681 timestamp not set on notif msgs
---
.../core/postoffice/impl/PostOfficeImpl.java | 5 +-
.../management/impl/ManagementServiceImpl.java | 4 +-
.../integration/management/NotificationTest.java | 56 ++++++++++++++++++++++
.../management/SSLSecurityNotificationTest.java | 9 ++++
.../management/SecurityNotificationTest.java | 13 +++++
5 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
index dfb8c1c..7f43e98 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
@@ -1687,7 +1687,10 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
message.setAddress(queueName);
message.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE, new SimpleString(type.toString()));
- message.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, System.currentTimeMillis());
+
+ long timestamp = System.currentTimeMillis();
+ message.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, timestamp);
+ message.setTimestamp(timestamp);
return message;
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 00bc3f5..5b2a034 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -691,7 +691,9 @@ public class ManagementServiceImpl implements ManagementService {
notificationMessage.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE, new SimpleString(notification.getType().toString()));
- notificationMessage.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, System.currentTimeMillis());
+ long timestamp = System.currentTimeMillis();
+ notificationMessage.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, timestamp);
+ notificationMessage.setTimestamp(timestamp);
postOffice.route(notificationMessage, false);
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java
index ba229bf..eef133a 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/NotificationTest.java
@@ -79,6 +79,7 @@ public class NotificationTest extends ActiveMQTestBase {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
session.createQueue(address, queue, durable);
//the first message received will be for the address creation
@@ -86,6 +87,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(BINDING_ADDED.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals(queue.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString());
Assert.assertEquals(address.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
+ Assert.assertTrue(notifications[1].getTimestamp() > start);
+ Assert.assertTrue((long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[1].getTimestamp(), (long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
session.deleteQueue(queue);
}
@@ -103,12 +107,16 @@ public class NotificationTest extends ActiveMQTestBase {
"'");
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
session.createQueue(address, queue, durable);
ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer);
Assert.assertEquals(BINDING_ADDED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString());
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
session.deleteQueue(queue);
}
@@ -142,6 +150,7 @@ public class NotificationTest extends ActiveMQTestBase {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
session.deleteQueue(queue);
//There will be 2 notifications, first is for binding removal, second is for address removal
@@ -149,6 +158,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(BINDING_REMOVED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals(queue.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME).toString());
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@Test
@@ -166,6 +178,7 @@ public class NotificationTest extends ActiveMQTestBase {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
ClientConsumer consumer = mySession.createConsumer(queue);
SimpleString consumerName = SimpleString.toSimpleString(((ClientSessionInternal) mySession).getName());
@@ -179,6 +192,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(SimpleString.toSimpleString("invm:0"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS));
Assert.assertEquals(consumerName, notifications[0].getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME));
Assert.assertEquals(SimpleString.toSimpleString("unavailable"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_CERT_SUBJECT_DN));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
consumer.close();
session.deleteQueue(queue);
@@ -201,6 +217,7 @@ public class NotificationTest extends ActiveMQTestBase {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
consumer.close();
ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer);
@@ -211,6 +228,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_USER));
Assert.assertEquals(SimpleString.toSimpleString("invm:0"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS));
Assert.assertEquals(sessionName, notifications[0].getSimpleStringProperty(ManagementHelper.HDR_SESSION_NAME));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
session.deleteQueue(queue);
}
@@ -221,12 +241,16 @@ public class NotificationTest extends ActiveMQTestBase {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
session.createAddress(address, RoutingType.ANYCAST, true);
ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer);
Assert.assertEquals(ADDRESS_ADDED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals(RoutingType.ANYCAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE));
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@@ -236,18 +260,23 @@ public class NotificationTest extends ActiveMQTestBase {
session.createAddress(address, RoutingType.ANYCAST, true);
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
server.getPostOffice().removeAddressInfo(address);
ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer);
Assert.assertEquals(ADDRESS_REMOVED.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertEquals(RoutingType.ANYCAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE));
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@Test
public void testConnectionCreatedAndDestroyed() throws Exception {
NotificationTest.flush(notifConsumer);
+ long start = System.currentTimeMillis();
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession mySession = sf.createSession("myUser", "myPassword", false, true, true, locator.isPreAcknowledge(), locator.getAckBatchSize());
mySession.start();
@@ -261,8 +290,13 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME));
Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_SESSION_NAME));
Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[1].getObjectProperty(ManagementHelper.HDR_USER));
+ Assert.assertTrue(notifications[1].getTimestamp() > start);
+ Assert.assertTrue((long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[1].getTimestamp(), (long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
NotificationTest.flush(notifConsumer);
+
+ start = System.currentTimeMillis();
mySession.close();
sf.close();
@@ -272,10 +306,17 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME));
Assert.assertNotNull(notifications[0].getObjectProperty(ManagementHelper.HDR_SESSION_NAME));
Assert.assertEquals(SimpleString.toSimpleString("myUser"), notifications[0].getObjectProperty(ManagementHelper.HDR_USER));
+ System.out.println(notifications[0].getTimestamp());
+ System.out.println(start);
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((Long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
Assert.assertEquals(CONNECTION_DESTROYED.toString(), notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TYPE).toString());
Assert.assertNotNull(notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME));
Assert.assertEquals(connectionId, notifications[1].getObjectProperty(ManagementHelper.HDR_CONNECTION_NAME).toString());
+ Assert.assertTrue(notifications[1].getTimestamp() > start);
+ Assert.assertTrue((long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[1].getTimestamp(), (long) notifications[1].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@Test
@@ -299,6 +340,8 @@ public class NotificationTest extends ActiveMQTestBase {
ClientMessage msg = session.createMessage(false);
msg.putStringProperty("someKey", "someValue");
producer.send(msg);
+
+ long start = System.currentTimeMillis();
consumer.receive(1000);
ClientMessage[] notifications = NotificationTest.consumeMessages(1, notifConsumer);
@@ -308,6 +351,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(address, notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS));
Assert.assertEquals(queue, notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME));
Assert.assertEquals(RoutingType.MULTICAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
consumer.close();
session.deleteQueue(queue);
@@ -334,6 +380,8 @@ public class NotificationTest extends ActiveMQTestBase {
ClientMessage msg = session.createMessage(false);
msg.putStringProperty("someKey", "someValue");
msg.setExpiration(1);
+
+ long start = System.currentTimeMillis();
producer.send(msg);
Thread.sleep(500);
consumer.receive(500);
@@ -344,6 +392,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(address, notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS));
Assert.assertEquals(queue, notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME));
Assert.assertEquals(RoutingType.MULTICAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
consumer.close();
session.deleteQueue(queue);
@@ -368,6 +419,8 @@ public class NotificationTest extends ActiveMQTestBase {
ClientMessage msg = session.createMessage(false);
msg.putStringProperty("someKey", "someValue");
msg.setExpiration(1);
+
+ long start = System.currentTimeMillis();
producer.send(msg);
Thread.sleep(500);
@@ -377,6 +430,9 @@ public class NotificationTest extends ActiveMQTestBase {
Assert.assertEquals(address, notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS));
Assert.assertEquals(queue, notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_NAME));
Assert.assertEquals(RoutingType.MULTICAST.getType(), notifications[0].getObjectProperty(ManagementHelper.HDR_ROUTING_TYPE));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
session.deleteQueue(queue);
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SSLSecurityNotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SSLSecurityNotificationTest.java
index d4c504c..83ec599 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SSLSecurityNotificationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SSLSecurityNotificationTest.java
@@ -85,6 +85,7 @@ public class SSLSecurityNotificationTest extends ActiveMQTestBase {
ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc));
ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator));
+ long start = System.currentTimeMillis();
try {
sf.createSession();
Assert.fail("authentication must fail and a notification of security violation must be sent");
@@ -96,6 +97,9 @@ public class SSLSecurityNotificationTest extends ActiveMQTestBase {
Assert.assertEquals(null, notifications[0].getObjectProperty(ManagementHelper.HDR_USER));
Assert.assertEquals("CN=Bad Client, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString());
Assert.assertTrue(notifications[0].getObjectProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString().startsWith("/127.0.0.1"));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@Test
@@ -123,6 +127,8 @@ public class SSLSecurityNotificationTest extends ActiveMQTestBase {
guestSession.createQueue(address, RoutingType.ANYCAST, queue, true);
SSLSecurityNotificationTest.flush(notifConsumer);
+
+ long start = System.currentTimeMillis();
guestSession.createConsumer(queue);
ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer);
@@ -131,6 +137,9 @@ public class SSLSecurityNotificationTest extends ActiveMQTestBase {
Assert.assertEquals("first", notifications[0].getObjectProperty(ManagementHelper.HDR_VALIDATED_USER).toString());
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
Assert.assertEquals("CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, ST=AMQ, C=AMQ", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
guestSession.close();
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java
index 08accec..932350a 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/SecurityNotificationTest.java
@@ -74,6 +74,7 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory sf = createSessionFactory(locator);
+ long start = System.currentTimeMillis();
try {
sf.createSession(unknownUser, RandomUtil.randomString(), false, true, true, false, 1);
Assert.fail("authentication must fail and a notification of security violation must be sent");
@@ -85,6 +86,9 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
Assert.assertEquals(unknownUser, notifications[0].getObjectProperty(ManagementHelper.HDR_USER).toString());
Assert.assertEquals("unavailable", notifications[0].getObjectProperty(ManagementHelper.HDR_CERT_SUBJECT_DN).toString());
Assert.assertEquals("invm:0", notifications[0].getObjectProperty(ManagementHelper.HDR_REMOTE_ADDRESS).toString());
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
}
@Test
@@ -106,6 +110,7 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession guestSession = sf.createSession("guest", "guest", false, true, true, false, 1);
+ long start = System.currentTimeMillis();
try {
guestSession.createQueue(address, queue, true);
Assert.fail("session creation must fail and a notification of security violation must be sent");
@@ -125,6 +130,9 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
Assert.assertEquals("guest", notifications[i].getObjectProperty(ManagementHelper.HDR_USER).toString());
Assert.assertEquals(address.toString(), notifications[i].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.toString(), notifications[i].getObjectProperty(ManagementHelper.HDR_CHECK_TYPE).toString());
+ Assert.assertTrue(notifications[i].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[i].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[i].getTimestamp(), (long) notifications[i].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
guestSession.close();
}
@@ -147,6 +155,8 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
guestSession.createQueue(address, RoutingType.ANYCAST, queue, true);
SecurityNotificationTest.flush(notifConsumer);
+
+ long start = System.currentTimeMillis();
guestSession.createConsumer(queue);
ClientMessage[] notifications = SecurityNotificationTest.consumeMessages(1, notifConsumer);
@@ -155,6 +165,9 @@ public class SecurityNotificationTest extends ActiveMQTestBase {
Assert.assertEquals("guest", notifications[0].getObjectProperty(ManagementHelper.HDR_VALIDATED_USER).toString());
Assert.assertEquals(address.toString(), notifications[0].getObjectProperty(ManagementHelper.HDR_ADDRESS).toString());
Assert.assertEquals(SimpleString.toSimpleString("unavailable"), notifications[0].getSimpleStringProperty(ManagementHelper.HDR_CERT_SUBJECT_DN));
+ Assert.assertTrue(notifications[0].getTimestamp() >= start);
+ Assert.assertTrue((long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP) >= start);
+ Assert.assertEquals(notifications[0].getTimestamp(), (long) notifications[0].getObjectProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP));
guestSession.close();
}