use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.
the class JobSchedulerTest method testAddLongLongIntStringByteSequence.
@Test
public void testAddLongLongIntStringByteSequence() throws Exception {
final int COUNT = 10;
final CountDownLatch latch = new CountDownLatch(COUNT);
scheduler.addListener(new JobListener() {
@Override
public void scheduledJob(String id, ByteSequence job) {
latch.countDown();
}
});
long time = 2000;
for (int i = 0; i < COUNT; i++) {
String test = new String("test" + i);
scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 10, -1);
}
assertTrue(latch.getCount() == COUNT);
latch.await(3000, TimeUnit.SECONDS);
assertTrue(latch.getCount() == 0);
}
use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.
the class JobSchedulerTest method testRemoveAllJobsInRange.
@Test
public void testRemoveAllJobsInRange() throws Exception {
final int COUNT = 10;
final String ID = "id:";
long start = 10000;
for (int i = 0; i < COUNT; i++) {
String str = new String("test" + i);
scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0);
}
start = System.currentTimeMillis();
long finish = start + 12000 + (COUNT * 1000);
scheduler.removeAllJobs(start, finish);
assertTrue(scheduler.getAllJobs().isEmpty());
}
use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.
the class JobSchedulerStoreCheckpointTest method setUp.
@Before
public void setUp() throws Exception {
File directory = new File("target/test/ScheduledJobsDB");
IOHelper.mkdirs(directory);
IOHelper.deleteChildren(directory);
startStore(directory);
byte[] data = new byte[8192];
for (int i = 0; i < data.length; ++i) {
data[i] = (byte) (i % 256);
}
payload = new ByteSequence(data);
}
use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.
the class FilePendingMessageCursorTestSupport method createBrokerWithTempStoreLimit.
private void createBrokerWithTempStoreLimit() throws Exception {
brokerService = new BrokerService();
brokerService.setUseJmx(false);
SystemUsage usage = brokerService.getSystemUsage();
usage.getTempUsage().setLimit(1025 * 1024 * 15);
// put something in the temp store to on demand initialise it
PList dud = brokerService.getTempDataStore().getPList("dud");
dud.addFirst("A", new ByteSequence("A".getBytes()));
}
use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.
the class DataFileGeneratorTestSupport method assertByteSequencesEqual.
protected void assertByteSequencesEqual(String message, ByteSequence expected, Object actualValue) {
assertTrue(message + ". Actual value should be a ByteSequence but was: " + actualValue, actualValue instanceof ByteSequence);
ByteSequence actual = (ByteSequence) actualValue;
int length = expected.getLength();
assertEquals(message + ". Length", length, actual.getLength());
int offset = expected.getOffset();
assertEquals(message + ". Offset", offset, actual.getOffset());
byte[] data = expected.getData();
byte[] actualData = actual.getData();
for (int i = 0; i < length; i++) {
assertEquals(message + ". Offset " + i, data[offset + i], actualData[offset + i]);
}
}
Aggregations