brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geomacy <>
Subject [GitHub] brooklyn-server pull request #663: expand test of future value
Date Tue, 02 May 2017 10:38:11 GMT
Github user geomacy commented on a diff in the pull request:
    --- Diff: core/src/test/java/org/apache/brooklyn/core/config/ ---
    @@ -30,32 +29,51 @@
     import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
     import org.apache.brooklyn.core.test.entity.TestApplication;
     import org.apache.brooklyn.util.guava.Maybe;
    +import org.apache.brooklyn.util.time.Duration;
    +import org.apache.brooklyn.util.time.Time;
    +import org.testng.Assert;
     import org.testng.annotations.Test;
    -public class ConfigTypeCoercionTest extends BrooklynAppUnitTestSupport {
    +public class DeferredConfigTest extends BrooklynAppUnitTestSupport {
         private static ConfigKey<Object> SENSORS_UNTYPED = ConfigKeys.newConfigKey(Object.class,
         private static ConfigKey<List<? extends Sensor<?>>> SENSORS = ConfigKeys.newConfigKey(new
TypeToken<List<? extends Sensor<?>>>() {}, "sensors");
    -    public void testSshConfigFromDefault() throws Exception {
    +    public void testDeferredConfigInListWhenAvailable() throws Exception {
    +        doTestDeferredConfigInList(false);
    +    }
    +    @Test
    +    public void testDeferredConfigInListNotAvailable() throws Exception {
    +        doTestDeferredConfigInList(true);
    +    }
    +    void doTestDeferredConfigInList(final boolean delay) throws Exception {
             // Simulate a deferred value
             Task<Sensor<?>> sensorFuture = app.getExecutionContext().submit(new
Callable<Sensor<?>>() {
                 public Sensor<?> call() throws Exception {
    +                if (delay) Time.sleep(Duration.FIVE_SECONDS);
                     return TestApplication.MY_ATTRIBUTE;
             app.config().set(SENSORS_UNTYPED, (Object)ImmutableList.of(sensorFuture));
    +        if (!delay) sensorFuture.get(Duration.ONE_SECOND);
    --- End diff --
    Why so large a timeout? Would a millisecond or two not be sufficient? This might be a
bit confusing for readers as it suggests that there is some need to wait for a long time,
even though the test in the `!delay` case is for a case where the future will execute and
complete very quickly. 

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message