This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 915f079ff6f203e8cbb6e177f5494d75c8c49463
Author: Alex Heneveld <[email protected]>
AuthorDate: Thu Jun 1 09:44:45 2023 +0100

    allow blueprint viewer tests to indicate they don't want to rebind
---
 .../brooklyn/core/internal/BrooklynPropertiesImpl.java  |  2 +-
 .../launcher/blueprints/AbstractBlueprintTest.java      | 17 ++++++++++++-----
 ...printTest.java => SimpleBlueprintNonRebindTest.java} | 10 ++++------
 .../launcher/blueprints/SimpleBlueprintTest.java        |  2 +-
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
index b7b7483b31..026c8c0fc0 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynPropertiesImpl.java
@@ -252,7 +252,7 @@ public class BrooklynPropertiesImpl implements 
BrooklynProperties {
     @Override
     @SuppressWarnings("unchecked")
     public BrooklynPropertiesImpl addFrom(Map map) {
-        putAll(Maps.transformValues(map, StringFunctions.trim()));
+        putAll(Maps.transformValues(map, x -> x instanceof String ? 
((String)x).trim() : x));
         return this;
     }
 
diff --git 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
index c5bf51cf04..619645583a 100644
--- 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
+++ 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
@@ -73,6 +73,7 @@ import org.testng.annotations.BeforeMethod;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 
+/** Ancestor for blueprint tests which can easily allow rebind (default true) 
and a REST API attached (default false). */
 public abstract class AbstractBlueprintTest {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(AbstractBlueprintTest.class);
@@ -92,7 +93,9 @@ public abstract class AbstractBlueprintTest {
         // required for REST access - otherwise it is viewed as not yet ready
         
((RebindManagerImpl)mgmt.getRebindManager()).setAwaitingInitialRebind(false);
 
-        LOG.info("Test "+getClass()+" persisting to "+mementoDir);
+        if (isRebindEnabled()) {
+            LOG.info("Test " + getClass() + " persisting to " + mementoDir);
+        }
 
         startViewer(true);
 
@@ -212,9 +215,11 @@ public abstract class AbstractBlueprintTest {
 
     protected Application runTest(Application app, Consumer<Application> 
check) throws Exception {
         check.accept(app);
-        
-        Application newApp = rebind();
-        check.accept(newApp);
+
+        if (isRebindEnabled()) {
+            Application newApp = rebind();
+            check.accept(newApp);
+        }
 
         return app;
     }
@@ -334,7 +339,9 @@ public abstract class AbstractBlueprintTest {
         if (isRebindEnabled()) {
             return 
decorateManagementContext(createBuilderForRebindingManagementContext().buildStarted());
         } else {
-            return 
decorateManagementContext(LocalManagementContextForTests.newInstance());
+            LocalManagementContext mgmt = 
LocalManagementContextForTests.newInstance();
+            mgmt.getHighAvailabilityManager().disabled(false);
+            return decorateManagementContext(mgmt);
         }
     }
 
diff --git 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintNonRebindTest.java
similarity index 85%
copy from 
launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
copy to 
launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintNonRebindTest.java
index b1d3f75187..f234cfaa7b 100644
--- 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
+++ 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintNonRebindTest.java
@@ -23,21 +23,19 @@ import org.apache.brooklyn.core.entity.Dumper;
 import org.apache.brooklyn.entity.stock.BasicEntity;
 import org.testng.annotations.Test;
 
-public class SimpleBlueprintTest extends AbstractBlueprintTest {
+public class SimpleBlueprintNonRebindTest extends AbstractBlueprintTest {
 
     @Override
     protected boolean isViewerEnabled() {
         return true;
     }
 
-    @Override
-    protected boolean isUsingNewViewerForRebind() {
-        return true;
+    protected boolean isRebindEnabled() {
+        return false;
     }
 
-    // only Live because it starts a server
     @Test(groups={"Live"})
-    public void testBasicEntity() throws Exception {
+    public void testBasicEntityNonRebind() throws Exception {
         Application app = runTestOnBlueprint("services: [ { type: " + 
BasicEntity.class.getName() + " } ]");
 
         // stick a breakpoint on the following line (make sure it is 
thread-only, not all-threads!)
diff --git 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
index b1d3f75187..7adcc91d5b 100644
--- 
a/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
+++ 
b/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/SimpleBlueprintTest.java
@@ -23,6 +23,7 @@ import org.apache.brooklyn.core.entity.Dumper;
 import org.apache.brooklyn.entity.stock.BasicEntity;
 import org.testng.annotations.Test;
 
+/** This does rebind. See SimpleBlueprintNonRebindTest for an example with 
rebind disabled. */
 public class SimpleBlueprintTest extends AbstractBlueprintTest {
 
     @Override
@@ -35,7 +36,6 @@ public class SimpleBlueprintTest extends 
AbstractBlueprintTest {
         return true;
     }
 
-    // only Live because it starts a server
     @Test(groups={"Live"})
     public void testBasicEntity() throws Exception {
         Application app = runTestOnBlueprint("services: [ { type: " + 
BasicEntity.class.getName() + " } ]");

Reply via email to