You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:50:54 UTC
[38/50] [abbrv] brooklyn-server git commit: rename non-java mentions
of classes which have been moved -- in plans, comments, and docs
rename non-java mentions of classes which have been moved -- in plans, comments, and docs
minor other tidies, to policies docs, and camp Service.toString, to remove prefixes rather than just change them;
in docs, we've also updated `package_path`, policies docs, links, and confirmed the build of api docs and catalog
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/6e0a847e
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/6e0a847e
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/6e0a847e
Branch: refs/heads/0.8.0-incubating
Commit: 6e0a847e385041154e186f69ac12f4dabe1f126d
Parents: fa424c0
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Aug 31 17:20:30 2015 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Sep 1 12:05:39 2015 +0100
----------------------------------------------------------------------
.../brooklyn/api/catalog/BrooklynCatalog.java | 8 +-
.../apache/brooklyn/api/location/Location.java | 4 -
.../apache/brooklyn/camp/spi/pdp/Service.java | 3 +-
.../brooklyn/core/catalog/CatalogLoadMode.java | 3 +-
.../catalog/internal/CatalogInitialization.java | 1 +
.../core/entity/lifecycle/Lifecycle.java | 8 +-
.../brooklyn/core/location/geo/HostGeoInfo.java | 11 +
.../rebind/transformer/CompoundTransformer.java | 2 +-
.../core/objs/proxy/InternalEntityFactory.java | 2 +-
.../core/sensor/DependentConfiguration.java | 2 +-
.../core/catalog/CatalogPredicatesTest.java | 22 +-
.../core/effector/EffectorBasicTest.java | 14 +-
.../core/entity/EntityPreManagementTest.java | 6 +-
.../core/entity/PolicyRegistrationTest.java | 7 +-
.../mgmt/osgi/OsgiVersionMoreEntityTest.java | 3 +-
...stomAggregatingEnricherDeprecatedTest.groovy | 14 +-
.../TransformingEnricherDeprecatedTest.groovy | 4 +-
.../entity/group/DynamicClusterTest.java | 2 +-
.../entity/group/DynamicFabricTest.java | 4 +-
.../brooklyn/location/jclouds/JcloudsUtil.java | 6 +-
.../JcloudsPortForwarderExtension.java | 3 +-
.../policy/enricher/HttpLatencyDetector.java | 5 +-
.../apache/brooklyn/feed/jmx/JmxFeedTest.java | 15 +-
.../apache/brooklyn/feed/jmx/JmxHelperTest.java | 3 +-
.../brooklyn/spi/creation/CampCatalogUtils.java | 2 +-
.../main/resources/brooklyn/default.catalog.bom | 20 +-
...lynLauncherRebindToCloudObjectStoreTest.java | 6 +-
.../src/test/resources/mongo-sharded.yaml | 2 +-
.../rest/domain/ApplicationSpecTest.java | 2 +-
.../brooklyn/rest/domain/EntitySpecTest.java | 2 +-
.../resources/fixtures/application-list.json | 2 +-
.../resources/fixtures/application-spec.json | 4 +-
.../test/resources/fixtures/application.json | 4 +-
.../resources/fixtures/entity-only-type.json | 4 +-
.../src/test/resources/fixtures/entity.json | 2 +-
.../brooklyn/rest/domain/ApplicationTest.java | 2 +-
.../org/apache/brooklyn/test/TestUtils.groovy | 538 -------------------
.../org/apache/brooklyn/test/TestUtils.java | 79 +++
.../java/org/apache/brooklyn/test/Asserts.java | 17 +-
.../util/internal/BrooklynSystemProperties.java | 5 +-
.../util/javalang/StackTraceSimplifier.java | 6 +-
41 files changed, 199 insertions(+), 650 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/api/src/main/java/org/apache/brooklyn/api/catalog/BrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/catalog/BrooklynCatalog.java b/api/src/main/java/org/apache/brooklyn/api/catalog/BrooklynCatalog.java
index 00ce2e7..21002d9 100644
--- a/api/src/main/java/org/apache/brooklyn/api/catalog/BrooklynCatalog.java
+++ b/api/src/main/java/org/apache/brooklyn/api/catalog/BrooklynCatalog.java
@@ -26,25 +26,25 @@ import com.google.common.base.Predicate;
public interface BrooklynCatalog {
static String DEFAULT_VERSION = "0.0.0_DEFAULT_VERSION";
- /** @return The item with the given {@link brooklyn.catalog.CatalogItem#getSymbolicName()
+ /** @return The item with the given {@link CatalogItem#getSymbolicName()
* symbolicName}, or null if not found.
* @deprecated since 0.7.0 use {@link #getCatalogItem(String, String)};
* or see also CatalogUtils getCatalogItemOptionalVersion */
@Deprecated
CatalogItem<?,?> getCatalogItem(String symbolicName);
- /** @return The item with the given {@link brooklyn.catalog.CatalogItem#getSymbolicName()
+ /** @return The item with the given {@link CatalogItem#getSymbolicName()
* symbolicName}, or null if not found. */
CatalogItem<?,?> getCatalogItem(String symbolicName, String version);
/** @return Deletes the item with the given
- * {@link brooklyn.catalog.CatalogItem#getSymbolicName() symbolicName}
+ * {@link CatalogItem#getSymbolicName() symbolicName}
* @throws NoSuchElementException if not found
* @deprecated since 0.7.0 use {@link #deleteCatalogItem(String, String)} */
@Deprecated
void deleteCatalogItem(String symbolicName);
- /** @return Deletes the item with the given {@link brooklyn.catalog.CatalogItem#getSymbolicName()
+ /** @return Deletes the item with the given {@link CatalogItem#getSymbolicName()
* symbolicName} and version
* @throws NoSuchElementException if not found */
void deleteCatalogItem(String symbolicName, String version);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/api/src/main/java/org/apache/brooklyn/api/location/Location.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/location/Location.java b/api/src/main/java/org/apache/brooklyn/api/location/Location.java
index e2c49fb..392af13 100644
--- a/api/src/main/java/org/apache/brooklyn/api/location/Location.java
+++ b/api/src/main/java/org/apache/brooklyn/api/location/Location.java
@@ -29,10 +29,6 @@ import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
/**
* A location that an entity can be in. Examples of locations include a single machine
* or a pool of machines, or a region within a given cloud.
- *
- * See {@link brooklyn.entity.trait.Startable#start(Collection)}.
- *
- * Locations may not be {@link Serializable} in subsequent releases!
*/
public interface Location extends Serializable, BrooklynObject {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/Service.java
----------------------------------------------------------------------
diff --git a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/Service.java b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/Service.java
index af15ddf..7bc310f 100644
--- a/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/Service.java
+++ b/camp/camp-base/src/main/java/org/apache/brooklyn/camp/spi/pdp/Service.java
@@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.yaml.Yamls;
import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -87,7 +88,7 @@ public class Service {
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this);
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogLoadMode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogLoadMode.java b/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogLoadMode.java
index 73f5a4e..dd2e54b 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogLoadMode.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogLoadMode.java
@@ -20,6 +20,7 @@ package org.apache.brooklyn.core.catalog;
import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
import org.apache.brooklyn.core.mgmt.persist.PersistMode;
+import org.apache.brooklyn.core.server.BrooklynServerConfig;
import org.slf4j.LoggerFactory;
/** @deprecated since 0.7.0 replaced by {@link CatalogInitialization} */
@@ -27,7 +28,7 @@ import org.slf4j.LoggerFactory;
public enum CatalogLoadMode {
/**
* The server will load its initial catalog from the URL configured in
- * {@link brooklyn.config.BrooklynServerConfig#BROOKLYN_CATALOG_URL} and will
+ * {@link BrooklynServerConfig#BROOKLYN_CATALOG_URL} and will
* disregard existing persisted state.
*/
LOAD_BROOKLYN_CATALOG_URL,
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
index 907cbb8..041037f 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import org.apache.brooklyn.api.catalog.CatalogItem;
import org.apache.brooklyn.api.mgmt.ManagementContext;
import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
+import org.apache.brooklyn.core.catalog.CatalogLoadMode;
import org.apache.brooklyn.core.mgmt.ManagementContextInjectable;
import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
import org.apache.brooklyn.core.server.BrooklynServerConfig;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/Lifecycle.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/Lifecycle.java b/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/Lifecycle.java
index dfbdbd7..68b316e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/Lifecycle.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/lifecycle/Lifecycle.java
@@ -25,6 +25,7 @@ import java.util.regex.Pattern;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.core.config.render.RendererHints;
+import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.util.core.flags.TypeCoercions;
import org.apache.brooklyn.util.text.StringFunctions;
@@ -41,7 +42,7 @@ public enum Lifecycle {
* The entity has just been created.
*
* This stage encompasses the contruction. Once this stage is
- * complete, the basic set of {@link brooklyn.event.Sensor}s will be available, apart from any that require the entity to be active or
+ * complete, the basic set of sensors will be available, apart from any that require the entity to be active or
* deployed to a {@link Location}.
*/
CREATED,
@@ -49,7 +50,7 @@ public enum Lifecycle {
/**
* The entity is starting.
* <p>
- * This stage is typically entered when the {@link brooklyn.entity.trait.Startable#START} {@link brooklyn.entity.Effector}
+ * This stage is typically entered when the {@link Startable#START} effector
* is called, to undertake the startup operations from the management plane.
* When this completes the entity will normally transition to
* {@link Lifecycle#RUNNING}.
@@ -65,7 +66,8 @@ public enum Lifecycle {
/**
* The entity is stopping.
*
- * This stage is activated when the {@link brooklyn.entity.trait.Startable#STOP} effector is called. The entity service is stopped.
+ * This stage is activated when the
+ * {@link Startable#STOP} effector is called. The entity service is stopped.
* Sensors that provide data from the running entity may be cleared and subscriptions cancelled.
*/
STOPPING,
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/location/geo/HostGeoInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/geo/HostGeoInfo.java b/core/src/main/java/org/apache/brooklyn/core/location/geo/HostGeoInfo.java
index 7089de9..f99b41d 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/geo/HostGeoInfo.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/geo/HostGeoInfo.java
@@ -140,9 +140,20 @@ public class HostGeoInfo implements Serializable {
}
return result;
}
+
+ @Deprecated
+ private static boolean warnedLegacy = false;
private static HostGeoLookup findHostGeoLookupImpl() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
String type = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL.getValue();
+ if (type==null) {
+ type = BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL_LEGACY.getValue();
+ if (type!=null && !warnedLegacy) {
+ warnedLegacy = true;
+ log.warn("Using deprecated host-geo-lookup property "+BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL_LEGACY+"; "
+ + "set "+BrooklynSystemProperties.HOST_GEO_LOOKUP_IMPL+" instead");
+ }
+ }
/* utrace seems more accurate than geobytes, and it gives a report of how many tokens are left;
* but maxmind if it's installed locally is even better (does not require remote lookup),
* so use it if available */
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java
index 74b1375..09b28b4 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/CompoundTransformer.java
@@ -201,7 +201,7 @@ public class CompoundTransformer {
}
private String toXstreamClassnameFormat(String val) {
- // xstream format for inner classes is like <brooklyn.entity.rebind.transformer.CompoundTransformerTest_-OrigType>
+ // xstream format for inner classes is like <org.apache.brooklyn.core.mgmt.rebind.transformer.CompoundTransformerTest_-OrigType>
return (val.contains("$")) ? val.replace("$", "_-") : val;
}
public CompoundTransformer build() {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
index 9547c9d..af7dd77 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
@@ -112,7 +112,7 @@ public class InternalEntityFactory extends InternalFactory {
// TODO OSGi strangeness! The classloader obtained from the type should be enough.
// If an OSGi class loader, it should delegate to find things like Entity.class etc.
// However, we get errors such as:
- // NoClassDefFoundError: brooklyn.event.AttributeSensor not found by io.brooklyn.brooklyn-test-osgi-entities
+ // NoClassDefFoundError: org.apache.brooklyn.api.sensor.AttributeSensor not found by ....brooklyn-test-osgi-entities
// Building our own aggregating class loader gets around this.
// But we really should not have to do this! What are the consequences?
//
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java b/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java
index d4f32d8..01e3426 100644
--- a/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java
+++ b/core/src/main/java/org/apache/brooklyn/core/sensor/DependentConfiguration.java
@@ -90,7 +90,7 @@ import com.google.common.collect.Lists;
* If using a lot it may be useful to:
* <pre>
* {@code
- * import static brooklyn.event.basic.DependentConfiguration.*;
+ * import static org.apache.brooklyn.core.sensor.DependentConfiguration.*;
* }
* </pre>
*/
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/core/catalog/CatalogPredicatesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/catalog/CatalogPredicatesTest.java b/core/src/test/java/org/apache/brooklyn/core/catalog/CatalogPredicatesTest.java
index e858061..2f9e841 100644
--- a/core/src/test/java/org/apache/brooklyn/core/catalog/CatalogPredicatesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/catalog/CatalogPredicatesTest.java
@@ -55,7 +55,7 @@ public class CatalogPredicatesTest {
@Test
public void testDisplayName() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.displayName("myname")
.build());
@@ -66,7 +66,7 @@ public class CatalogPredicatesTest {
@Test
public void testDeprecated() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>deprecated(false).apply(item));
@@ -81,7 +81,7 @@ public class CatalogPredicatesTest {
@Test
public void testDisabled() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>disabled(false).apply(item));
@@ -96,7 +96,7 @@ public class CatalogPredicatesTest {
@Test
public void testIsCatalogItemType() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>isCatalogItemType(CatalogItemType.ENTITY).apply(item));
@@ -106,7 +106,7 @@ public class CatalogPredicatesTest {
@Test
public void testSymbolicName() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>symbolicName(Predicates.equalTo("foo")).apply(item));
@@ -116,14 +116,14 @@ public class CatalogPredicatesTest {
@Test
public void testIsBestVersion() {
CatalogItem<Entity, EntitySpec<?>> itemV1 = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
CatalogItem<Entity, EntitySpec<?>> itemV2 = createItem(CatalogItemBuilder.newEntity("foo", "2.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
CatalogItem<Entity, EntitySpec<?>> itemV3Disabled = createItem(CatalogItemBuilder.newEntity("foo", "3.0")
.disabled(true)
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>isBestVersion(mgmt).apply(itemV2));
@@ -135,7 +135,7 @@ public class CatalogPredicatesTest {
public void testEntitledToSee() {
// TODO No entitlements configured, so everything allowed - therefore test not thorough enough!
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .plan("services:\n- type: brooklyn.entity.basic.BasicEntity")
+ .plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>entitledToSee(mgmt).apply(item));
@@ -145,10 +145,10 @@ public class CatalogPredicatesTest {
@Test
public void testJavaType() {
CatalogItem<Entity, EntitySpec<?>> item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
- .javaType("brooklyn.entity.basic.BasicEntity")
+ .javaType("org.apache.brooklyn.entity.stock.BasicEntity")
.build());
- assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>javaType(Predicates.equalTo("brooklyn.entity.basic.BasicEntity")).apply(item));
+ assertTrue(CatalogPredicates.<Entity,EntitySpec<?>>javaType(Predicates.equalTo("org.apache.brooklyn.entity.stock.BasicEntity")).apply(item));
assertFalse(CatalogPredicates.<Entity,EntitySpec<?>>javaType(Predicates.equalTo("wrongtype")).apply(item));
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/core/effector/EffectorBasicTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/effector/EffectorBasicTest.java b/core/src/test/java/org/apache/brooklyn/core/effector/EffectorBasicTest.java
index b05a397..a8dfda5 100644
--- a/core/src/test/java/org/apache/brooklyn/core/effector/EffectorBasicTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/effector/EffectorBasicTest.java
@@ -32,7 +32,7 @@ import org.apache.brooklyn.core.location.SimulatedLocation;
import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.TestUtils;
+import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.task.Tasks;
import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -63,20 +63,20 @@ public class EffectorBasicTest extends BrooklynAppUnitTestSupport {
@Test
public void testInvokeEffectorStart() {
app.start(locs);
- TestUtils.assertSetsEqual(locs, app.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, app.getLocations());
// TODO above does not get registered as a task
}
@Test
public void testInvokeEffectorStartWithMap() {
app.invoke(Startable.START, MutableMap.of("locations", locs)).getUnchecked();
- TestUtils.assertSetsEqual(locs, app.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, app.getLocations());
}
@Test
public void testInvokeEffectorStartWithArgs() {
Entities.invokeEffectorWithArgs((EntityLocal)app, app, Startable.START, locs).getUnchecked();
- TestUtils.assertSetsEqual(locs, app.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, app.getLocations());
}
@Test
@@ -84,9 +84,9 @@ public class EffectorBasicTest extends BrooklynAppUnitTestSupport {
TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
TestEntity entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
app.start(locs);
- TestUtils.assertSetsEqual(locs, app.getLocations());
- TestUtils.assertSetsEqual(locs, entity.getLocations());
- TestUtils.assertSetsEqual(locs, entity2.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, app.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, entity.getLocations());
+ Asserts.assertEqualsIgnoringOrder(locs, entity2.getLocations());
}
@Test
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
index 0d83980..e10c703 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
@@ -34,7 +34,7 @@ import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
import org.apache.brooklyn.core.test.entity.TestApplication;
import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.TestUtils;
+import org.apache.brooklyn.test.Asserts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -102,7 +102,7 @@ public class EntityPreManagementTest {
e.setParent(app);
Entities.manage(e);
- TestUtils.assertEventually(new Runnable() {
+ Asserts.succeedsEventually(new Runnable() {
@Override
public void run() {
if (events.isEmpty()) Assert.fail("no events received");
@@ -135,7 +135,7 @@ public class EntityPreManagementTest {
Entities.startManagement(app, managementContext);
- TestUtils.assertEventually(new Runnable() {
+ Asserts.succeedsEventually(new Runnable() {
@Override
public void run() {
if (events.isEmpty()) Assert.fail("no events received");
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/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 b802bb6..10b85bb 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
@@ -31,13 +31,12 @@ import org.apache.brooklyn.api.policy.PolicySpec;
import org.apache.brooklyn.api.sensor.EnricherSpec;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
-import org.apache.brooklyn.core.entity.AbstractEntity;
import org.apache.brooklyn.core.entity.lifecycle.PolicyDescriptor;
import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.core.test.entity.TestEntityNoEnrichersImpl;
-import org.apache.brooklyn.test.TestUtils;
+import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.collections.MutableMap;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -135,7 +134,7 @@ public class PolicyRegistrationTest extends BrooklynAppUnitTestSupport {
}
private <T> void assertEqualsEventually(final T actual, final T expected) {
- TestUtils.assertEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
+ Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
@Override public void run() {
assertEquals(actual, expected, "actual="+actual);
}});
@@ -143,7 +142,7 @@ public class PolicyRegistrationTest extends BrooklynAppUnitTestSupport {
// Ignores order of vals in collection, but asserts each same size and same elements
private <T> void assertCollectionEqualsEventually(final Collection<? extends T> actual, final Collection<? extends T> expected) {
- TestUtils.assertEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
+ Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
@Override public void run() {
assertEquals(ImmutableSet.copyOf(actual), ImmutableSet.copyOf(expected), "actual="+actual);
assertEquals(actual.size(), expected.size(), "actual="+actual);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/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 b7c7292..5eb9bbf 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
@@ -99,7 +99,8 @@ public class OsgiVersionMoreEntityTest {
/**
* Test fix for
- * java.lang.NoClassDefFoundError: brooklyn.event.AttributeSensor not found by io.brooklyn.brooklyn-test-osgi-entities [41]
+ * NoClassDefFoundError: org.apache.brooklyn.api.sensor.AttributeSensor not found by ....brooklyn-test-osgi-entities
+ * (see comments in InternalEntityFactory)
*/
@Test
public void testEntityProxy() throws Exception {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy
index 481e233..68d6804 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherDeprecatedTest.groovy
@@ -27,9 +27,9 @@ import org.apache.brooklyn.core.test.entity.TestEntity
import org.apache.brooklyn.enricher.stock.CustomAggregatingEnricher;
import org.apache.brooklyn.core.entity.Entities
import org.apache.brooklyn.entity.group.BasicGroup
+import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.core.location.SimulatedLocation
import org.apache.brooklyn.core.sensor.BasicAttributeSensor
-import org.apache.brooklyn.test.TestUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.testng.annotations.AfterMethod
@@ -271,18 +271,18 @@ class CustomAggregatingEnricherDeprecatedTest {
group.addMember(p1)
p1.setAttribute(intSensor, 1)
- TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
+ Asserts.succeedsEventually(timeout:TIMEOUT_MS) {
assertEquals cae.getAggregate(), 1
}
group.addMember(p2)
p2.setAttribute(intSensor, 2)
- TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
+ Asserts.succeedsEventually(timeout:TIMEOUT_MS) {
assertEquals cae.getAggregate(), 3
}
group.removeMember(p2)
- TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
+ Asserts.succeedsEventually(timeout:TIMEOUT_MS) {
assertEquals cae.getAggregate(), 1
}
} catch (Exception e) {
@@ -315,12 +315,12 @@ class CustomAggregatingEnricherDeprecatedTest {
assertEquals cae.getAggregate(), 1
p2.setAttribute(intSensor, 2)
- TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
+ Asserts.succeedsEventually(timeout:TIMEOUT_MS) {
assertEquals cae.getAggregate(), 3
}
group.removeMember(p2)
- TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
+ Asserts.succeedsEventually(timeout:TIMEOUT_MS) {
assertEquals cae.getAggregate(), 1
}
}
@@ -343,7 +343,7 @@ class CustomAggregatingEnricherDeprecatedTest {
assertEquals cae.getAggregate(), 1
group.addMember(p3)
- TestUtils.assertSucceedsContinually(timeout:SHORT_WAIT_MS) {
+ Asserts.succeedsContinually(timeout:SHORT_WAIT_MS) {
assertEquals cae.getAggregate(), 1
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherDeprecatedTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherDeprecatedTest.groovy b/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherDeprecatedTest.groovy
index d1f264d..b524738 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherDeprecatedTest.groovy
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherDeprecatedTest.groovy
@@ -28,7 +28,7 @@ import org.apache.brooklyn.enricher.stock.SensorTransformingEnricher;
import org.apache.brooklyn.core.entity.Entities
import org.apache.brooklyn.core.location.SimulatedLocation
import org.apache.brooklyn.core.sensor.BasicAttributeSensor
-import org.apache.brooklyn.test.TestUtils
+import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.util.collections.MutableMap
import org.slf4j.Logger
import org.slf4j.LoggerFactory
@@ -73,7 +73,7 @@ public class TransformingEnricherDeprecatedTest {
//ensure previous values get picked up
producer.addEnricher(e1);
- TestUtils.assertEventually(MutableMap.of("timeout", TIMEOUT_MS),
+ Asserts.succeedsEventually(MutableMap.of("timeout", TIMEOUT_MS),
new Callable<Object>() { public Object call() {
Assert.assertEquals(producer.getAttribute(target), (Long)((long)6));
return null;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
index 0e2f73f..44e4fbd 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicClusterTest.java
@@ -437,7 +437,7 @@ public class DynamicClusterTest extends BrooklynAppUnitTestSupport {
return null;
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
- // expect: brooklyn.util.exceptions.PropagatedRuntimeException: Error invoking resize at DynamicClusterImpl{id=I9Ggxfc1}: 1 of 3 parallel child tasks failed: Simulating entity stop failure for test
+ // expect: PropagatedRuntimeException: Error invoking resize at DynamicClusterImpl{id=I9Ggxfc1}: 1 of 3 parallel child tasks failed: Simulating entity stop failure for test
Assert.assertTrue(e.toString().contains("resize"));
return e;
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
index 0c18820..9d1830e 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
@@ -47,9 +47,9 @@ import org.apache.brooklyn.core.test.entity.BlockingEntity;
import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.entity.stock.BasicEntity;
import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.TestUtils;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.repeat.Repeater;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -325,7 +325,7 @@ public class DynamicFabricTest extends BrooklynAppUnitTestSupport {
fabric.start(ImmutableList.of(loc1));
assertEquals(fabric.getChildren().size(), 1);
} catch (Exception e) {
- Throwable unwrapped = TestUtils.unwrapThrowable(e);
+ Throwable unwrapped = Exceptions.getFirstInteresting(e);
if (unwrapped instanceof IllegalStateException && unwrapped.getMessage() != null && (unwrapped.getMessage().contains("is not Startable"))) {
// success
} else {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
index bfa3003..1101b34 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
@@ -170,7 +170,7 @@ public class JcloudsUtil implements JcloudsLocationConfig {
}
/**
- * @deprecated since 0.7; {@see #installJavaAndCurl(OperatingSystem)}
+ * @deprecated since 0.7; see {@link #installJavaAndCurl(OperatingSystem)}
*/
@Deprecated
public static final Statement APT_RUN_SCRIPT = newStatementList(//
@@ -185,7 +185,7 @@ public class JcloudsUtil implements JcloudsLocationConfig {
.toString()));
/**
- * @deprecated since 0.7; {@see #installJavaAndCurl(OperatingSystem)}
+ * @deprecated since 0.7; see {@link #installJavaAndCurl(OperatingSystem)}
*/
@Deprecated
public static final Statement YUM_RUN_SCRIPT = newStatementList(
@@ -198,7 +198,7 @@ public class JcloudsUtil implements JcloudsLocationConfig {
.toString()));
/**
- * @deprecated since 0.7; {@see #installJavaAndCurl(OperatingSystem)}
+ * @deprecated since 0.7; {@link #installJavaAndCurl(OperatingSystem)}
*/
@Deprecated
public static final Statement ZYPPER_RUN_SCRIPT = exec(new StringBuilder()//
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwarderExtension.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwarderExtension.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwarderExtension.java
index deacda4..d101a60 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwarderExtension.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsPortForwarderExtension.java
@@ -19,6 +19,7 @@
package org.apache.brooklyn.location.jclouds.networking;
import org.jclouds.compute.domain.NodeMetadata;
+import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
import org.apache.brooklyn.core.location.access.PortForwardManager;
import org.apache.brooklyn.util.net.Cidr;
@@ -35,7 +36,7 @@ public interface JcloudsPortForwarderExtension {
*
* This should also register the port with the {@link PortForwardManager}, via
* {@code portForwardManager.associate(node.getId(), result, targetPort)} so that
- * subsequent calls to {@link BrooklynAccessUtils#getBrooklynAccessibleAddress(brooklyn.entity.Entity, int)}
+ * subsequent calls to {@link BrooklynAccessUtils#getBrooklynAccessibleAddress(Entity, int)}
* will know about the mapped port.
*/
public HostAndPort openPortForwarding(NodeMetadata node, int targetPort, Optional<Integer> optionalPublicPort, Protocol protocol, Cidr accessingCidr);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/policy/src/main/java/org/apache/brooklyn/policy/enricher/HttpLatencyDetector.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/org/apache/brooklyn/policy/enricher/HttpLatencyDetector.java b/policy/src/main/java/org/apache/brooklyn/policy/enricher/HttpLatencyDetector.java
index 58fda00..1bd9e8f 100644
--- a/policy/src/main/java/org/apache/brooklyn/policy/enricher/HttpLatencyDetector.java
+++ b/policy/src/main/java/org/apache/brooklyn/policy/enricher/HttpLatencyDetector.java
@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.api.sensor.Enricher;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
import org.apache.brooklyn.config.ConfigKey;
@@ -65,7 +66,7 @@ import com.google.common.reflect.TypeToken;
* and has limited support for https.
*/
//@Catalog(name="HTTP Latency Detector", description="An Enricher which computes latency in accessing a URL, normally by periodically polling that URL")
-public class HttpLatencyDetector extends AbstractEnricher {
+public class HttpLatencyDetector extends AbstractEnricher implements Enricher {
private static final Logger log = LoggerFactory.getLogger(HttpLatencyDetector.class);
@@ -304,7 +305,7 @@ public class HttpLatencyDetector extends AbstractEnricher {
}
/** returns the detector. note that callers should then add this to the entity,
- * typically using {@link Entity#addEnricher(brooklyn.policy.Enricher)} */
+ * typically using {@link Entity#addEnricher(Enricher)} */
public HttpLatencyDetector build() {
return new HttpLatencyDetector(MutableMap.builder()
.putIfNotNull(PERIOD, period)
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxFeedTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxFeedTest.java b/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxFeedTest.java
index 3975e68..6b78930 100644
--- a/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxFeedTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxFeedTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.brooklyn.feed.jmx;
-import static org.apache.brooklyn.test.TestUtils.executeUntilSucceeds;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -64,22 +63,14 @@ import org.apache.brooklyn.entity.java.UsesJmx;
import org.apache.brooklyn.entity.java.UsesJmx.JmxAgentModes;
import org.apache.brooklyn.entity.software.base.test.jmx.GeneralisedDynamicMBean;
import org.apache.brooklyn.entity.software.base.test.jmx.JmxService;
-import org.apache.brooklyn.feed.jmx.JmxAttributePollConfig;
-import org.apache.brooklyn.feed.jmx.JmxFeed;
-import org.apache.brooklyn.feed.jmx.JmxHelper;
-import org.apache.brooklyn.feed.jmx.JmxNotificationFilters;
-import org.apache.brooklyn.feed.jmx.JmxNotificationSubscriptionConfig;
-import org.apache.brooklyn.feed.jmx.JmxOperationPollConfig;
-import org.apache.brooklyn.feed.jmx.JmxValueFunctions;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.TestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -236,7 +227,7 @@ public class JmxFeedTest {
.operationName(opName))
.build();
- TestUtils.executeUntilSucceeds(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
public void run() {
assertTrue(invocationCount.get() > 0, "invocationCount="+invocationCount);
assertEquals(entity.getAttribute(intAttribute), (Integer)opReturnVal);
@@ -413,7 +404,7 @@ public class JmxFeedTest {
}
private <T> void assertSensorEventually(final AttributeSensor<T> sensor, final T expectedVal, long timeout) {
- executeUntilSucceeds(ImmutableMap.of("timeout", timeout), new Callable<Void>() {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", timeout), new Callable<Void>() {
public Void call() {
assertEquals(entity.getAttribute(sensor), expectedVal);
return null;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxHelperTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxHelperTest.java b/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxHelperTest.java
index 3470166..a78f49b 100644
--- a/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxHelperTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/feed/jmx/JmxHelperTest.java
@@ -36,6 +36,7 @@ import javax.management.StandardEmitterMBean;
import org.apache.brooklyn.entity.software.base.test.jmx.GeneralisedDynamicMBean;
import org.apache.brooklyn.entity.software.base.test.jmx.JmxService;
import org.apache.brooklyn.feed.jmx.JmxHelper;
+import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.test.TestUtils;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -249,7 +250,7 @@ public class JmxHelperTest {
final Notification notif = sendNotification(mbean, "one", sequence++, "abc");
- TestUtils.executeUntilSucceeds(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
public void run() {
assertEquals(received.size(), 1);
assertNotificationsEqual(received.get(0), notif);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
index b486038..3d64897 100644
--- a/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
+++ b/usage/camp/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampCatalogUtils.java
@@ -122,7 +122,7 @@ public class CampCatalogUtils {
}
private static PolicySpec<?> createPolicySpec(DeploymentPlan plan, BrooklynClassLoadingContext loader, Set<String> encounteredCatalogTypes) {
- //Would ideally re-use io.brooklyn.camp.brooklyn.spi.creation.BrooklynEntityDecorationResolver.PolicySpecResolver
+ //Would ideally re-use the PolicySpecResolver
//but it is CAMP specific and there is no easy way to get hold of it.
Object policies = checkNotNull(plan.getCustomAttributes().get(BasicBrooklynCatalog.POLICIES_KEY), "policy config");
if (!(policies instanceof Iterable<?>)) {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/cli/src/main/resources/brooklyn/default.catalog.bom
----------------------------------------------------------------------
diff --git a/usage/cli/src/main/resources/brooklyn/default.catalog.bom b/usage/cli/src/main/resources/brooklyn/default.catalog.bom
index 92ed645..54e46fd 100644
--- a/usage/cli/src/main/resources/brooklyn/default.catalog.bom
+++ b/usage/cli/src/main/resources/brooklyn/default.catalog.bom
@@ -142,12 +142,12 @@ brooklyn.catalog:
brooklyn.enrichers:
# publish the URL as a sensor; the GUI will pick this up (main.uri)
- - type: org.apache.brooklyn.sensor.enricher.Transformer
+ - type: org.apache.brooklyn.enricher.stock.Transformer
brooklyn.config:
uniqueTag: url-generator
enricher.sourceSensor: host.subnet.hostname
# use the definition from Attributes class, as it has a RendererHint so GUI makes it a link
- enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.entity.core.Attributes", "main.uri")
+ enricher.targetSensor: $brooklyn:sensor("org.apache.brooklyn.core.entity.Attributes", "main.uri")
enricher.targetValue:
$brooklyn:formatString:
- "http://%s:%s/"
@@ -246,7 +246,7 @@ brooklyn.catalog:
brooklyn.initializers:
# make a simple request-count sensor, by counting the number of 200 responses in output.txt
- - type: org.apache.brooklyn.sensor.ssh.SshCommandSensor
+ - type: org.apache.brooklyn.core.sensor.ssh.SshCommandSensor
brooklyn.config:
name: reqs.count
targetType: int
@@ -261,13 +261,13 @@ brooklyn.catalog:
brooklyn.enrichers:
# derive reqs.per_sec from reqs.count
- - type: org.apache.brooklyn.sensor.enricher.YamlTimeWeightedDeltaEnricher
+ - type: org.apache.brooklyn.enricher.stock.YamlTimeWeightedDeltaEnricher
brooklyn.config:
enricher.sourceSensor: reqs.count
enricher.targetSensor: reqs.per_sec
enricher.delta.period: 1s
# and take an average over 30s for reqs.per_sec into reqs.per_sec.windowed_30s
- - type: org.apache.brooklyn.sensor.enricher.YamlRollingTimeWindowMeanEnricher
+ - type: org.apache.brooklyn.enricher.stock.YamlRollingTimeWindowMeanEnricher
brooklyn.config:
enricher.sourceSensor: reqs.per_sec
enricher.targetSensor: reqs.per_sec.windowed_30s
@@ -286,17 +286,17 @@ brooklyn.catalog:
# back at the cluster, create a total per-sec and some per-node average
brooklyn.enrichers:
- - type: org.apache.brooklyn.sensor.enricher.Aggregator
+ - type: org.apache.brooklyn.enricher.stock.Aggregator
brooklyn.config:
enricher.sourceSensor: reqs.per_sec
enricher.targetSensor: reqs.per_sec
transformation: sum
- - type: org.apache.brooklyn.sensor.enricher.Aggregator
+ - type: org.apache.brooklyn.enricher.stock.Aggregator
brooklyn.config:
enricher.sourceSensor: reqs.per_sec
enricher.targetSensor: reqs.per_sec.per_node
transformation: average
- - type: org.apache.brooklyn.sensor.enricher.Aggregator
+ - type: org.apache.brooklyn.enricher.stock.Aggregator
brooklyn.config:
enricher.sourceSensor: reqs.per_sec.windowed_30s
enricher.targetSensor: reqs.per_sec.windowed_30s.per_node
@@ -335,13 +335,13 @@ brooklyn.catalog:
brooklyn.enrichers:
# publish a few useful info sensors and KPI's to the root of the app
- - type: org.apache.brooklyn.sensor.enricher.Propagator
+ - type: org.apache.brooklyn.enricher.stock.Propagator
brooklyn.config:
uniqueTag: propagate-load-balancer-url
producer: $brooklyn:entity("load-bal")
propagating:
- main.uri
- - type: org.apache.brooklyn.sensor.enricher.Propagator
+ - type: org.apache.brooklyn.enricher.stock.Propagator
brooklyn.config:
uniqueTag: propagate-reqs-per-sec
producer: $brooklyn:entity("my-web-cluster")
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindToCloudObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindToCloudObjectStoreTest.java b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindToCloudObjectStoreTest.java
index dba30ac..24db1c7 100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindToCloudObjectStoreTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindToCloudObjectStoreTest.java
@@ -46,9 +46,9 @@ public class BrooklynLauncherRebindToCloudObjectStoreTest extends BrooklynLaunch
// apps=[Application[mDNfOA7w]] expected [true] but found [false]
// Should it really delete everything in the bucket?! Only if we can back up first!
- // FIXME brooklyn.util.exceptions.FatalRuntimeException: Error rebinding to persisted state: Writes not allowed in brooklyn.entity.rebind.persister.BrooklynMementoPersisterToObjectStore@7d2f7563
- // at brooklyn.launcher.BrooklynLauncher.persistState(BrooklynLauncher.java:502)
- // at brooklyn.launcher.BrooklynLauncherRebindToCloudObjectStoreTest.testCopyPersistedState(BrooklynLauncherRebindToCloudObjectStoreTest.java:144)
+ // FIXME FatalRuntimeException: Error rebinding to persisted state: Writes not allowed in brooklyn.entity.rebind.persister.BrooklynMementoPersisterToObjectStore@7d2f7563
+ // at BrooklynLauncher.persistState(BrooklynLauncher.java:502)
+ // at BrooklynLauncherRebindToCloudObjectStoreTest.testCopyPersistedState(BrooklynLauncherRebindToCloudObjectStoreTest.java:144)
// Presumably a previous run wasn't tearing down properly, so it joined as a standby rather than being master?!
{ persistenceLocationSpec = BlobStoreTest.PERSIST_TO_OBJECT_STORE_FOR_TEST_SPEC; }
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/launcher/src/test/resources/mongo-sharded.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/mongo-sharded.yaml b/usage/launcher/src/test/resources/mongo-sharded.yaml
index b9b3d9e..1a7a0bc 100644
--- a/usage/launcher/src/test/resources/mongo-sharded.yaml
+++ b/usage/launcher/src/test/resources/mongo-sharded.yaml
@@ -36,7 +36,7 @@ services:
$brooklyn:entitySpec:
type: org.apache.brooklyn.entity.nosql.mongodb.sharding.CoLocatedMongoDBRouter
brooklyn.enrichers:
- - type: brooklyn.enricher.basic.Propagator
+ - type: org.apache.brooklyn.enricher.stock.Propagator
brooklyn.config:
enricher.propagating.sensorMapping:
$brooklyn:sensor("org.apache.brooklyn.entity.webapp.jboss.JBoss7Server", "http.port"): $brooklyn:sensor("org.apache.brooklyn.entity.webapp.jboss.JBoss7Server", "http.port")
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java b/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
index 43c95cc..a04d074 100644
--- a/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
+++ b/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/ApplicationSpecTest.java
@@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableSet;
public class ApplicationSpecTest {
- final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "brooklyn.entity.java.VanillaJavaApp",
+ final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "org.apache.brooklyn.entity.java.VanillaJavaApp",
ImmutableMap.<String, String>of(
"initialSize", "1",
"creationScriptUrl", "http://my.brooklyn.io/storage/foo.sql"));
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySpecTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySpecTest.java b/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySpecTest.java
index 74159d1..a61cfd5 100644
--- a/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySpecTest.java
+++ b/usage/rest-api/src/test/java/org/apache/brooklyn/rest/domain/EntitySpecTest.java
@@ -29,7 +29,7 @@ import org.testng.annotations.Test;
public class EntitySpecTest {
- final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "brooklyn.entity.java.VanillaJavaApp");
+ final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "org.apache.brooklyn.entity.java.VanillaJavaApp");
@Test
public void testSerializeToJSON() throws IOException {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/resources/fixtures/application-list.json
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/resources/fixtures/application-list.json b/usage/rest-api/src/test/resources/fixtures/application-list.json
index f9f4b05..029cf68 100644
--- a/usage/rest-api/src/test/resources/fixtures/application-list.json
+++ b/usage/rest-api/src/test/resources/fixtures/application-list.json
@@ -25,7 +25,7 @@
"entities":[
{
"name":"Vanilla Java App",
- "type":"brooklyn.entity.java.VanillaJavaApp",
+ "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
"config":{
"initialSize":"1",
"creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/resources/fixtures/application-spec.json
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/resources/fixtures/application-spec.json b/usage/rest-api/src/test/resources/fixtures/application-spec.json
index 3605791..9f042c6 100644
--- a/usage/rest-api/src/test/resources/fixtures/application-spec.json
+++ b/usage/rest-api/src/test/resources/fixtures/application-spec.json
@@ -3,7 +3,7 @@
"entities":[
{
"name":"Vanilla Java App",
- "type":"brooklyn.entity.java.VanillaJavaApp",
+ "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
"config":{
"initialSize":"1",
"creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
@@ -13,4 +13,4 @@
"locations":[
"/v1/locations/1"
]
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/resources/fixtures/application.json
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/resources/fixtures/application.json b/usage/rest-api/src/test/resources/fixtures/application.json
index d98e837..cd6a21a 100644
--- a/usage/rest-api/src/test/resources/fixtures/application.json
+++ b/usage/rest-api/src/test/resources/fixtures/application.json
@@ -5,7 +5,7 @@
"entities":[
{
"name":"Vanilla Java App",
- "type":"brooklyn.entity.java.VanillaJavaApp",
+ "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
"config":{
"initialSize":"1",
"creationScriptUrl":"http://my.brooklyn.io/storage/foo.sql"
@@ -19,4 +19,4 @@
"self":"/v1/applications/myapp",
"entities":"fixtures/entity-summary-list.json"
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/resources/fixtures/entity-only-type.json
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/resources/fixtures/entity-only-type.json b/usage/rest-api/src/test/resources/fixtures/entity-only-type.json
index 949d373..e932ab1 100644
--- a/usage/rest-api/src/test/resources/fixtures/entity-only-type.json
+++ b/usage/rest-api/src/test/resources/fixtures/entity-only-type.json
@@ -1,3 +1,3 @@
{
- "type":"brooklyn.entity.java.VanillaJavaApp"
-}
\ No newline at end of file
+ "type":"org.apache.brooklyn.entity.java.VanillaJavaApp"
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-api/src/test/resources/fixtures/entity.json
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/resources/fixtures/entity.json b/usage/rest-api/src/test/resources/fixtures/entity.json
index cdadd2c..dac0509 100644
--- a/usage/rest-api/src/test/resources/fixtures/entity.json
+++ b/usage/rest-api/src/test/resources/fixtures/entity.json
@@ -1,7 +1,7 @@
[
{
"name":"Vanilla Java App",
- "type":"brooklyn.entity.java.VanillaJavaApp",
+ "type":"org.apache.brooklyn.entity.java.VanillaJavaApp",
"config":{}
}
]
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
index f2073b4..b09d829 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
@@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
public class ApplicationTest {
- final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "brooklyn.entity.java.VanillaJavaApp",
+ final EntitySpec entitySpec = new EntitySpec("Vanilla Java App", "org.apache.brooklyn.entity.java.VanillaJavaApp",
ImmutableMap.<String, String>of(
"initialSize", "1",
"creationScriptUrl", "http://my.brooklyn.io/storage/foo.sql"));
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6e0a847e/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.groovy
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.groovy b/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.groovy
deleted file mode 100644
index 33ed9e4..0000000
--- a/usage/test-support/src/main/java/org/apache/brooklyn/test/TestUtils.groovy
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.test
-
-import static org.testng.Assert.*
-import groovy.time.TimeDuration
-
-import java.util.concurrent.Callable
-import java.util.concurrent.ExecutionException
-import java.util.concurrent.Executors
-
-import org.apache.brooklyn.api.entity.Entity
-import org.apache.brooklyn.util.time.Duration
-import org.codehaus.groovy.runtime.InvokerInvocationException
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-import com.google.common.base.Predicate
-import com.google.common.base.Supplier
-import com.google.common.collect.Iterables
-
-/**
- * Helper functions for tests of Tomcat, JBoss and others.
- *
- * Note that methods will migrate from here to {@link Asserts} in future releases.
- */
-public class TestUtils {
- private static final Logger log = LoggerFactory.getLogger(TestUtils.class)
-
- private TestUtils() { }
-
- /**
- * True if two attempts to connect to the port succeed.
- *
- * @deprecated since 0.5; use {@link brooklyn.util.NetworkUtils#isPortAvailable(int)}
- */
- @Deprecated
- public static boolean isPortInUse(int port, long retryAfterMillis=0) {
- try {
- def s = new Socket("localhost", port)
- s.close()
- if (retryAfterMillis>0) {
- log.debug "port {} still open, waiting 1s for it to really close", port
- //give it 1s to close
- Thread.sleep retryAfterMillis
- s = new Socket("localhost", port)
- s.close()
- }
- log.debug "port {} still open (conclusive)", port
- return true
- } catch (ConnectException e) {
- return false
- }
- }
-
- /**
- * Connects to the given HTTP URL and asserts that the response had status code 200.
- * @deprecated Use HttpTestUtils.getHttpStatusCode(url) == 200
- */
- @Deprecated
- public static boolean urlRespondsWithStatusCode200(String url) {
- int status = HttpTestUtils.getHttpStatusCode(url);
- log.debug "connection to {} gives {}", url, status
- if (status == 404)
- throw new Exception("Connection to $url gave 404");
- return status == 200
- }
-
- /**
- * Connects to the given HTTP URL and asserts that the response had status code 200.
- * @deprecated Use HttpTestUtils.getHttpStatusCode(url)
- */
- @Deprecated
- public static int urlRespondsStatusCode(String url) {
- return HttpTestUtils.getHttpStatusCode(url);
- }
-
- /**
- * Connects to the given url and returns the connection.
- * @deprecated Use HttpTestUtils.connectToUrl(url)
- */
- @Deprecated
- public static URLConnection connectToURL(String url) {
- return HttpTestUtils.connectToUrl(url);
- }
-
- // calling groovy from java doesn't cope with generics here; stripping them from here :-(
- // <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate)
- /**
- * @deprecated since 0.5; use {@link Asserts#eventually(Map, Supplier, Predicate)}
- */
- @Deprecated
- public static void assertEventually(Map flags=[:], Supplier supplier, Predicate predicate) {
- Asserts.eventually(flags, supplier, predicate);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#eventually(Map, Supplier, Predicate, String)}
- */
- @Deprecated
- public static <T> void assertEventually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
- Asserts.eventually(flags, supplier, predicate, errMsg);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(java.util.Map, Callable)}
- */
- @Deprecated
- public static void assertEventually(Map flags=[:], Callable c) {
- executeUntilSucceeds(flags, c);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Runnable)}
- */
- @Deprecated
- public static void assertEventually(Map flags=[:], Runnable c) {
- executeUntilSucceeds(flags, c);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}
- */
- @Deprecated
- public static void executeUntilSucceeds(Map flags=[:], Closure c) {
- Asserts.succeedsEventually(flags, c);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}
- */
- @Deprecated
- public static void executeUntilSucceeds(Map flags=[:], Callable c) {
- Asserts.succeedsEventually(flags, c);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Runnable)}
- */
- @Deprecated
- public static void executeUntilSucceeds(Map flags=[:], Runnable r) {
- if (r in Callable)
- executeUntilSucceedsWithFinallyBlock(flags, {return ((Callable)r).call();}, { })
- else if (r in Closure) // Closure check probably not necessary, just was trying to fix a server build which had a screwy problem
- executeUntilSucceedsWithFinallyBlock(flags, {return ((Closure)r).call();}, { })
- else
- executeUntilSucceedsWithFinallyBlock(flags, {r.run(); return true}, { })
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
- */
- @Deprecated
- public static void executeUntilSucceedsElseShutdown(Map flags=[:], Entity entity, Closure c) {
- try {
- executeUntilSucceedsWithFinallyBlock(flags, c) { }
- } catch (Throwable t) {
- entity.stop()
- throw t
- }
- }
-
- /**
- * convenience for entities to ensure they shutdown afterwards.
- *
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
- */
- @Deprecated
- public static void executeUntilSucceedsWithShutdown(Map flags=[:], Entity entity, Closure c) {
- executeUntilSucceedsWithFinallyBlock(flags, c) { entity.stop() }
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
- */
- @Deprecated
- public static void executeUntilSucceedsWithFinallyBlock(Map flags=[:], Closure c, Closure finallyBlock={}) {
- executeUntilSucceedsWithFinallyBlockInternal(flags, c, finallyBlock)
- }
-
- /**
- * Convenience method for cases where we need to test until something is true.
- *
- * The runnable will be invoked periodically until it succesfully concludes.
- * Additionally, a finally block can be supplied.
- * <p>
- * The following flags are supported:
- * <ul>
- * <li>abortOnError (boolean, default true)
- * <li>abortOnException - (boolean, default false)
- * <li>useGroovyTruth - (defaults to false; any result code apart from 'false' will be treated as success including null; ignored for Runnables which aren't Callables)
- * <li>timeout - (a Duration or an integer in millis, defaults to 30*SECONDS)
- * <li>period - (a Duration or an integer in millis, for fixed retry time; if not set, defaults to exponentially increasing from 1 to 500ms)
- * <li>minPeriod - (a Duration or an integer in millis; only used if period not explicitly set; the minimum period when exponentially increasing; defaults to 1ms)
- * <li>maxPeriod - (a Duration or an integer in millis; only used if period not explicitly set; the maximum period when exponentially increasing; defaults to 500ms)
- * <li>maxAttempts - (integer, Integer.MAX_VALUE)
- * </ul>
- *
- * @param flags, accepts the flags listed above
- * @param r
- * @param finallyBlock
- *
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
- */
- @Deprecated
- public static void executeUntilSucceedsWithFinallyBlock(Map flags=[:], Callable<?> c, Closure finallyBlock={}) {
- executeUntilSucceedsWithFinallyBlockInternal(flags, c, finallyBlock);
- }
-
- /**
- * the "real" implementation, renamed to allow multiple entry points (depending whether closure cast to callable)
- *
- * @deprecated since 0.5; use {@link Asserts#succeedsEventually(Map, Callable)}, and tear-down with {@link AfterMethod}.
- */
- @Deprecated
- private static void executeUntilSucceedsWithFinallyBlockInternal(Map flags=[:], Callable<?> c, Closure finallyBlock={}) {
-// log.trace "abortOnError = {}", flags.abortOnError
- boolean abortOnException = flags.abortOnException ?: false
- boolean abortOnError = flags.abortOnError ?: false
- boolean useGroovyTruth = flags.useGroovyTruth ?: false
- boolean logException = flags.logException ?: true
-
- // To speed up tests, default is for the period to start small and increase...
- Duration duration = Duration.of(flags.timeout) ?: Duration.THIRTY_SECONDS;
- Duration fixedPeriod = Duration.of(flags.period) ?: null
- Duration minPeriod = fixedPeriod ?: Duration.of(flags.minPeriod) ?: Duration.millis(1)
- Duration maxPeriod = fixedPeriod ?: Duration.of(flags.maxPeriod) ?: Duration.millis(500)
- int maxAttempts = flags.maxAttempts ?: Integer.MAX_VALUE;
- int attempt = 0;
- long startTime = System.currentTimeMillis();
- try {
- Throwable lastException = null;
- Object result;
- long lastAttemptTime = 0;
- long expireTime = startTime+duration.toMilliseconds();
- long sleepTimeBetweenAttempts = minPeriod.toMilliseconds();
-
- while (attempt<maxAttempts && lastAttemptTime<expireTime) {
- try {
- attempt++
- lastAttemptTime = System.currentTimeMillis()
- result = c.call()
- log.trace "Attempt {} after {} ms: {}", attempt, System.currentTimeMillis() - startTime, result
- if (useGroovyTruth) {
- if (result) return;
- } else if (result != false) {
- if (result instanceof BooleanWithMessage)
- log.warn "Test returned an instance of BooleanWithMessage but useGroovyTruth is not set! " +
- "The result of this probably isn't what you intended."
- return;
- }
- lastException = null
- } catch(Throwable e) {
- lastException = e
- log.trace "Attempt {} after {} ms: {}", attempt, System.currentTimeMillis() - startTime, e.message
- if (abortOnException) throw e
- if (abortOnError && e in Error) throw e
- }
- long sleepTime = Math.min(sleepTimeBetweenAttempts, expireTime-System.currentTimeMillis())
- if (sleepTime > 0) Thread.sleep(sleepTime)
- sleepTimeBetweenAttempts = Math.min(sleepTimeBetweenAttempts*2, maxPeriod.toMilliseconds())
- }
-
- log.debug "TestUtils.executeUntilSucceedsWithFinallyBlockInternal exceeded max attempts or timeout - {} attempts lasting {} ms", attempt, System.currentTimeMillis()-startTime
- if (lastException != null)
- throw lastException
- fail "invalid result: $result"
- } catch (Throwable t) {
- if (logException) log.info("failed execute-until-succeeds, "+attempt+" attempts, "+
- (System.currentTimeMillis()-startTime)+"ms elapsed "+
- "(rethrowing): "+t);
- throw t
- } finally {
- finallyBlock.call()
- }
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsContinually(Map, Runnable)}
- */
- @Deprecated
- public static <T> void assertSucceedsContinually(Map flags=[:], Runnable job) {
- assertSucceedsContinually(flags, Executors.callable(job));
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#succeedsContinually(Map, Callable)}
- */
- @Deprecated
- public static void assertSucceedsContinually(Map flags=[:], Callable<?> job) {
- Duration duration = Duration.of(flags.timeout) ?: Duration.ONE_SECOND
- Duration period = Duration.of(flags.period) ?: Duration.millis(10)
- long periodMs = period.toMilliseconds()
- long startTime = System.currentTimeMillis()
- long expireTime = startTime+duration.toMilliseconds()
-
- boolean first = true;
- while (first || System.currentTimeMillis() <= expireTime) {
- job.call();
- if (periodMs > 0) sleep(periodMs);
- first = false;
- }
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate)}
- */
- @Deprecated
- // FIXME When calling from java, the generics declared in groovy messing things up!
- public static void assertContinuallyFromJava(Map flags=[:], Supplier<?> supplier, Predicate<?> predicate) {
- Asserts.continually(flags, supplier, predicate);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate)}
- */
- @Deprecated
- public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate) {
- Asserts.continually(flags, supplier, predicate, (String)null);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate, String)}
- */
- @Deprecated
- public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg, long durationMs) {
- flags.put("duration", Duration.millis(durationMs));
- Asserts.continually(flags, supplier, predicate, errMsg);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#continually(Map, Supplier, Predicate, String)}
- */
- @Deprecated
- public static <T> void assertContinually(Map flags=[:], Supplier<? extends T> supplier, Predicate<T> predicate, String errMsg) {
- Asserts.continually(flags, supplier, predicate, errMsg);
- }
-
- public static class BooleanWithMessage {
- boolean value; String message;
- public BooleanWithMessage(boolean value, String message) {
- this.value = value; this.message = message;
- }
- public boolean asBoolean() {
- return value
- }
- public String toString() {
- return message
- }
- }
-
- /**
- * @deprecated since 0.5; use {@link brooklyn.util.ResourceUtils}
- */
- @Deprecated
- public static File getResource(String path, ClassLoader loader) {
- URL resource = loader.getResource(path)
- if (resource==null)
- throw new IllegalArgumentException("cannot find required entity '"+path+"'");
-
- return new File(resource.path)
- }
-
- /**
- * @deprecated since 0.5; use long and {@link TimeUnit}
- */
- @Deprecated
- public static TimeDuration toTimeDuration(Object duration) {
- return toTimeDuration(duration, null);
- }
-
- /**
- * @deprecated since 0.5; use long and {@link TimeUnit}
- */
- @Deprecated
- public static TimeDuration toTimeDuration(Object duration, TimeDuration defaultVal) {
- if (duration == null) {
- return defaultVal;
- } else if (duration instanceof TimeDuration) {
- return (TimeDuration) duration
- } else if (duration instanceof Number) {
- return new TimeDuration(0,0,0,(int)duration)
- // TODO would be nice to have this, but we need to sort out utils / test-utils dependency
-// } else if (duration instanceof String) {
-// return Time.parseTimeString((String)duration);
- } else {
- throw new IllegalArgumentException("Cannot convert $duration of type ${duration.class.name} to a TimeDuration")
- }
- }
-
- public static Throwable unwrapThrowable(Throwable t) {
- if (t.getCause() == null) {
- return t;
- } else if (t instanceof ExecutionException) {
- return unwrapThrowable(t.getCause())
- } else if (t instanceof InvokerInvocationException) {
- return unwrapThrowable(t.getCause())
- } else {
- return t
- }
- }
-
- // causes compilation errors??
-// /**
-// * @deprecated since 0.5; use {@link EntityTestUtils#assertAttributeEqualsEventually(Entity, AttributeSensor, Object)}
-// */
-// @Deprecated
-// public static <T> void assertAttributeEventually(Entity entity, AttributeSensor<T> attribute, T expected) {
-// executeUntilSucceeds() {
-// assertEquals(entity.getAttribute(attribute), expected);
-// }
-// }
-//
-// /**
-// * @deprecated since 0.5; use {@link EntityTestUtils#assertAttributeEqualsContinually(Entity, AttributeSensor, Object)}
-// */
-// @Deprecated
-// public static <T> void assertAttributeContinually(Entity entity, AttributeSensor<T> attribute, T expected) {
-// assertSucceedsContinually() {
-// assertEquals(entity.getAttribute(attribute), expected);
-// }
-// }
-
- /**
- * @deprecated since 0.5; use {@link HttpTestUtils#assertHttpStatusCodeEquals(String, int)}
- */
- @Deprecated
- public static void assertUrlStatusCodeEventually(final String url, final int expected) {
- executeUntilSucceeds() {
- assertEquals(urlRespondsStatusCode(url), expected);
- }
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#assertFails(Runnable)}
- */
- @Deprecated
- public static void assertFails(Runnable c) {
- assertFailsWith(c, (Predicate)null);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Closure)}
- */
- @Deprecated
- public static void assertFailsWith(Runnable c, Closure exceptionChecker) {
- assertFailsWith(c, exceptionChecker as Predicate);
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Runnable, Class, Class...)}
- */
- @Deprecated
- public static void assertFailsWith(Runnable c, final Class<? extends Throwable> validException, final Class<? extends Throwable> ...otherValidExceptions) {
- assertFailsWith(c, { e ->
- if (validException.isInstance(e)) return true;
- if (otherValidExceptions.find {it.isInstance(e)}) return true;
- List expectedTypes = [validException];
- expectedTypes.addAll(Arrays.asList(otherValidExceptions));
- fail("Test threw exception of unexpected type "+e.getClass()+"; expecting "+expectedTypes);
- });
- }
-
- /**
- * @deprecated since 0.5; use {@link Asserts#assertFailsWith(Runnable, Predicate)}
- */
- @Deprecated
- public static void assertFailsWith(Runnable c, Predicate<Throwable> exceptionChecker) {
- boolean failed = false;
- try {
- c.run();
- } catch (Throwable e) {
- failed = true;
- if (exceptionChecker!=null) {
- if (!exceptionChecker.apply(e)) {
- fail("Test threw invalid exception: "+e);
- }
- }
- log.debug("Test for exception successful ("+e+")");
- }
- if (!failed) fail("Test code should have thrown exception but did not");
- }
-
- public static void assertSetsEqual(Collection c1, Collection c2) {
- Set s = new LinkedHashSet();
- s.addAll(c1); s.removeAll(c2);
- if (!s.isEmpty()) fail("First argument contains additional contents: "+s);
- s.clear(); s.addAll(c2); s.removeAll(c1);
- if (!s.isEmpty()) fail("Second argument contains additional contents: "+s);
- }
-
- /**
- * @deprecated since 0.5; use {@code assertFalse(Iterables.isEmpty(c))}
- */
- @Deprecated
- public static <T> void assertNonEmpty(Iterable<T> c) {
- if (c.iterator().hasNext()) return;
- fail("Expected non-empty set");
- }
-
- /**
- * @deprecated since 0.5; use {@code assertEquals(Iterables.size(c), expectedSize)}
- */
- @Deprecated
- public static <T> void assertSize(Iterable<T> c, int expectedSize) {
- int actualSize = Iterables.size(c);
- if (actualSize==expectedSize) return;
- fail("Expected collection of size "+expectedSize+" but got size "+actualSize+": "+c);
- }
-
- /**
- * @deprecated since 0.7.0; use {@link Asserts#assertThat(Object, Predicate)} with {@link StringFunctions})}
- */
- @Deprecated
- public static void assertStringContainsLiteral(String string, String substring) {
- if (string==null) fail("String is null");
- if (substring==null) fail("Substring is null");
- if (string.indexOf(substring)>=0) return;
- fail("String '"+string+"' does not contain expected pattern '"+substring+"'");
- }
-
-}