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 2016/09/23 16:40:16 UTC
[1/2] brooklyn-server git commit: Add more tests to
TemplateProcessorTest
Repository: brooklyn-server
Updated Branches:
refs/heads/master 9b602930b -> 21a36649b
Add more tests to TemplateProcessorTest
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2c17af0f
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2c17af0f
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2c17af0f
Branch: refs/heads/master
Commit: 2c17af0f9f35844dd4430ab8fe87128ecc0cce6d
Parents: 9b60293
Author: Aled Sage <al...@gmail.com>
Authored: Fri Sep 23 14:26:48 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Sep 23 14:26:48 2016 +0100
----------------------------------------------------------------------
.../util/core/text/TemplateProcessorTest.java | 35 ++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2c17af0f/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java b/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
index 0f8bf47..547279f 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
@@ -23,9 +23,12 @@ import static org.testng.Assert.assertEquals;
import com.google.common.collect.Iterables;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.EntityInternal;
import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
import org.apache.brooklyn.core.sensor.DependentConfiguration;
+import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
import org.apache.brooklyn.core.test.entity.TestApplication;
import org.apache.brooklyn.core.test.entity.TestEntity;
@@ -37,6 +40,7 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
public class TemplateProcessorTest extends BrooklynAppUnitTestSupport {
@@ -90,6 +94,37 @@ public class TemplateProcessorTest extends BrooklynAppUnitTestSupport {
}
@Test
+ public void testEntityAttribute() {
+ TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+ entity.sensors().set(Attributes.HOSTNAME, "myval");
+ String templateContents = "${attribute['"+Attributes.HOSTNAME.getName()+"']}";
+ String result = TemplateProcessor.processTemplateContents(templateContents, entity, ImmutableMap.<String,Object>of());
+ assertEquals(result, "myval");
+ }
+
+ @Test
+ public void testConditionalComparingAttributes() {
+ AttributeSensor<String> sensor1 = Sensors.newStringSensor("sensor1");
+ AttributeSensor<String> sensor2 = Sensors.newStringSensor("sensor2");
+ TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+ entity.sensors().set(sensor1, "myval1");
+ entity.sensors().set(sensor2, "myval1");
+ String templateContents = Joiner.on("\n").join(
+ "[#ftl]",
+ "[#if attribute['sensor1'] == attribute['sensor2']]",
+ "true",
+ "[#else]",
+ "false",
+ "[/#if]");
+ String result = TemplateProcessor.processTemplateContents(templateContents, entity, ImmutableMap.<String,Object>of());
+ assertEquals(result.trim(), "true");
+
+ entity.sensors().set(sensor2, "myval2");
+ String result2 = TemplateProcessor.processTemplateContents(templateContents, entity, ImmutableMap.<String,Object>of());
+ assertEquals(result2.trim(), "false");
+ }
+
+ @Test
public void testGetSysProp() {
System.setProperty("testGetSysProp", "myval");
[2/2] brooklyn-server git commit: This closes #347
Posted by al...@apache.org.
This closes #347
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/21a36649
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/21a36649
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/21a36649
Branch: refs/heads/master
Commit: 21a36649b2f645f27b22456403c0e4fcf3e4013d
Parents: 9b60293 2c17af0
Author: Aled Sage <al...@gmail.com>
Authored: Fri Sep 23 17:40:06 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Sep 23 17:40:06 2016 +0100
----------------------------------------------------------------------
.../util/core/text/TemplateProcessorTest.java | 35 ++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------