Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/835#discussion_r142922808
--- Diff:
core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
---
@@ -170,4 +181,84 @@ public void run() {
if (threadException.get() != null) throw threadException.get();
}
+ @Test
+ // same test as in PolicySubscriptionTest, but for entities / simpler
+ public void testSubscriptionReceivesInitialValueEventsInOrder() {
+ RecordingSensorEventListener<Object> listener = new
RecordingSensorEventListener<>();
+
+ entity.sensors().set(TestEntity.NAME, "myname");
+ entity.sensors().set(TestEntity.SEQUENCE, 123);
+ entity.sensors().emit(TestEntity.MY_NOTIF, -1);
+
+ // delivery should be in subscription order, so 123 then 456
+
entity.subscriptions().subscribe(ImmutableMap.of("notifyOfInitialValue", true),
entity, TestEntity.SEQUENCE, listener);
+ // wait for the above delivery - otherwise it might get dropped
+ Asserts.succeedsEventually(MutableMap.of("timeout",
Duration.seconds(5)), () -> {
--- End diff --
Don't bother setting timeouts - just rely on the defaults. If you want
things to run faster locally, then set the Java system property
`-Dbrooklyn.test.defaultTimeout=5s`.
---