lundi 27 juillet 2015

How mock jcabi annotation parameters

I have some code like below.

@RetryOnFailure(attempts = Constant.RETRY_ATTEMPTS, delay = Constant.RETRY_DELAY, unit = TimeUnit.SECONDS)
public void method() {
    // some processing
    //throw exception if HTTP operation is not successful. (use of retry)
}

The value of RETRY_ATTEMPTS and RETRY_DELAY variable come from a separate Constant class, which are int primitive. Both the variable are defined as public static final.

How can I override these values while writing the unit testcases. The actual values increases running time of unit testcases.

I have already tried two approach: Both did not work

  1. Using PowerMock with Whitebox.setInternalState().
  2. Using Reflection as well.

Aucun commentaire:

Enregistrer un commentaire