Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/390#discussion_r85202543
--- Diff:
core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java
---
@@ -280,4 +279,55 @@ public void
testSubscriptionForInitialValueWhenNotValid() {
entity.subscriptions().subscribe(ImmutableMap.of("notifyOfInitialValue", true),
null, TestEntity.NAME, listener);
entity.subscriptions().subscribe(ImmutableMap.of("notifyOfInitialValue", true),
null, null, listener);
}
+
+ @Test
+ public void testContextEntityOnSubscriptionCallbackTask() {
+ observedEntity.sensors().set(TestEntity.NAME, "myval");
+
entity.subscriptions().subscribe(ImmutableMap.of("notifyOfInitialValue", true),
observedEntity, TestEntity.NAME, listener);
+
+ // notify-of-initial-value should give us our entity
+ assertListenerCalledOnceWithContextEntityEventually(listener,
entity);
+ listener.clearEvents();
+
+ // as should subsequent events
+ observedEntity.sensors().set(TestEntity.NAME, "myval2");
+ assertListenerCalledOnceWithContextEntityEventually(listener,
entity);
+ listener.clearEvents();
+
+ // same for subscribing to children: context should be the
subscriber
+ entity.subscriptions().subscribeToChildren(observedEntity,
TestEntity.SEQUENCE, listener);
+ observedChildEntity.sensors().set(TestEntity.SEQUENCE, 123);
+ assertListenerCalledOnceWithContextEntityEventually(listener,
entity);
+ listener.clearEvents();
--- End diff --
should this be in a `tearDown`?
---
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.
---