Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/48#discussion_r14704160
  
    --- Diff: 
software/base/src/test/java/brooklyn/entity/software/http/HttpRequestSensorTest.java
 ---
    @@ -0,0 +1,62 @@
    +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.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.assertTrue;
    +import static org.testng.Assert.assertEquals;
    +import static brooklyn.test.Asserts.succeedsEventually;
    +
    +public class HttpRequestSensorTest {
    +    final static AttributeSensor<String> SENSOR_STRING = 
Sensors.newStringSensor("aString", "");
    +    final static AttributeSensor<String> SENSOR_JSON_OBJECT = 
Sensors.newStringSensor("aJSONObject","");
    +    final static AttributeSensor<String> SENSOR_URI = 
Sensors.newStringSensor("uri","");
    +
    +    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 {
    +        new HttpRequestSensor<String>(ConfigBag.newInstance()
    +                .configure(HttpRequestSensor.SENSOR_NAME, 
SENSOR_STRING.getName())
    +                .configure(HttpRequestSensor.JSON_PATH, "$.myKey")
    +                .configure(HttpRequestSensor.SENSOR_URI, 
"http://echo.jsontest.com/myKey/myValue";))
    +            .apply(entity);
    +        entity.setAttribute(Attributes.SERVICE_UP, true);
    +
    +        succeedsEventually(new Runnable() {
    --- End diff --
    
    Can instead use the convenience 
`EntityTestUtils.assertAttributeEqualsEventually(entity, SENSOR_STRING, 
"mValue")`


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to