Github user nakomis commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/971#discussion_r214940310
--- Diff:
camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/DslAndRebindYamlTest.java
---
@@ -467,6 +467,30 @@ public void testDslLocation() throws Exception {
assertEquals(getConfigInTask(testEntity,
ConfigKeys.newConfigKey(Object.class, "config2")), appLoc);
}
+ @Test
+ public void testDslLocationIndexOutOfBounds() throws Exception {
+ String yaml = Joiner.on("\n").join(
+ "location: localhost",
+ "services:",
+ "- type: " + BasicApplication.class.getName(),
+ " brooklyn.config:",
+ " config1: $brooklyn:location(\"1\")");
+
+ Application app = (Application)
createStartWaitAndLogApplication(yaml);
+
+ Location appLoc = Iterables.getOnlyElement(app.getLocations());
+ try {
+ assertEquals(getConfigInTask(app,
ConfigKeys.newConfigKey(Object.class, "config1")), appLoc);
--- End diff --
If an exception is not thrown here the test will pass when it should fail.
This case should be checked, e.g. by throwing `IllegalStateException` after
this line
---