use of fish.payara.microprofile.faulttolerance.FaultToleranceConfig in project Payara by payara.
the class ConfigScopeTest method isMetricsEnabledOnlyResolvedOnce.
@Test
public void isMetricsEnabledOnlyResolvedOnce() {
FaultToleranceConfig config = new BindableFaultToleranceConfig(overrides, null);
assertTrue("default should be true", config.isMetricsEnabled());
overrides.override(BindableFaultToleranceConfig.METRICS_ENABLED_PROPERTY, false);
assertTrue("should still be true since it has been resolved already", config.isMetricsEnabled());
assertFalse("should be false since property was set before it was resolved", new BindableFaultToleranceConfig(overrides, null).isMetricsEnabled());
}
use of fish.payara.microprofile.faulttolerance.FaultToleranceConfig in project Payara by payara.
the class ConfigOverridePriorityTest method methodAndClassLevelAnnotationPresent.
@Test
public void methodAndClassLevelAnnotationPresent() {
Method annotatedMethod = TestUtils.getAnnotatedMethod();
FaultToleranceConfig config = configFactory.bindTo(new StaticAnalysisContext(getClass(), annotatedMethod));
Retry retry = config.getAnnotation(Retry.class);
assertEquals(ChronoUnit.WEEKS, config.delayUnit(retry));
overrides.override(Retry.class, "delayUnit", ChronoUnit.ERAS);
assertEquals("should be: global override effective", ChronoUnit.ERAS, config.delayUnit(retry));
overrides.override(getClass(), Retry.class, "delayUnit", ChronoUnit.MICROS);
assertEquals("should be: class level annotation present but override ineffective because method level annotation is present", ChronoUnit.ERAS, config.delayUnit(retry));
overrides.override(annotatedMethod, Retry.class, "delayUnit", ChronoUnit.YEARS);
assertEquals("should be: method level override effective", ChronoUnit.YEARS, config.delayUnit(retry));
}
use of fish.payara.microprofile.faulttolerance.FaultToleranceConfig in project Payara by payara.
the class ConfigOverridePriorityTest method onlyMethodLevelAnnotationPresent.
@Test
public void onlyMethodLevelAnnotationPresent() {
Method annotatedMethod = TestUtils.getAnnotatedMethod();
FaultToleranceConfig config = configFactory.bindTo(new StaticAnalysisContext(getClass(), annotatedMethod));
Timeout timeout = config.getAnnotation(Timeout.class);
assertEquals(42L, config.value(timeout));
overrides.override(Timeout.class, "value", 11L);
assertEquals("should be: global override effective", 11L, config.value(timeout));
overrides.override(getClass(), Timeout.class, "value", 22L);
assertEquals("should be: class level override ineffective because no class level annotation present", 11L, config.value(timeout));
// do method level override
overrides.override(annotatedMethod, Timeout.class, "value", 33L);
assertEquals("should be: method level override effective", 33L, config.value(timeout));
}
Aggregations