Example usage for org.apache.commons.lang.mutable MutableInt getValue

List of usage examples for org.apache.commons.lang.mutable MutableInt getValue

Introduction

In this page you can find the example usage for org.apache.commons.lang.mutable MutableInt getValue.

Prototype

public Object getValue() 

Source Link

Document

Gets the value as a Integer instance.

Usage

From source file:org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetryTest.java

@Test(expected = LightweightTransactionException.class)
public void functionRunnerShouldFailIfTransactionCanNotBePerformed() throws Exception {
    final MutableInt value = new MutableInt(0);
    new FunctionRunnerWithRetry(MAX_RETRY).execute(() -> {
        value.increment();//from  w w  w .  j  ava  2  s  .  c o m
        return false;
    });
    assertThat(value.getValue()).isEqualTo(MAX_RETRY);
}

From source file:org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetryTest.java

@Test
public void functionRunnerShouldWorkOnFirstTry() throws Exception {
    final MutableInt value = new MutableInt(0);
    new FunctionRunnerWithRetry(MAX_RETRY).execute(() -> {
        value.increment();//from w  w  w  .  java 2  s . co m
        return true;
    });
    assertThat(value.getValue()).isEqualTo(1);
}

From source file:org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetryTest.java

@Test
public void functionRunnerShouldWorkIfNotSucceededOnFirstTry() throws Exception {
    final MutableInt value = new MutableInt(0);
    new FunctionRunnerWithRetry(MAX_RETRY).execute(() -> {
        value.increment();/*from w ww.jav  a2  s.co  m*/
        return (Integer) value.getValue() == MAX_RETRY / 2;
    });
    assertThat(value.getValue()).isEqualTo(MAX_RETRY / 2);
}

From source file:org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetryTest.java

@Test
public void functionRunnerShouldWorkIfNotSucceededOnMaxRetryReached() throws Exception {
    final MutableInt value = new MutableInt(0);
    new FunctionRunnerWithRetry(MAX_RETRY).execute(() -> {
        value.increment();/*w  ww .j  av a  2 s . c  o  m*/
        return (Integer) value.getValue() == MAX_RETRY;
    });
    assertThat(value.getValue()).isEqualTo(MAX_RETRY);
}