brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Adds EntityInitializers for http ...
Date Thu, 17 Jul 2014 09:55:47 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/48#discussion_r15048949
  
    --- Diff: software/base/src/test/java/brooklyn/entity/software/http/HttpRequestSensorTest.java
---
    @@ -0,0 +1,55 @@
    +package brooklyn.entity.software.http;
    +
    +import brooklyn.entity.basic.ApplicationBuilder;
    +import brooklyn.entity.basic.Attributes;
    +import brooklyn.entity.basic.Entities;
    +import brooklyn.entity.basic.EntityLocal;
    +import brooklyn.entity.proxying.EntitySpec;
    +import brooklyn.event.AttributeSensor;
    +import brooklyn.event.basic.Sensors;
    +import brooklyn.location.Location;
    +import brooklyn.test.EntityTestUtils;
    +import brooklyn.test.entity.TestApplication;
    +import brooklyn.test.entity.TestEntity;
    +import brooklyn.util.config.ConfigBag;
    +import com.google.common.collect.ImmutableList;
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +public class HttpRequestSensorTest {
    +    final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString",
"");
    +    final static AttributeSensor<String> TARGET_TYPE = Sensors.newStringSensor("java.lang.String",
"");
    +
    +    private TestApplication app;
    +    private EntityLocal entity;
    +
    +    @BeforeMethod(alwaysRun=true)
    +    public void setUp() throws Exception {
    +        app = ApplicationBuilder.newManagedApp(TestApplication.class);
    +        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(app.newLocalhostProvisioningLocation().obtain()));
    +        app.start(ImmutableList.<Location>of());
    +    }
    +
    +    @AfterMethod(alwaysRun=true)
    +    public void tearDown() throws Exception {
    +        if (app != null) Entities.destroyAll(app.getManagementContext());
    +    }
    +
    +    @Test(groups="Integration")
    +    public void testHttpSensor() throws Exception {
    +        HttpRequestSensor<Integer> sensor = new HttpRequestSensor<Integer>(ConfigBag.newInstance()
    +                .configure(HttpRequestSensor.SENSOR_NAME, SENSOR_STRING.getName())
    +                .configure(HttpRequestSensor.SENSOR_TYPE, TARGET_TYPE.getName())
    --- End diff --
    
    Does `TARGET_TYPE` need be an `AttributeSensor`? It looks like you just call `getName()`,
which means it could just be a string. Or better yet it could use the value of `SENSOR_STRING.getTypeName()`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message