use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSessionTestCase method removeNonExistingAttribute.
@Test
public void removeNonExistingAttribute() {
String name = "name";
this.validate(session -> session.removeAttribute(name));
SessionManager<LocalSessionContext, Batch> manager = mock(SessionManager.class);
Batcher<Batch> batcher = mock(Batcher.class);
BatchContext context = mock(BatchContext.class);
SessionAttributes attributes = mock(SessionAttributes.class);
SessionListener listener = mock(SessionListener.class);
SessionListeners listeners = new SessionListeners();
listeners.addSessionListener(listener);
when(this.session.getAttributes()).thenReturn(attributes);
when(attributes.removeAttribute(name)).thenReturn(null);
when(this.manager.getSessionListeners()).thenReturn(listeners);
when(this.manager.getSessionManager()).thenReturn(manager);
when(manager.getBatcher()).thenReturn(batcher);
when(batcher.resumeBatch(this.batch)).thenReturn(context);
Object result = this.adapter.removeAttribute(name);
assertNull(result);
verify(listener, never()).attributeRemoved(same(this.adapter), same(name), any());
verify(context).close();
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class DistributableSessionTestCase method getMaxInactiveInterval.
@Test
public void getMaxInactiveInterval() {
this.validate(session -> session.getMaxInactiveInterval());
SessionManager<LocalSessionContext, Batch> manager = mock(SessionManager.class);
Batcher<Batch> batcher = mock(Batcher.class);
BatchContext context = mock(BatchContext.class);
SessionMetaData metaData = mock(SessionMetaData.class);
long expected = 3600L;
when(this.manager.getSessionManager()).thenReturn(manager);
when(manager.getBatcher()).thenReturn(batcher);
when(batcher.resumeBatch(this.batch)).thenReturn(context);
when(this.session.getMetaData()).thenReturn(metaData);
when(metaData.getMaxInactiveInterval()).thenReturn(Duration.ofSeconds(expected));
long result = this.adapter.getMaxInactiveInterval();
assertEquals(expected, result);
verify(context).close();
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class InfinispanBatcherTestCase method resumeBatch.
@Test
public void resumeBatch() throws Exception {
TransactionBatch batch = mock(TransactionBatch.class);
Transaction tx = mock(Transaction.class);
when(batch.getTransaction()).thenReturn(tx);
try (BatchContext context = this.batcher.resumeBatch(batch)) {
verify(this.tm, never()).suspend();
verify(this.tm).resume(tx);
reset(this.tm);
assertSame(batch, InfinispanBatcher.CURRENT_BATCH.get());
}
verify(this.tm).suspend();
verify(this.tm, never()).resume(any());
assertNull(InfinispanBatcher.CURRENT_BATCH.get());
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class InfinispanBatcherTestCase method resumeBatchExisting.
@Test
public void resumeBatchExisting() throws Exception {
TransactionBatch existingBatch = mock(TransactionBatch.class);
Transaction existingTx = mock(Transaction.class);
InfinispanBatcher.CURRENT_BATCH.set(existingBatch);
TransactionBatch batch = mock(TransactionBatch.class);
Transaction tx = mock(Transaction.class);
when(existingBatch.getTransaction()).thenReturn(existingTx);
when(batch.getTransaction()).thenReturn(tx);
when(this.tm.suspend()).thenReturn(existingTx);
try (BatchContext context = this.batcher.resumeBatch(batch)) {
verify(this.tm).resume(tx);
reset(this.tm);
assertSame(batch, InfinispanBatcher.CURRENT_BATCH.get());
when(this.tm.suspend()).thenReturn(tx);
}
verify(this.tm).resume(existingTx);
assertSame(existingBatch, InfinispanBatcher.CURRENT_BATCH.get());
}
use of org.wildfly.clustering.ee.BatchContext in project wildfly by wildfly.
the class InfinispanBatcherTestCase method resumeNonTxBatch.
@Test
public void resumeNonTxBatch() throws Exception {
TransactionBatch existingBatch = mock(TransactionBatch.class);
InfinispanBatcher.CURRENT_BATCH.set(existingBatch);
TransactionBatch batch = mock(TransactionBatch.class);
try (BatchContext context = this.batcher.resumeBatch(batch)) {
verifyZeroInteractions(this.tm);
assertSame(batch, InfinispanBatcher.CURRENT_BATCH.get());
}
verifyZeroInteractions(this.tm);
assertSame(existingBatch, InfinispanBatcher.CURRENT_BATCH.get());
}
Aggregations