You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/10/07 11:31:40 UTC
[10/13] incubator-brooklyn git commit: Use entity.sensors().* etc,
instead of deprecated methods
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntitySpecTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntitySpecTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntitySpecTest.java
index 1fec2e8..0f57558 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntitySpecTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntitySpecTest.java
@@ -89,7 +89,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
.configure(MyPolicy.CONF1, "myconf1val")
.configure("myfield", "myfieldval")));
- Policy policy = Iterables.getOnlyElement(entity.getPolicies());
+ Policy policy = Iterables.getOnlyElement(entity.policies());
assertTrue(policy instanceof MyPolicy, "policy="+policy);
assertEquals(policy.getDisplayName(), "mypolicyname");
assertEquals(policy.getConfig(MyPolicy.CONF1), "myconf1val");
@@ -101,7 +101,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
.policy(policy));
- assertEquals(Iterables.getOnlyElement(entity.getPolicies()), policy);
+ assertEquals(Iterables.getOnlyElement(entity.policies()), policy);
}
@Test
@@ -112,7 +112,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
.configure(MyEnricher.CONF1, "myconf1val")
.configure("myfield", "myfieldval")));
- Enricher enricher = Iterables.getOnlyElement(entity.getEnrichers());
+ Enricher enricher = Iterables.getOnlyElement(entity.enrichers());
assertTrue(enricher instanceof MyEnricher, "enricher="+enricher);
assertEquals(enricher.getDisplayName(), "myenrichername");
assertEquals(enricher.getConfig(MyEnricher.CONF1), "myconf1val");
@@ -124,7 +124,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
entity = app.createAndManageChild(EntitySpec.create(TestEntity.class, TestEntityNoEnrichersImpl.class)
.enricher(enricher));
- assertEquals(Iterables.getOnlyElement(entity.getEnrichers()), enricher);
+ assertEquals(Iterables.getOnlyElement(entity.enrichers()), enricher);
}
@Test
@@ -134,7 +134,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
.member(entity));
Asserts.assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of(entity));
- Asserts.assertEqualsIgnoringOrder(entity.getGroups(), ImmutableSet.of(group));
+ Asserts.assertEqualsIgnoringOrder(entity.groups(), ImmutableSet.of(group));
}
@Test
@@ -144,7 +144,7 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
.group(group));
Asserts.assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of(entity));
- Asserts.assertEqualsIgnoringOrder(entity.getGroups(), ImmutableSet.of(group));
+ Asserts.assertEqualsIgnoringOrder(entity.groups(), ImmutableSet.of(group));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java
index 38848ef..3d61a99 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntitySubscriptionTest.java
@@ -79,9 +79,9 @@ public class EntitySubscriptionTest {
@Test
public void testSubscriptionReceivesEvents() {
- entity.subscribe(observedEntity, TestEntity.SEQUENCE, listener);
- entity.subscribe(observedEntity, TestEntity.NAME, listener);
- entity.subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.NAME, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
otherEntity.sensors().set(TestEntity.SEQUENCE, 123);
observedEntity.sensors().set(TestEntity.SEQUENCE, 123);
@@ -99,7 +99,7 @@ public class EntitySubscriptionTest {
@Test
public void testSubscriptionToAllReceivesEvents() {
- entity.subscribe(null, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribe(null, TestEntity.SEQUENCE, listener);
observedEntity.sensors().set(TestEntity.SEQUENCE, 123);
otherEntity.sensors().set(TestEntity.SEQUENCE, 456);
@@ -114,7 +114,7 @@ public class EntitySubscriptionTest {
@Test
public void testSubscribeToChildrenReceivesEvents() {
- entity.subscribeToChildren(observedEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribeToChildren(observedEntity, TestEntity.SEQUENCE, listener);
observedChildEntity.sensors().set(TestEntity.SEQUENCE, 123);
observedEntity.sensors().set(TestEntity.SEQUENCE, 456);
@@ -128,7 +128,7 @@ public class EntitySubscriptionTest {
@Test
public void testSubscribeToChildrenReceivesEventsForDynamicallyAddedChildren() {
- entity.subscribeToChildren(observedEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribeToChildren(observedEntity, TestEntity.SEQUENCE, listener);
final TestEntity observedChildEntity2 = observedEntity.createAndManageChild(EntitySpec.create(TestEntity.class));
observedChildEntity2.sensors().set(TestEntity.SEQUENCE, 123);
@@ -142,10 +142,10 @@ public class EntitySubscriptionTest {
@Test
public void testSubscribeToMembersReceivesEvents() {
- entity.subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
observedMemberEntity.sensors().set(TestEntity.SEQUENCE, 123);
- ((EntityLocal)observedGroup).sensors().set(TestEntity.SEQUENCE, 456);
+ observedGroup.sensors().set(TestEntity.SEQUENCE, 456);
Asserts.succeedsEventually(new Runnable() {
@Override public void run() {
@@ -156,7 +156,7 @@ public class EntitySubscriptionTest {
@Test
public void testSubscribeToMembersReceivesEventsForDynamicallyAddedMembers() {
- entity.subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
final TestEntity observedMemberEntity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
observedGroup.addMember(observedMemberEntity2);
@@ -171,7 +171,7 @@ public class EntitySubscriptionTest {
@Test(groups="Integration")
public void testSubscribeToMembersIgnoresEventsForDynamicallyRemovedMembers() {
- entity.subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribeToMembers(observedGroup, TestEntity.SEQUENCE, listener);
observedGroup.removeMember(observedMemberEntity);
@@ -185,11 +185,11 @@ public class EntitySubscriptionTest {
@Test
public void testUnsubscribeRemovesAllSubscriptionsForThatEntity() {
- entity.subscribe(observedEntity, TestEntity.SEQUENCE, listener);
- entity.subscribe(observedEntity, TestEntity.NAME, listener);
- entity.subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
- entity.subscribe(otherEntity, TestEntity.SEQUENCE, listener);
- entity.unsubscribe(observedEntity);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.NAME, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
+ entity.subscriptions().subscribe(otherEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().unsubscribe(observedEntity);
observedEntity.sensors().set(TestEntity.SEQUENCE, 123);
observedEntity.sensors().set(TestEntity.NAME, "myname");
@@ -205,11 +205,11 @@ public class EntitySubscriptionTest {
@Test
public void testUnsubscribeUsingHandleStopsEvents() {
- SubscriptionHandle handle1 = entity.subscribe(observedEntity, TestEntity.SEQUENCE, listener);
- SubscriptionHandle handle2 = entity.subscribe(observedEntity, TestEntity.NAME, listener);
- SubscriptionHandle handle3 = entity.subscribe(otherEntity, TestEntity.SEQUENCE, listener);
+ SubscriptionHandle handle1 = entity.subscriptions().subscribe(observedEntity, TestEntity.SEQUENCE, listener);
+ SubscriptionHandle handle2 = entity.subscriptions().subscribe(observedEntity, TestEntity.NAME, listener);
+ SubscriptionHandle handle3 = entity.subscriptions().subscribe(otherEntity, TestEntity.SEQUENCE, listener);
- entity.unsubscribe(observedEntity, handle2);
+ entity.subscriptions().unsubscribe(observedEntity, handle2);
observedEntity.sensors().set(TestEntity.SEQUENCE, 123);
observedEntity.sensors().set(TestEntity.NAME, "myname");
@@ -226,7 +226,7 @@ public class EntitySubscriptionTest {
@Test
public void testSubscriptionReceivesEventsInOrder() {
final int NUM_EVENTS = 100;
- entity.subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.MY_NOTIF, listener);
for (int i = 0; i < NUM_EVENTS; i++) {
observedEntity.sensors().emit(TestEntity.MY_NOTIF, i);
@@ -263,8 +263,8 @@ public class EntitySubscriptionTest {
observedEntity.sensors().set(TestEntity.SEQUENCE, 123);
observedEntity.sensors().set(TestEntity.NAME, "myname");
- entity.subscribe(observedEntity, TestEntity.SEQUENCE, listener);
- entity.subscribe(observedEntity, TestEntity.NAME, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.SEQUENCE, listener);
+ entity.subscriptions().subscribe(observedEntity, TestEntity.NAME, listener);
Asserts.succeedsContinually(ImmutableMap.of("timeout", SHORT_WAIT_MS), new Runnable() {
@Override public void run() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java
index 130327f..6f31b6e 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityTypeTest.java
@@ -196,7 +196,7 @@ public class EntityTypeTest extends BrooklynAppUnitTestSupport {
@Test
public void testAddSensorValueThroughEntity() throws Exception{
- entity.setAttribute(TEST_SENSOR, "abc");
+ entity.sensors().set(TEST_SENSOR, "abc");
assertEquals(entity.getEntityType().getSensors(),
ImmutableSet.builder().addAll(DEFAULT_SENSORS).add(TEST_SENSOR).build());
@@ -205,7 +205,7 @@ public class EntityTypeTest extends BrooklynAppUnitTestSupport {
@Test
public void testRemoveSensorThroughEntity() throws Exception{
- entity.setAttribute(TEST_SENSOR, "abc");
+ entity.sensors().set(TEST_SENSOR, "abc");
entity.removeAttribute(TEST_SENSOR);
assertFalse(entity.getEntityType().getSensors().contains(TEST_SENSOR), "sensors="+entity.getEntityType().getSensors());
assertEquals(entity.getAttribute(TEST_SENSOR), null);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/PolicyRegistrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/PolicyRegistrationTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/PolicyRegistrationTest.java
index 10b85bb..a46335b 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/PolicyRegistrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/PolicyRegistrationTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import org.apache.brooklyn.api.entity.EntitySpec;
@@ -67,11 +68,11 @@ public class PolicyRegistrationTest extends BrooklynAppUnitTestSupport {
added = Lists.newCopyOnWriteArrayList();
removed = Lists.newCopyOnWriteArrayList();
- app.subscribe(entity, AbstractEntity.POLICY_ADDED, new SensorEventListener<PolicyDescriptor>() {
+ app.subscriptions().subscribe(entity, AbstractEntity.POLICY_ADDED, new SensorEventListener<PolicyDescriptor>() {
@Override public void onEvent(SensorEvent<PolicyDescriptor> event) {
added.add(event.getValue());
}});
- app.subscribe(entity, AbstractEntity.POLICY_REMOVED, new SensorEventListener<PolicyDescriptor>() {
+ app.subscriptions().subscribe(entity, AbstractEntity.POLICY_REMOVED, new SensorEventListener<PolicyDescriptor>() {
@Override public void onEvent(SensorEvent<PolicyDescriptor> event) {
removed.add(event.getValue());
}});
@@ -79,7 +80,7 @@ public class PolicyRegistrationTest extends BrooklynAppUnitTestSupport {
@Test
public void testGetPoliciesIsInitiallyEmpty() {
- assertEquals(entity.getPolicies(), ImmutableList.of());
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of());
}
@Test(expectedExceptions = { UnsupportedOperationException.class })
@@ -88,48 +89,57 @@ public class PolicyRegistrationTest extends BrooklynAppUnitTestSupport {
fail();
}
+ @Test(expectedExceptions = { UnsupportedOperationException.class })
+ public void testPoliciesIteratorReturnsImmutable() {
+ entity.policies().add(policy1);
+ Iterator<Policy> iterator = entity.policies().iterator();
+ iterator.next();
+ iterator.remove();
+ fail();
+ }
+
@Test
public void testAddAndRemovePolicies() {
- entity.addPolicy(policy1);
- assertEquals(entity.getPolicies(), ImmutableList.of(policy1));
+ entity.policies().add(policy1);
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of(policy1));
assertEqualsEventually(added, ImmutableList.of(new PolicyDescriptor(policy1)));
- entity.addPolicy(policy2);
- assertEquals(entity.getPolicies(), ImmutableList.of(policy1, policy2));
+ entity.policies().add(policy2);
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of(policy1, policy2));
assertEqualsEventually(added, ImmutableList.of(new PolicyDescriptor(policy1), new PolicyDescriptor(policy2)));
- entity.removePolicy(policy1);
- assertEquals(entity.getPolicies(), ImmutableList.of(policy2));
+ entity.policies().remove(policy1);
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of(policy2));
assertEqualsEventually(removed, ImmutableList.of(new PolicyDescriptor(policy1)));
- entity.removePolicy(policy2);
- assertEquals(entity.getPolicies(), ImmutableList.of());
+ entity.policies().remove(policy2);
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of());
assertEqualsEventually(removed, ImmutableList.of(new PolicyDescriptor(policy1), new PolicyDescriptor(policy2)));
}
@Test
public void testAddPolicySpec() {
- EntitySpecTest.MyPolicy policy = entity.addPolicy(PolicySpec.create(EntitySpecTest.MyPolicy.class));
+ EntitySpecTest.MyPolicy policy = entity.policies().add(PolicySpec.create(EntitySpecTest.MyPolicy.class));
assertNotNull(policy);
- assertEquals(entity.getPolicies(), ImmutableList.of(policy));
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of(policy));
assertEqualsEventually(added, ImmutableList.of(new PolicyDescriptor(policy)));
}
@Test
public void testAddEnricherSpec() {
TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class, TestEntityNoEnrichersImpl.class));
- EntitySpecTest.MyEnricher enricher = entity2.addEnricher(EnricherSpec.create(EntitySpecTest.MyEnricher.class));
+ EntitySpecTest.MyEnricher enricher = entity2.enrichers().add(EnricherSpec.create(EntitySpecTest.MyEnricher.class));
assertNotNull(enricher);
- assertEquals(entity2.getEnrichers(), ImmutableList.of(enricher));
+ assertEquals(ImmutableList.copyOf(entity2.enrichers()), ImmutableList.of(enricher));
}
@Test
public void testRemoveAllPolicies() {
- entity.addPolicy(policy1);
- entity.addPolicy(policy2);
- entity.removeAllPolicies();
+ entity.policies().add(policy1);
+ entity.policies().add(policy2);
+ entity.policies().removeAllPolicies();
- assertEquals(entity.getPolicies(), ImmutableList.of());
+ assertEquals(ImmutableList.copyOf(entity.policies()), ImmutableList.of());
assertCollectionEqualsEventually(removed, ImmutableSet.of(new PolicyDescriptor(policy1), new PolicyDescriptor(policy2)));
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/BasicDownloadsRegistryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/BasicDownloadsRegistryTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/BasicDownloadsRegistryTest.java
index 67b1224..f2bf364 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/BasicDownloadsRegistryTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/BasicDownloadsRegistryTest.java
@@ -67,8 +67,8 @@ public class BasicDownloadsRegistryTest {
@Test
public void testUsesDownloadUrlAttribute() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
- entity.setAttribute(Attributes.DOWNLOAD_URL, "acme.com/version=${version},type=${type},simpletype=${simpletype}");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.sensors().set(Attributes.DOWNLOAD_URL, "acme.com/version=${version},type=${type},simpletype=${simpletype}");
String expectedFilename = String.format("version=%s,type=%s,simpletype=%s", "myversion", TestEntity.class.getName(), "TestEntity");
String expectedLocalRepo = String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", "TestEntity", "myversion", expectedFilename);
@@ -79,8 +79,8 @@ public class BasicDownloadsRegistryTest {
@Test
public void testUsesDownloadAddonUrlsAttribute() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myentityversion");
- entity.setAttribute(Attributes.DOWNLOAD_ADDON_URLS, ImmutableMap.of("myaddon", "acme.com/addon=${addon},version=${addonversion},type=${type},simpletype=${simpletype}"));
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myentityversion");
+ entity.sensors().set(Attributes.DOWNLOAD_ADDON_URLS, ImmutableMap.of("myaddon", "acme.com/addon=${addon},version=${addonversion},type=${type},simpletype=${simpletype}"));
String expectedFilename = String.format("addon=%s,version=%s,type=%s,simpletype=%s", "myaddon", "myaddonversion", TestEntity.class.getName(), "TestEntity");
String expectedLocalRepo = String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", "TestEntity", "myentityversion", expectedFilename);
@@ -92,7 +92,7 @@ public class BasicDownloadsRegistryTest {
@Test
public void testDefaultResolverSubstitutesDownloadUrlFailsIfVersionMissing() throws Exception {
- entity.setAttribute(Attributes.DOWNLOAD_URL, "version=${version}");
+ entity.sensors().set(Attributes.DOWNLOAD_URL, "version=${version}");
try {
DownloadResolver result = managementContext.getEntityDownloadsManager().newDownloader(driver);
fail("Should have failed, but got "+result);
@@ -106,8 +106,8 @@ public class BasicDownloadsRegistryTest {
BrooklynProperties managementProperties = managementContext.getBrooklynProperties();
managementProperties.put("brooklyn.downloads.all.url", "http://fromprops/${version}.allprimary");
managementProperties.put("brooklyn.downloads.all.fallbackurl", "http://fromfallback/${version}.allfallback");
- entity.setAttribute(Attributes.DOWNLOAD_URL, "http://fromattrib/${version}.default");
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.sensors().set(Attributes.DOWNLOAD_URL, "http://fromattrib/${version}.default");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
String expectedFilename = "myversion.allprimary";
String expectedLocalRepo = String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", "TestEntity", "myversion", expectedFilename);
@@ -123,8 +123,8 @@ public class BasicDownloadsRegistryTest {
@Test
public void testInfersFilenameFromDownloadUrl() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
- entity.setAttribute(Attributes.DOWNLOAD_URL, "http://myhost.com/myfile-${version}.tar.gz");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.sensors().set(Attributes.DOWNLOAD_URL, "http://myhost.com/myfile-${version}.tar.gz");
DownloadResolver actual = managementContext.getEntityDownloadsManager().newDownloader(driver);
assertEquals(actual.getFilename(), "myfile-myversion.tar.gz");
@@ -132,8 +132,8 @@ public class BasicDownloadsRegistryTest {
@Test
public void testInfersAddonFilenameFromDownloadUrl() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
- entity.setAttribute(Attributes.DOWNLOAD_ADDON_URLS, ImmutableMap.of("myaddon", "http://myhost.com/myfile-${addonversion}.tar.gz"));
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.sensors().set(Attributes.DOWNLOAD_ADDON_URLS, ImmutableMap.of("myaddon", "http://myhost.com/myfile-${addonversion}.tar.gz"));
DownloadResolver actual = managementContext.getEntityDownloadsManager().newDownloader(driver, "myaddon", ImmutableMap.of("addonversion", "myaddonversion"));
assertEquals(actual.getFilename(), "myfile-myaddonversion.tar.gz");
@@ -141,8 +141,8 @@ public class BasicDownloadsRegistryTest {
@Test
public void testCanOverrideFilenameFromDownloadUrl() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
- entity.setAttribute(Attributes.DOWNLOAD_URL, "http://myhost.com/download/");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.sensors().set(Attributes.DOWNLOAD_URL, "http://myhost.com/download/");
DownloadResolver actual = managementContext.getEntityDownloadsManager().newDownloader(driver, ImmutableMap.of("filename", "overridden.filename.tar.gz"));
assertEquals(actual.getFilename(), "overridden.filename.tar.gz");
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
index e6d1448..ac3e955 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromLocalRepoTest.java
@@ -84,7 +84,7 @@ public class DownloadProducerFromLocalRepoTest {
// uses default of ${simpletype}-${version}.tar.gz";
String entityVersion = "myversion";
String downloadFilename = (entitySimpleType+"-"+entityVersion+".tar.gz").toLowerCase();
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
assertResolves(String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", entitySimpleType, entityVersion, downloadFilename));
}
@@ -92,7 +92,7 @@ public class DownloadProducerFromLocalRepoTest {
public void testReturnsFilenameFromDriver() throws Exception {
String entityVersion = "myversion";
String filename = "my.file.name";
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
BasicDownloadRequirement req = new BasicDownloadRequirement(driver, ImmutableMap.of("filename", filename));
assertResolves(req, String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", entitySimpleType, entityVersion, filename));
@@ -104,7 +104,7 @@ public class DownloadProducerFromLocalRepoTest {
String entityVersion = "myversion";
String fileSuffix = "mysuffix";
String expectedFilename = (entitySimpleType+"-"+entityVersion+"."+fileSuffix).toLowerCase();
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, entityVersion);
BasicDownloadRequirement req = new BasicDownloadRequirement(driver, ImmutableMap.of("fileSuffix", fileSuffix));
assertResolves(req, String.format("file://$HOME/.brooklyn/repository/%s/%s/%s", entitySimpleType, entityVersion, expectedFilename));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
index 1398357..b0be66d 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadProducerFromPropertiesTest.java
@@ -99,7 +99,7 @@ public class DownloadProducerFromPropertiesTest {
@Test
public void testSubstitutionsAppliedToFallbackUrl() throws Exception {
brooklynProperties.put("brooklyn.downloads.all.fallbackurl", "version=${version}");
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
assertResolves(ImmutableList.<String>of(), ImmutableList.of("version=myversion"));
}
@@ -113,7 +113,7 @@ public class DownloadProducerFromPropertiesTest {
@Test
public void testReturnsGlobalUrlWithEntitySubstituions() throws Exception {
brooklynProperties.put("brooklyn.downloads.all.url", "version=${version}");
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
assertResolves("version=myversion");
}
@@ -121,7 +121,7 @@ public class DownloadProducerFromPropertiesTest {
public void testEntitySpecificUrlOverridesGlobalUrl() throws Exception {
brooklynProperties.put("brooklyn.downloads.all.url", "version=${version}");
brooklynProperties.put("brooklyn.downloads.entity.TestEntity.url", "overridden,version=${version}");
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
assertResolves("overridden,version=myversion", "version=myversion");
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadSubstitutersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadSubstitutersTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadSubstitutersTest.java
index 822a7a9..608a265 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadSubstitutersTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/drivers/downloads/DownloadSubstitutersTest.java
@@ -56,7 +56,7 @@ public class DownloadSubstitutersTest extends BrooklynAppUnitTestSupport {
@Test
public void testSimpleSubstitution() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
String pattern = "mykey1=${mykey1},mykey2=${mykey2}";
String result = DownloadSubstituters.substitute(pattern, ImmutableMap.of("mykey1", "myval1", "mykey2", "myval2"));
assertEquals(result, "mykey1=myval1,mykey2=myval2");
@@ -64,7 +64,7 @@ public class DownloadSubstitutersTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubstitutionIncludesDefaultSubs() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
String pattern = "version=${version},type=${type},simpletype=${simpletype}";
BasicDownloadRequirement req = new BasicDownloadRequirement(driver);
String result = DownloadSubstituters.substitute(req, pattern);
@@ -100,7 +100,7 @@ public class DownloadSubstitutersTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubstitutionUsesOverrides() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
String pattern = "version=${version},mykey1=${mykey1}";
BasicDownloadRequirement req = new BasicDownloadRequirement(driver, ImmutableMap.of("version", "overriddenversion", "mykey1", "myval1"));
String result = DownloadSubstituters.substitute(req, pattern);
@@ -121,7 +121,7 @@ public class DownloadSubstitutersTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubstituter() throws Exception {
- entity.setConfig(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
+ entity.config().set(BrooklynConfigKeys.SUGGESTED_VERSION, "myversion");
String baseurl = "version=${version},type=${type},simpletype=${simpletype}";
Map<String,Object> subs = DownloadSubstituters.getBasicEntitySubstitutions(driver);
DownloadTargets result = DownloadSubstituters.substituter(Functions.constant(baseurl), Functions.constant(subs)).apply(new BasicDownloadRequirement(driver));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/hello/HelloEntityImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/hello/HelloEntityImpl.java b/core/src/test/java/org/apache/brooklyn/core/entity/hello/HelloEntityImpl.java
index 67ae8a6..5f1a430 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/hello/HelloEntityImpl.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/hello/HelloEntityImpl.java
@@ -25,7 +25,7 @@ public class HelloEntityImpl extends AbstractGroupImpl implements HelloEntity {
@Override
public void setAge(Integer age) {
- setAttribute(AGE, age);
- emit(ITS_MY_BIRTHDAY, null);
+ sensors().set(AGE, age);
+ sensors().emit(ITS_MY_BIRTHDAY, null);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
index 6d64d2b..9ce3b73 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
@@ -174,7 +174,7 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigSetFromAttribute() {
- app.setConfig(HelloEntity.MY_NAME, "Bob");
+ app.config().set(HelloEntity.MY_NAME, "Bob");
HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class).parent(dad));
@@ -186,13 +186,13 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
assertEquals("Bob", son.getConfig(HelloEntity.MY_NAME));
//attributes are not
- app.setAttribute(HelloEntity.FAVOURITE_NAME, "Carl");
+ app.sensors().set(HelloEntity.FAVOURITE_NAME, "Carl");
assertEquals("Carl", app.getAttribute(HelloEntity.FAVOURITE_NAME));
assertEquals(null, dad.getAttribute(HelloEntity.FAVOURITE_NAME));
}
@Test
public void testConfigSetFromAttributeWhenReady() throws Exception {
- app.setConfig(HelloEntity.MY_NAME, "Bob");
+ app.config().set(HelloEntity.MY_NAME, "Bob");
final HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
final HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class)
@@ -230,7 +230,7 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
assertEquals(null, sonsConfig[0]);
for (Task tt : ((EntityInternal)dad).getExecutionContext().getTasks()) { log.info("task at dad: {}, {}", tt, tt.getStatusDetail(false)); }
for (Task tt : ((EntityInternal)son).getExecutionContext().getTasks()) { log.info("task at son: {}, {}", tt, tt.getStatusDetail(false)); }
- ((EntityLocal)dad).setAttribute(HelloEntity.FAVOURITE_NAME, "Dan");
+ ((EntityLocal)dad).sensors().set(HelloEntity.FAVOURITE_NAME, "Dan");
if (!s1.tryAcquire(2, TimeUnit.SECONDS)) fail("race mismatch, missing permits");
}
log.info("dad: "+dad.getAttribute(HelloEntity.FAVOURITE_NAME));
@@ -244,7 +244,7 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigSetFromAttributeWhenReadyTransformations() {
- app.setConfig(HelloEntity.MY_NAME, "Bob");
+ app.config().set(HelloEntity.MY_NAME, "Bob");
HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class)
@@ -256,13 +256,13 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
Entities.manage(son);
app.start(ImmutableList.of(loc));
- ((EntityLocal)dad).setAttribute(HelloEntity.FAVOURITE_NAME, "Dan");
+ ((EntityLocal)dad).sensors().set(HelloEntity.FAVOURITE_NAME, "Dan");
assertEquals(son.getConfig(HelloEntity.MY_NAME), "Danny");
}
@Test
public void testConfigSetFromAttributeWhenReadyNullTransformations() {
- app.setConfig(HelloEntity.MY_NAME, "Bob");
+ app.config().set(HelloEntity.MY_NAME, "Bob");
HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
// the unnecessary (HelloEntity) cast is required as a work-around to an IntelliJ issue that prevents Brooklyn from launching from the IDE
@@ -275,7 +275,7 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
Entities.manage(son);
app.start(ImmutableList.of(loc));
- ((EntityLocal)dad).setAttribute(HelloEntity.FAVOURITE_NAME, "Dan");
+ ((EntityLocal)dad).sensors().set(HelloEntity.FAVOURITE_NAME, "Dan");
assertEquals(son.getConfig(HelloEntity.MY_NAME), "Danny");
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
index 44e67df..0327258 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
@@ -49,7 +49,7 @@ public class ConfigMapGroovyTest {
@Test
public void testGetConfigOfTypeClosureReturnsClosure() throws Exception {
MyOtherEntity entity2 = new MyOtherEntity(app);
- entity2.setConfig(MyOtherEntity.CLOSURE_KEY, { return "abc" } );
+ entity2.config().set(MyOtherEntity.CLOSURE_KEY, { return "abc" } );
Entities.manage(entity2);
Closure configVal = entity2.getConfig(MyOtherEntity.CLOSURE_KEY);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
index 0a0b3a2..982d689 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
@@ -108,8 +108,8 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigSubMap() throws Exception {
- entity.setConfig(MyBaseEntity.SUPER_KEY_1, "s1");
- entity.setConfig(MySubEntity.SUB_KEY_2, "s2");
+ entity.config().set(MyBaseEntity.SUPER_KEY_1, "s1");
+ entity.config().set(MySubEntity.SUB_KEY_2, "s2");
ConfigMap sub = entity.getConfigMap().submap(ConfigPredicates.matchingGlob("sup*"));
Assert.assertEquals(sub.getConfigRaw(MyBaseEntity.SUPER_KEY_1, true).get(), "s1");
Assert.assertFalse(sub.getConfigRaw(MySubEntity.SUB_KEY_2, true).isPresent());
@@ -119,13 +119,13 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
public void testFailFastOnInvalidConfigKeyCoercion() throws Exception {
MyOtherEntity entity2 = new MyOtherEntity(app);
ConfigKey<Integer> key = MyOtherEntity.INT_KEY;
- entity2.setConfig((ConfigKey)key, "thisisnotanint");
+ entity2.config().set((ConfigKey)key, "thisisnotanint");
}
@Test
public void testGetConfigOfPredicateTaskReturnsCoercedClosure() throws Exception {
MyOtherEntity entity2 = new MyOtherEntity(app);
- entity2.setConfig(MyOtherEntity.PREDICATE_KEY, Predicates.notNull());
+ entity2.config().set(MyOtherEntity.PREDICATE_KEY, Predicates.notNull());
Entities.manage(entity2);
Predicate predicate = entity2.getConfig(MyOtherEntity.PREDICATE_KEY);
@@ -157,7 +157,7 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
Future<String> future = executor.submit(work);
final MyOtherEntity entity2 = new MyOtherEntity(app);
- entity2.setConfig((ConfigKey)MyOtherEntity.STRING_KEY, future);
+ entity2.config().set((ConfigKey)MyOtherEntity.STRING_KEY, future);
Entities.manage(entity2);
Future<String> getConfigFuture = executor.submit(new Callable<String>() {
@@ -178,7 +178,7 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
Task<String> task = executionManager.submit(work);
final MyOtherEntity entity2 = new MyOtherEntity(app);
- entity2.setConfig(MyOtherEntity.STRING_KEY, task);
+ entity2.config().set(MyOtherEntity.STRING_KEY, task);
Entities.manage(entity2);
Future<String> getConfigFuture = executor.submit(new Callable<String>() {
@@ -200,7 +200,7 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
Task<String> task = new BasicTask<String>(work);
final MyOtherEntity entity2 = new MyOtherEntity(app);
- entity2.setConfig(MyOtherEntity.STRING_KEY, task);
+ entity2.config().set(MyOtherEntity.STRING_KEY, task);
Entities.manage(entity2);
Future<String> getConfigFuture = executor.submit(new Callable<String>() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageLegacyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageLegacyTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageLegacyTest.java
index 11e3ca6..a9f1140 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageLegacyTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageLegacyTest.java
@@ -99,8 +99,8 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigCanBeSetOnEntity() throws Exception {
TestEntity entity = new TestEntityImpl(app);
- entity.setConfig(strKey, "aval");
- entity.setConfig(intKey, 2);
+ entity.config().set(strKey, "aval");
+ entity.config().set(intKey, 2);
Entities.manage(entity);
assertEquals(entity.getConfig(strKey), "aval");
@@ -110,7 +110,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigInheritedFromParent() throws Exception {
TestEntity parent = new TestEntityImpl(MutableMap.of("config", MutableMap.of(strKey, "aval")), app);
- parent.setConfig(intKey, 2);
+ parent.config().set(intKey, 2);
TestEntity entity = new TestEntityImpl(parent);
Entities.manage(parent);
@@ -131,7 +131,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testConfigSetterOverridesParentValue() throws Exception {
TestEntity parent = new TestEntityImpl(MutableMap.of("config", MutableMap.of(strKey, "aval")), app);
TestEntity entity = new TestEntityImpl(parent);
- entity.setConfig(strKey, "diffval");
+ entity.config().set(strKey, "diffval");
Entities.manage(parent);
assertEquals("diffval", entity.getConfig(strKey));
@@ -140,7 +140,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigSetterOverridesConstructorValue() throws Exception {
TestEntity entity = new TestEntityImpl(MutableMap.of("config", MutableMap.of(strKey, "aval")), app);
- entity.setConfig(strKey, "diffval");
+ entity.config().set(strKey, "diffval");
Entities.manage(entity);
assertEquals("diffval", entity.getConfig(strKey));
@@ -149,7 +149,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigSetOnParentInheritedByExistingChildrenBeforeStarted() throws Exception {
TestEntity entity = new TestEntityImpl(app);
- app.setConfig(strKey,"aval");
+ app.config().set(strKey,"aval");
Entities.manage(entity);
assertEquals("aval", entity.getConfig(strKey));
@@ -159,7 +159,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testConfigInheritedThroughManyGenerations() throws Exception {
TestEntity e = new TestEntityImpl(app);
TestEntity e2 = new TestEntityImpl(e);
- app.setConfig(strKey,"aval");
+ app.config().set(strKey,"aval");
Entities.manage(e);
assertEquals("aval", app.getConfig(strKey));
@@ -174,7 +174,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
app.start(ImmutableList.of(new SimulatedLocation()));
try {
- app.setConfig(strKey,"aval");
+ app.config().set(strKey,"aval");
fail();
} catch (IllegalStateException e) {
// success
@@ -193,7 +193,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
@Test
public void testGetFutureConfigWhenReady() throws Exception {
TestEntity entity = new TestEntityImpl(app);
- entity.setConfig(TestEntity.CONF_NAME, DependentConfiguration.whenDone(Callables.returning("aval")));
+ entity.config().set(TestEntity.CONF_NAME, DependentConfiguration.whenDone(Callables.returning("aval")));
Entities.manage(entity);
app.start(ImmutableList.of(new SimulatedLocation()));
@@ -204,7 +204,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testGetFutureConfigBlocksUntilReady() throws Exception {
TestEntity entity = new TestEntityImpl(app);
final CountDownLatch latch = new CountDownLatch(1);
- entity.setConfig(TestEntity.CONF_NAME, DependentConfiguration.whenDone(new Callable<String>() {
+ entity.config().set(TestEntity.CONF_NAME, DependentConfiguration.whenDone(new Callable<String>() {
@Override public String call() throws Exception {
latch.await();
return "aval";
@@ -234,12 +234,12 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testGetAttributeWhenReadyConfigReturnsWhenSet() throws Exception {
TestEntity entity = new TestEntityImpl(app);
TestEntity entity2 = new TestEntityImpl(app);
- entity.setConfig(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity2, TestEntity.NAME));
+ entity.config().set(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity2, TestEntity.NAME));
Entities.manage(entity);
Entities.manage(entity2);
app.start(ImmutableList.of(new SimulatedLocation()));
- entity2.setAttribute(TestEntity.NAME, "aval");
+ entity2.sensors().set(TestEntity.NAME, "aval");
assertEquals(entity.getConfig(TestEntity.CONF_NAME), "aval");
}
@@ -247,7 +247,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testGetAttributeWhenReadyWithPostProcessingConfigReturnsWhenSet() throws Exception {
TestEntity entity = new TestEntityImpl(app);
TestEntity entity2 = new TestEntityImpl(app);
- entity.setConfig(TestEntity.CONF_NAME, DependentConfiguration.attributePostProcessedWhenReady(entity2, TestEntity.NAME, Predicates.notNull(), new Function<String,String>() {
+ entity.config().set(TestEntity.CONF_NAME, DependentConfiguration.attributePostProcessedWhenReady(entity2, TestEntity.NAME, Predicates.notNull(), new Function<String,String>() {
@Override public String apply(String input) {
return (input == null) ? null : input+"mysuffix";
}}));
@@ -255,7 +255,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
Entities.manage(entity2);
app.start(ImmutableList.of(new SimulatedLocation()));
- entity2.setAttribute(TestEntity.NAME, "aval");
+ entity2.sensors().set(TestEntity.NAME, "aval");
assertEquals(entity.getConfig(TestEntity.CONF_NAME), "avalmysuffix");
}
@@ -263,7 +263,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
public void testGetAttributeWhenReadyConfigBlocksUntilSet() throws Exception {
TestEntity entity = new TestEntityImpl(app);
final TestEntity entity2 = new TestEntityImpl(app);
- entity.setConfig(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity2, TestEntity.NAME));
+ entity.config().set(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity2, TestEntity.NAME));
Entities.manage(entity);
Entities.manage(entity2);
app.start(ImmutableList.of(new SimulatedLocation()));
@@ -274,7 +274,7 @@ public class EntityConfigMapUsageLegacyTest extends BrooklynAppUnitTestSupport {
Thread t = new Thread(new Runnable() {
@Override public void run() {
Time.sleep(sleepTime);
- entity2.setAttribute(TestEntity.NAME, "aval");
+ entity2.sensors().set(TestEntity.NAME, "aval");
}});
try {
long starttime = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
index 9af2919..5dd9a5a 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
@@ -124,8 +124,8 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
@Test
public void testConfigCanBeSetOnEntity() throws Exception {
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
- ((EntityLocal)entity).setConfig(strKey, "aval");
- ((EntityLocal)entity).setConfig(intKey, 2);
+ ((EntityLocal)entity).config().set(strKey, "aval");
+ ((EntityLocal)entity).config().set(intKey, 2);
Entities.manage(entity);
assertEquals(entity.getConfig(strKey), "aval");
@@ -136,7 +136,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
public void testConfigInheritedFromParent() throws Exception {
TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class)
.configure(strKey, "aval"));
- ((EntityLocal)parent).setConfig(intKey, 2);
+ ((EntityLocal)parent).config().set(intKey, 2);
Entities.manage(parent);
TestEntity entity = parent.createAndManageChild(EntitySpec.create(TestEntity.class));
@@ -159,7 +159,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
TestEntity parent = app.createAndManageChild(EntitySpec.create(TestEntity.class)
.configure(strKey, "aval"));
TestEntity entity = parent.createAndManageChild(EntitySpec.create(TestEntity.class));
- ((EntityLocal)entity).setConfig(strKey, "diffval");
+ ((EntityLocal)entity).config().set(strKey, "diffval");
assertEquals(entity.getConfig(strKey), "diffval");
}
@@ -168,7 +168,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
public void testConfigSetterOverridesConstructorValue() throws Exception {
TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
.configure(strKey, "aval"));
- ((EntityLocal)entity).setConfig(strKey, "diffval");
+ ((EntityLocal)entity).config().set(strKey, "diffval");
Entities.manage(entity);
assertEquals(entity.getConfig(strKey), "diffval");
@@ -178,7 +178,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
public void testConfigSetOnParentInheritedByExistingChildrenBeforeStarted() throws Exception {
TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class));
TestEntity entity = parent.createChild(EntitySpec.create(TestEntity.class));
- ((EntityLocal)parent).setConfig(strKey,"aval");
+ ((EntityLocal)parent).config().set(strKey,"aval");
Entities.manage(entity);
assertEquals(entity.getConfig(strKey), "aval");
@@ -203,7 +203,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
app.start(locs);
try {
- ((EntityLocal)app).setConfig(strKey,"aval");
+ ((EntityLocal)app).config().set(strKey,"aval");
fail();
} catch (IllegalStateException e) {
// success
@@ -269,7 +269,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
.configure(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity, TestEntity.NAME)));
app.start(locs);
- ((EntityLocal)entity).setAttribute(TestEntity.NAME, "aval");
+ ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "aval");
}
@@ -283,7 +283,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
}})));
app.start(locs);
- ((EntityLocal)entity).setAttribute(TestEntity.NAME, "aval");
+ ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "avalmysuffix");
}
@@ -298,7 +298,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
public void run() {
try {
Thread.sleep(10+EARLY_RETURN_GRACE);
- ((EntityLocal)entity).setAttribute(TestEntity.NAME, "aval");
+ ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
} catch (InterruptedException e) {
throw Exceptions.propagate(e);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogicTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogicTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogicTest.java
index 33d5e1c..ddb4d53 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogicTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/lifecycle/ServiceStateLogicTest.java
@@ -203,7 +203,7 @@ public class ServiceStateLogicTest extends BrooklynAppUnitTestSupport {
// if we change the state quorum check for the app to be "all are healthy and at least one running" *then* it shows stopped
// (normally this would be done in `initEnrichers` of course)
- Enricher appChildrenBasedEnricher = EntityAdjuncts.tryFindWithUniqueTag(app.getEnrichers(), ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG).get();
+ Enricher appChildrenBasedEnricher = EntityAdjuncts.tryFindWithUniqueTag(app.enrichers(), ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG).get();
appChildrenBasedEnricher.config().set(ComputeServiceIndicatorsFromChildrenAndMembers.RUNNING_QUORUM_CHECK, QuorumChecks.allAndAtLeastOne());
assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
@@ -271,14 +271,14 @@ public class ServiceStateLogicTest extends BrooklynAppUnitTestSupport {
//manually set state to healthy as enrichers are disabled
EntityInternal child = (EntityInternal) cluster.getMembers().iterator().next();
- child.setAttribute(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- child.setAttribute(Attributes.SERVICE_UP, Boolean.TRUE);
+ child.sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ child.sensors().set(Attributes.SERVICE_UP, Boolean.TRUE);
EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
//set untyped service state, the quorum check should be able to handle coercion
AttributeSensor<Object> stateSensor = Sensors.newSensor(Object.class, Attributes.SERVICE_STATE_ACTUAL.getName());
- child.setAttribute(stateSensor, "running");
+ child.sensors().set(stateSensor, "running");
EntityTestUtils.assertAttributeEqualsContinually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/location/LocationPredicatesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/LocationPredicatesTest.java b/core/src/test/java/org/apache/brooklyn/core/location/LocationPredicatesTest.java
index 0075ec0..9991931 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/LocationPredicatesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/LocationPredicatesTest.java
@@ -63,7 +63,7 @@ public class LocationPredicatesTest {
@Test
public void testConfigEqualTo() throws Exception {
- loc.setConfig(TestEntity.CONF_NAME, "myname");
+ loc.config().set(TestEntity.CONF_NAME, "myname");
assertTrue(LocationPredicates.configEqualTo(TestEntity.CONF_NAME, "myname").apply(loc));
assertFalse(LocationPredicates.configEqualTo(TestEntity.CONF_NAME, "wrongname").apply(loc));
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtilsTest.java b/core/src/test/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtilsTest.java
index 17a24b0..afca28d 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtilsTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/access/BrooklynAccessUtilsTest.java
@@ -79,7 +79,7 @@ public class BrooklynAccessUtilsTest extends BrooklynAppUnitTestSupport {
entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
.configure(BrooklynAccessUtils.PORT_FORWARDING_MANAGER, pfm)
.location(machine));
- entity.setAttribute(Attributes.HOSTNAME, privateIp);
+ entity.sensors().set(Attributes.HOSTNAME, privateIp);
assertEquals(BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, privatePort), HostAndPort.fromParts(privateIp, privatePort));
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/location/access/PortForwardManagerRebindTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/access/PortForwardManagerRebindTest.java b/core/src/test/java/org/apache/brooklyn/core/location/access/PortForwardManagerRebindTest.java
index f14c4a3..3ce1177 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/access/PortForwardManagerRebindTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/access/PortForwardManagerRebindTest.java
@@ -187,8 +187,8 @@ public class PortForwardManagerRebindTest extends RebindTestFixtureWithApp {
if (getConfig(PORT_FORWARD_MANAGER) == null) {
PortForwardManager pfm = (PortForwardManager) getManagementContext().getLocationRegistry().resolve("portForwardManager(scope=global)");
- setAttribute(PORT_FORWARD_MANAGER_LIVE, pfm);
- setConfig(PORT_FORWARD_MANAGER, pfm);
+ sensors().set(PORT_FORWARD_MANAGER_LIVE, pfm);
+ config().set(PORT_FORWARD_MANAGER, pfm);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerInMemoryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerInMemoryTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerInMemoryTest.java
index 36e0fa2..84f076f 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerInMemoryTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerInMemoryTest.java
@@ -64,7 +64,7 @@ public class HighAvailabilityManagerInMemoryTest extends HighAvailabilityManager
TestApplication app = TestApplication.Factory.newManagedInstanceForTests(managementContext);
LocalhostMachineProvisioningLocation l = app.newLocalhostProvisioningLocation();
- l.setConfig(TestEntity.CONF_NAME, "sample1");
+ l.config().set(TestEntity.CONF_NAME, "sample1");
Assert.assertEquals(l.getConfig(TestEntity.CONF_NAME), "sample1");
SshMachineLocation l2 = l.obtain();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerSplitBrainTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerSplitBrainTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerSplitBrainTest.java
index 6f80a5c..8b34f68 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerSplitBrainTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HighAvailabilityManagerSplitBrainTest.java
@@ -327,7 +327,7 @@ public class HighAvailabilityManagerSplitBrainTest {
// create
TestApplication app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class), n1.mgmt);
app.start(ImmutableList.<Location>of());
- app.setAttribute(TestApplication.MY_ATTRIBUTE, "hello");
+ app.sensors().set(TestApplication.MY_ATTRIBUTE, "hello");
assertEquals(n1.mgmt.getApplications().size(), 1);
assertEquals(n2.mgmt.getApplications().size(), 0);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
index 1ee7053..2eaebcf 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
@@ -184,7 +184,7 @@ public class HotStandbyTest {
app.setDisplayName("First App");
app.start(MutableList.<Location>of());
app.config().set(TestEntity.CONF_NAME, "first-app");
- app.setAttribute(TestEntity.SEQUENCE, 3);
+ app.sensors().set(TestEntity.SEQUENCE, 3);
forcePersistNow(n1);
return app;
@@ -233,7 +233,7 @@ public class HotStandbyTest {
assertEquals(appRO.getAttribute(TestEntity.SEQUENCE), (Integer)3);
try {
- ((TestApplication)appRO).setAttribute(TestEntity.SEQUENCE, 4);
+ ((TestApplication)appRO).sensors().set(TestEntity.SEQUENCE, 4);
Assert.fail("Should not have allowed sensor to be set");
} catch (Exception e) {
Assert.assertTrue(e.toString().toLowerCase().contains("read-only"), "Error message did not contain expected text: "+e);
@@ -256,7 +256,7 @@ public class HotStandbyTest {
app.setDisplayName("First App Renamed");
app.config().set(TestEntity.CONF_NAME, "first-app-renamed");
- app.setAttribute(TestEntity.SEQUENCE, 4);
+ app.sensors().set(TestEntity.SEQUENCE, 4);
appRO = expectRebindSequenceNumber(n1, n2, app, 4, true);
assertEquals(n2.mgmt.getEntityManager().getEntities().size(), 1);
@@ -267,7 +267,7 @@ public class HotStandbyTest {
app.setDisplayName("First App");
app.config().set(TestEntity.CONF_NAME, "first-app-restored");
- app.setAttribute(TestEntity.SEQUENCE, 5);
+ app.sensors().set(TestEntity.SEQUENCE, 5);
appRO = expectRebindSequenceNumber(n1, n2, app, 5, true);
assertEquals(n2.mgmt.getEntityManager().getEntities().size(), 1);
@@ -302,7 +302,7 @@ public class HotStandbyTest {
TestApplication app2 = TestApplication.Factory.newManagedInstanceForTests(n1.mgmt);
app2.config().set(TestEntity.CONF_NAME, "second-app");
- app.setAttribute(TestEntity.SEQUENCE, 4);
+ app.sensors().set(TestEntity.SEQUENCE, 4);
appRO = expectRebindSequenceNumber(n1, n2, app, 4, immediate);
assertEquals(appRO.getChildren().size(), 1);
@@ -322,7 +322,7 @@ public class HotStandbyTest {
Entities.unmanage(child);
Entities.unmanage(app2);
- app.setAttribute(TestEntity.SEQUENCE, 5);
+ app.sensors().set(TestEntity.SEQUENCE, 5);
appRO = expectRebindSequenceNumber(n1, n2, app, 5, immediate);
EntityTestUtils.assertAttributeEqualsEventually(appRO, TestEntity.SEQUENCE, 5);
@@ -540,7 +540,7 @@ public class HotStandbyTest {
Assert.assertNotNull(app2RO);
assertEquals(app2RO.getConfig(TestEntity.CONF_NAME), "second-app");
try {
- ((TestApplication)app2RO).setAttribute(TestEntity.SEQUENCE, 4);
+ ((TestApplication)app2RO).sensors().set(TestEntity.SEQUENCE, 4);
Assert.fail("Should not have allowed sensor to be set");
} catch (Exception e) {
Assert.assertTrue(e.toString().toLowerCase().contains("read-only"), "Error message did not contain expected text: "+e);
@@ -561,7 +561,7 @@ public class HotStandbyTest {
Application app2B = n2.mgmt.lookup(app2.getId(), Application.class);
Assert.assertNotNull(app2B);
assertEquals(app2B.getConfig(TestEntity.CONF_NAME), "second-app");
- ((TestApplication)app2B).setAttribute(TestEntity.SEQUENCE, 4);
+ ((TestApplication)app2B).sensors().set(TestEntity.SEQUENCE, 4);
forcePersistNow(n2);
forceRebindNow(n1);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/EntityExecutionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/EntityExecutionManagerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/EntityExecutionManagerTest.java
index 590b8fb..b00ffc4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/EntityExecutionManagerTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/EntityExecutionManagerTest.java
@@ -297,7 +297,7 @@ public class EntityExecutionManagerTest {
List<Task<?>> t1 = em.getAllTasks();
TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
- entity.setAttribute(TestEntity.NAME, "bob");
+ entity.sensors().set(TestEntity.NAME, "bob");
entity.invoke(TestEntity.MY_EFFECTOR, ImmutableMap.<String,Object>of()).get();
Entities.destroy(entity);
Time.sleep(Duration.ONE_SECOND);
@@ -347,7 +347,7 @@ public class EntityExecutionManagerTest {
try {
LOG.debug(JavaClassNames.niceClassAndMethod()+": iteration="+i);
TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
- entity.setAttribute(byteArrayAttrib, new BigObject(10*1000*1000));
+ entity.sensors().set(byteArrayAttrib, new BigObject(10*1000*1000));
entity.invoke(TestEntity.MY_EFFECTOR, ImmutableMap.<String,Object>of()).get();
// we get exceptions because tasks are still trying to publish after deployment;
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
index 08efee4..10f07ab 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
@@ -64,7 +64,7 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubscribeToEntityAttributeChange() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
- app.subscribe(entity, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
+ app.subscriptions().subscribe(entity, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
@Override public void onEvent(SensorEvent<Object> event) {
latch.countDown();
}});
@@ -77,7 +77,7 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubscribeToEntityWithAttributeWildcard() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
- app.subscribe(entity, null, new SensorEventListener<Object>() {
+ app.subscriptions().subscribe(entity, null, new SensorEventListener<Object>() {
@Override public void onEvent(SensorEvent<Object> event) {
latch.countDown();
}});
@@ -90,7 +90,7 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubscribeToAttributeChangeWithEntityWildcard() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
- app.subscribe(null, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
+ app.subscriptions().subscribe(null, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
@Override public void onEvent(SensorEvent<Object> event) {
latch.countDown();
}});
@@ -103,7 +103,7 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
@Test
public void testSubscribeToChildAttributeChange() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
- app.subscribeToChildren(app, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
+ app.subscriptions().subscribeToChildren(app, TestEntity.SEQUENCE, new SensorEventListener<Object>() {
@Override public void onEvent(SensorEvent<Object> event) {
latch.countDown();
}});
@@ -123,7 +123,7 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
final List<SensorEvent<Integer>> events = new CopyOnWriteArrayList<SensorEvent<Integer>>();
final CountDownLatch latch = new CountDownLatch(1);
- app.subscribeToMembers(group, TestEntity.SEQUENCE, new SensorEventListener<Integer>() {
+ app.subscriptions().subscribeToMembers(group, TestEntity.SEQUENCE, new SensorEventListener<Integer>() {
@Override public void onEvent(SensorEvent<Integer> event) {
events.add(event);
latch.countDown();
@@ -154,10 +154,10 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
@Override public void onEvent(SensorEvent<Object> event) {
}
};
- app.subscribe(null, TestEntity.SEQUENCE, noopListener);
+ app.subscriptions().subscribe(null, TestEntity.SEQUENCE, noopListener);
while (!Thread.currentThread().isInterrupted()) {
- SubscriptionHandle handle = app.subscribe(null, TestEntity.SEQUENCE, noopListener);
- app.unsubscribe(null, handle);
+ SubscriptionHandle handle = app.subscriptions().subscribe(null, TestEntity.SEQUENCE, noopListener);
+ app.subscriptions().unsubscribe(null, handle);
}
} catch (Exception e) {
threadException.set(e);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiVersionMoreEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiVersionMoreEntityTest.java
index 5eb9bbf..ad878da 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiVersionMoreEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/osgi/OsgiVersionMoreEntityTest.java
@@ -260,11 +260,11 @@ public class OsgiVersionMoreEntityTest {
OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_POLICY,
TEST_VERSION,
BROOKLYN_TEST_OSGI_ENTITIES_URL);
- me.addPolicy(getPolicySpec(cp));
+ me.policies().add(getPolicySpec(cp));
Assert.assertEquals(me.getPolicies().size(), 1, "Wrong number of policies: "+me.getPolicies());
- String catalogItemId = Iterables.getOnlyElement( me.getPolicies() ).getCatalogItemId();
+ String catalogItemId = Iterables.getOnlyElement( me.policies() ).getCatalogItemId();
Assert.assertNotNull(catalogItemId);
// must be the actual source bundle
Assert.assertFalse(catalogItemId.equals(me.getCatalogItemId()), "catalog item id is: "+catalogItemId);
@@ -311,7 +311,7 @@ public class OsgiVersionMoreEntityTest {
assertV2EffectorCall(me);
Assert.assertEquals(me.getPolicies().size(), 1, "Wrong number of policies: "+me.getPolicies());
- String catalogItemId = Iterables.getOnlyElement( me.getPolicies() ).getCatalogItemId();
+ String catalogItemId = Iterables.getOnlyElement( me.policies() ).getCatalogItemId();
Assert.assertNotNull(catalogItemId);
// allow either me's bundle (more) or the actual source bundle
Assert.assertTrue(catalogItemId.equals(me.getCatalogItemId()) || catalogItemId.startsWith("brooklyn-test-osgi-entities"));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
index 3f5c482..716e246 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterInMemorySizeIntegrationTest.java
@@ -76,7 +76,7 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends Brookly
Assert.assertTrue(out1<30*1000, "should have written less than 30k, wrote "+out1);
Assert.assertTrue(filesOut1<30, "should have written fewer than 30 files, wrote "+out1);
- ((EntityInternal)app).setAttribute(TestEntity.NAME, "hello world");
+ ((EntityInternal)app).sensors().set(TestEntity.NAME, "hello world");
if (forceDelay) Time.sleep(Duration.FIVE_SECONDS);
else recorder.blockUntilDataWrittenExceeds(out1+10, Duration.FIVE_SECONDS);
localManagementContext.getRebindManager().waitForPendingComplete(Duration.FIVE_SECONDS, canTrigger);
@@ -89,7 +89,7 @@ public class BrooklynMementoPersisterInMemorySizeIntegrationTest extends Brookly
Assert.assertTrue(out2<50*1000, "should have written less than 50k, wrote "+out1);
Assert.assertTrue(filesOut2<40, "should have written fewer than 40 files, wrote "+out1);
- ((EntityInternal)entity).setAttribute(TestEntity.NAME, Identifiers.makeRandomId(bigBlockSize));
+ ((EntityInternal)entity).sensors().set(TestEntity.NAME, Identifiers.makeRandomId(bigBlockSize));
if (forceDelay) Time.sleep(Duration.FIVE_SECONDS);
else recorder.blockUntilDataWrittenExceeds(out2+bigBlockSize, Duration.FIVE_SECONDS);
localManagementContext.getRebindManager().waitForPendingComplete(Duration.FIVE_SECONDS, canTrigger);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
index 03a9c79..a355abd 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
@@ -85,8 +85,8 @@ public abstract class BrooklynMementoPersisterTestFixture {
.createLocation(LocationSpec.create(SshMachineLocation.class)
.configure("address", "localhost"));
entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(location));
- enricher = app.addEnricher(Enrichers.builder().propagatingAll().from(entity).build());
- app.addPolicy(policy = new TestPolicy());
+ enricher = app.enrichers().add(Enrichers.builder().propagatingAll().from(entity).build());
+ app.policies().add(policy = new TestPolicy());
}
protected abstract ManagementContext newPersistingManagementContext();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
index dae43a7..2c3b281 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
@@ -95,8 +95,8 @@ public class CheckpointEntityTest extends RebindTestFixtureWithApp {
@Test
public void testPersistsOnExplicitCheckpointOfEntity() throws Exception {
- origE.setConfig(MyEntity.MY_CONFIG, "mynewval");
- origE.setAttribute(MyEntity.MY_SENSOR, "mysensorval");
+ origE.config().set(MyEntity.MY_CONFIG, "mynewval");
+ origE.sensors().set(MyEntity.MY_SENSOR, "mysensorval");
// Assert persisted the modified config/attributes
newApp = rebind();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d08310c/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
index a109f13..6a034c4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
@@ -103,7 +103,7 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
EntitySpec<StartableApplication> appSpec = EntitySpec.create(StartableApplication.class, appClazz)
.configure("myconf", "myconfval");
origApp = ApplicationBuilder.newManagedApp(appSpec, origManagementContext);
- ((EntityInternal)origApp).setAttribute(Sensors.newStringSensor("mysensor"), "mysensorval");
+ ((EntityInternal)origApp).sensors().set(Sensors.newStringSensor("mysensor"), "mysensorval");
newApp = rebindWithAppClass();
Entities.dumpInfo(newApp);