Search in sources :

Example 1 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitGetKeyValueCommand.

public void testVisitGetKeyValueCommand() throws Throwable {
    GetKeyValueCommand command = new GetKeyValueCommand(KEY, 0, 0);
    InvocationStage stage = makeStage(interceptor.visitGetKeyValueCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocation(null);
    assertNull(stage.get());
    assertEquals(1, interceptor.getAverageReadTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) GetKeyValueCommand(org.infinispan.commands.read.GetKeyValueCommand)

Example 2 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitPutMapCommand.

public void testVisitPutMapCommand() throws Throwable {
    PutMapCommand command = new PutMapCommand(Collections.singletonMap(KEY, VALUE), null, 0, null);
    InvocationStage stage = makeStage(interceptor.visitPutMapCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocation(null);
    assertNull(stage.get());
    assertEquals(1, interceptor.getAverageWriteTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) PutMapCommand(org.infinispan.commands.write.PutMapCommand)

Example 3 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitPutKeyValueCommand.

public void testVisitPutKeyValueCommand() throws Throwable {
    PutKeyValueCommand command = new PutKeyValueCommand(KEY, VALUE, false, null, 0, 0, null);
    InvocationStage stage = makeStage(interceptor.visitPutKeyValueCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocation(null);
    assertNull(stage.get());
    assertEquals(1, interceptor.getAverageWriteTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand)

Example 4 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitGetAllCommand.

public void testVisitGetAllCommand() throws Throwable {
    GetAllCommand command = new GetAllCommand(Collections.singleton(KEY), 0, false);
    InvocationStage stage = makeStage(interceptor.visitGetAllCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocation(Collections.emptyMap());
    assertEquals(Collections.emptyMap(), stage.get());
    assertEquals(1, interceptor.getAverageReadTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) GetAllCommand(org.infinispan.commands.read.GetAllCommand)

Example 5 with InvocationStage

use of org.infinispan.interceptors.InvocationStage in project infinispan by infinispan.

the class CacheMgmtInterceptorTest method testVisitReplaceCommandException.

public void testVisitReplaceCommandException() throws Throwable {
    ReplaceCommand command = new ReplaceCommand(KEY, VALUE, false, null, 0, 0, null);
    InvocationStage stage = makeStage(interceptor.visitReplaceCommand(ctx, command));
    assertFalse(stage.isDone());
    timeService.advance(1);
    nextInterceptor.completeLastInvocationExceptionally(new TestException());
    expectInvocationException(stage);
    assertEquals(1, interceptor.getAverageWriteTime());
}
Also used : InvocationStage(org.infinispan.interceptors.InvocationStage) TestException(org.infinispan.test.TestException) ReplaceCommand(org.infinispan.commands.write.ReplaceCommand)

Aggregations

InvocationStage (org.infinispan.interceptors.InvocationStage)29 TestException (org.infinispan.test.TestException)7 TxInvocationContext (org.infinispan.context.impl.TxInvocationContext)6 SyncInvocationStage (org.infinispan.interceptors.SyncInvocationStage)6 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)5 Map (java.util.Map)4 VisitableCommand (org.infinispan.commands.VisitableCommand)4 LockControlCommand (org.infinispan.commands.control.LockControlCommand)4 PrepareCommand (org.infinispan.commands.tx.PrepareCommand)4 PutMapCommand (org.infinispan.commands.write.PutMapCommand)4 RemoveCommand (org.infinispan.commands.write.RemoveCommand)4 ReplaceCommand (org.infinispan.commands.write.ReplaceCommand)4 WriteCommand (org.infinispan.commands.write.WriteCommand)4 InvocationContext (org.infinispan.context.InvocationContext)4 KeyValuePair (org.infinispan.util.KeyValuePair)4 FlagAffectedCommand (org.infinispan.commands.FlagAffectedCommand)3 CommitCommand (org.infinispan.commands.tx.CommitCommand)3 CacheEntry (org.infinispan.container.entries.CacheEntry)3 FlagBitSets (org.infinispan.context.impl.FlagBitSets)3 Inject (org.infinispan.factories.annotations.Inject)3