use of org.apache.activemq.util.IdGenerator in project activemq-artemis by apache.
the class ActiveMQMessageAuditTest method testIsDuplicateString.
/**
* test case for isDuplicate
*/
public void testIsDuplicateString() {
int count = 10000;
ActiveMQMessageAudit audit = new ActiveMQMessageAudit();
IdGenerator idGen = new IdGenerator();
// add to a list
List<String> list = new ArrayList<>();
for (int i = 0; i < count; i++) {
String id = idGen.generateId();
list.add(id);
assertFalse(audit.isDuplicate(id));
}
List<String> windowList = list.subList(list.size() - 1 - audit.getAuditDepth(), list.size() - 1);
for (String id : windowList) {
assertTrue("duplicate, id:" + id, audit.isDuplicate(id));
}
}
use of org.apache.activemq.util.IdGenerator in project activemq-artemis by apache.
the class JobSchedulerManagementTest method testRemoveNotScheduled.
@Test
public void testRemoveNotScheduled() throws Exception {
Connection connection = createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the Browse Destination and the Reply To location
Destination management = session.createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION);
MessageProducer producer = session.createProducer(management);
try {
// Send the remove request
Message remove = session.createMessage();
remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL);
remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID, new IdGenerator().generateId());
producer.send(remove);
} catch (Exception e) {
fail("Caught unexpected exception during remove of unscheduled message.");
}
}
use of org.apache.activemq.util.IdGenerator in project activemq-artemis by apache.
the class ActiveMQMessageAuditTest method testIsInOrderString.
public void testIsInOrderString() {
int count = 10000;
ActiveMQMessageAudit audit = new ActiveMQMessageAudit();
IdGenerator idGen = new IdGenerator();
// add to a list
List<String> list = new ArrayList<>();
for (int i = 0; i < count; i++) {
String id = idGen.generateId();
if (i == 0) {
assertFalse(audit.isDuplicate(id));
assertTrue(audit.isInOrder(id));
}
if (i > 1 && i % 2 != 0) {
list.add(id);
}
}
for (String id : list) {
assertFalse(audit.isInOrder(id));
assertFalse(audit.isDuplicate(id));
}
}
use of org.apache.activemq.util.IdGenerator in project activemq-artemis by apache.
the class DestinationMapTempDestinationTest method testtestTempDestinations.
public void testtestTempDestinations() throws Exception {
ConnectionId id = new ConnectionId(new IdGenerator().generateId());
DestinationMap map = new DestinationMap();
Object value = new Object();
int count = 1000;
for (int i = 0; i < count; i++) {
ActiveMQTempQueue queue = new ActiveMQTempQueue(id, i);
map.put(queue, value);
}
for (int i = 0; i < count; i++) {
ActiveMQTempQueue queue = new ActiveMQTempQueue(id, i);
map.remove(queue, value);
Set<?> set = map.get(queue);
assertTrue(set.isEmpty());
}
}
Aggregations