Search in sources :

Example 21 with CommandMessage

use of com.birbit.android.jobqueue.messaging.message.CommandMessage in project android-priority-jobqueue by yigit.

the class UnsafeMessageQueueTest method simplePostAtFront.

@Test
public void simplePostAtFront() {
    Message m = new CommandMessage();
    Message m2 = new CommandMessage();
    Message m3 = new CommandMessage();
    mq.postAtFront(m);
    mq.postAtFront(m2);
    mq.postAtFront(m3);
    assertThat(mq.next(), is(m3));
    assertThat(mq.next(), is(m2));
    assertThat(mq.next(), is(m));
}
Also used : CommandMessage(com.birbit.android.jobqueue.messaging.message.CommandMessage) CommandMessage(com.birbit.android.jobqueue.messaging.message.CommandMessage) Test(org.junit.Test)

Example 22 with CommandMessage

use of com.birbit.android.jobqueue.messaging.message.CommandMessage in project android-priority-jobqueue by yigit.

the class UnsafeMessageQueueTest method add.

private Message add(long id) {
    CommandMessage msg = new CommandMessage();
    mq.post(msg);
    added.put(id, msg);
    return msg;
}
Also used : CommandMessage(com.birbit.android.jobqueue.messaging.message.CommandMessage)

Example 23 with CommandMessage

use of com.birbit.android.jobqueue.messaging.message.CommandMessage in project android-priority-jobqueue by yigit.

the class DelayedMessageBagAddTest method add.

private Message add(long readyNs) {
    CommandMessage msg = factory.obtain(CommandMessage.class);
    bag.add(msg, readyNs);
    added.put(readyNs, msg);
    return msg;
}
Also used : CommandMessage(com.birbit.android.jobqueue.messaging.message.CommandMessage)

Example 24 with CommandMessage

use of com.birbit.android.jobqueue.messaging.message.CommandMessage in project android-priority-jobqueue by yigit.

the class MessageFactoryTest method test.

@Test
public void test() {
    AddJobMessage aj1 = factory.obtain(AddJobMessage.class);
    assertThat(aj1, isA(AddJobMessage.class));
    CommandMessage cm1 = factory.obtain(CommandMessage.class);
    assertThat(cm1, isA(CommandMessage.class));
    assertThat(factory.obtain(AddJobMessage.class), not(sameInstance(aj1)));
    assertThat(factory.obtain(CommandMessage.class), not(sameInstance(cm1)));
    factory.release(aj1);
    factory.release(cm1);
    assertThat(factory.obtain(AddJobMessage.class), sameInstance(aj1));
    assertThat(factory.obtain(CommandMessage.class), sameInstance(cm1));
    assertThat(factory.obtain(AddJobMessage.class), not(sameInstance(aj1)));
    assertThat(factory.obtain(CommandMessage.class), not(sameInstance(cm1)));
}
Also used : AddJobMessage(com.birbit.android.jobqueue.messaging.message.AddJobMessage) CommandMessage(com.birbit.android.jobqueue.messaging.message.CommandMessage) Test(org.junit.Test)

Aggregations

CommandMessage (com.birbit.android.jobqueue.messaging.message.CommandMessage)24 Test (org.junit.Test)12 MockTimer (com.birbit.android.jobqueue.test.timer.MockTimer)6 MessageQueueConsumer (com.birbit.android.jobqueue.messaging.MessageQueueConsumer)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 AddJobMessage (com.birbit.android.jobqueue.messaging.message.AddJobMessage)3 Message (com.birbit.android.jobqueue.messaging.Message)2 PublicQueryMessage (com.birbit.android.jobqueue.messaging.message.PublicQueryMessage)2 RunJobMessage (com.birbit.android.jobqueue.messaging.message.RunJobMessage)2 VisibleForTesting (android.support.annotation.VisibleForTesting)1 SafeMessageQueue (com.birbit.android.jobqueue.messaging.SafeMessageQueue)1 CallbackMessage (com.birbit.android.jobqueue.messaging.message.CallbackMessage)1 CancelMessage (com.birbit.android.jobqueue.messaging.message.CancelMessage)1 CancelResultMessage (com.birbit.android.jobqueue.messaging.message.CancelResultMessage)1 ConstraintChangeMessage (com.birbit.android.jobqueue.messaging.message.ConstraintChangeMessage)1 JobConsumerIdleMessage (com.birbit.android.jobqueue.messaging.message.JobConsumerIdleMessage)1 RunJobResultMessage (com.birbit.android.jobqueue.messaging.message.RunJobResultMessage)1 SchedulerMessage (com.birbit.android.jobqueue.messaging.message.SchedulerMessage)1 SchedulerConstraint (com.birbit.android.jobqueue.scheduling.SchedulerConstraint)1 AssertionFailedError (junit.framework.AssertionFailedError)1