From 758b3594cb13c3aee23dadff8f9e0b2afb0b9c29 Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Wed, 28 Jun 2017 16:41:39 +0100 Subject: [PATCH 1/3] repair what i think the test was supposed to test added by @neykov in d2f8ff16947dcbafd678841bcf64cb5d0214e0ef the file referenced doesn't exist; as rewritten it is a meaningful and failing test but one we'd like to have working --- .../org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java index 8de36feaaa..fc56564fe1 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java @@ -133,7 +133,7 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception { "brooklyn.catalog:", " itemType: entity", " items:", - " - id: yaml.standalone", + " - id: yaml.basic", " version: " + TEST_VERSION, " item:", " services:", @@ -142,7 +142,7 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception { " version: " + TEST_VERSION, " item:", " services:", - " - type: classpath://yaml-ref-parent-catalog.yaml"); + " - type: classpath://yaml-ref-catalog.yaml"); // this references yaml.basic above String entityName = "YAML -> catalog item -> yaml url"; Entity app = createAndStartApplication( From fb3dcbebd876fbfbdf18598de359c954525fcb3d Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Wed, 28 Jun 2017 16:47:24 +0100 Subject: [PATCH 2/3] add another catalog internal reference failure case and the corresponding working case --- .../camp/brooklyn/ReferencedYamlTest.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java index fc56564fe1..50888a8dc5 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java @@ -127,6 +127,56 @@ public void testYamlUrlReferencingCatalog() throws Exception { checkChildEntitySpec(app, entityName); } + @Test + public void testYamlReferencingEarlierItemShortForm() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " itemType: entity", + " items:", + " - id: yaml.basic", + " version: " + TEST_VERSION, + " item:", + " type: org.apache.brooklyn.entity.stock.BasicEntity", + " - id: yaml.reference", + " version: " + TEST_VERSION, + " item:", + " type: yaml.basic"); + + String entityName = "YAML -> catalog item -> yaml url"; + Entity app = createAndStartApplication( + "services:", + "- name: " + entityName, + " type: " + ver("yaml.reference")); + + checkChildEntitySpec(app, entityName); + } + + @Test(groups="WIP") // references to earlier items only work with short form syntax + public void testYamlReferencingEarlierItemLongForm() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " itemType: entity", + " items:", + " - id: yaml.basic", + " version: " + TEST_VERSION, + " item:", + " services:", + " - type: org.apache.brooklyn.entity.stock.BasicEntity", + " - id: yaml.reference", + " version: " + TEST_VERSION, + " item:", + " services:", + " - type: yaml.basic"); + + String entityName = "YAML -> catalog item -> yaml url"; + Entity app = createAndStartApplication( + "services:", + "- name: " + entityName, + " type: " + ver("yaml.reference")); + + checkChildEntitySpec(app, entityName); + } + @Test(groups="WIP") //Not able to use caller provided catalog items when referencing entity specs (as opposed to catalog meta) public void testYamlUrlReferencingCallerCatalogItem() throws Exception { addCatalogItems( @@ -152,7 +202,7 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception { checkChildEntitySpec(app, entityName); } - + private void checkChildEntitySpec(Entity app, String entityName) { Collection children = app.getChildren(); Assert.assertEquals(children.size(), 1); From 178aeeecbc68eb91b5cb0f91806c7689e0e40973 Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Thu, 29 Jun 2017 09:53:31 +0100 Subject: [PATCH 3/3] expand tests for completeness --- .../camp/brooklyn/ReferencedYamlTest.java | 78 +++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java index 50888a8dc5..3480368e21 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java @@ -91,6 +91,24 @@ public void testAnonymousReferenceYamlAsChild() throws Exception { @Test public void testCatalogReferencingYamlUrl() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " id: yaml.reference", + " version: " + TEST_VERSION, + " itemType: entity", + " item: classpath://yaml-ref-entity.yaml"); + + String entityName = "YAML -> catalog item -> yaml url"; + Entity app = createAndStartApplication( + "services:", + "- name: " + entityName, + " type: " + ver("yaml.reference")); + + checkChildEntitySpec(app, entityName); + } + + @Test + public void testCatalogReferencingYamlUrlAsType() throws Exception { addCatalogItems( "brooklyn.catalog:", " id: yaml.reference", @@ -152,7 +170,7 @@ public void testYamlReferencingEarlierItemShortForm() throws Exception { } @Test(groups="WIP") // references to earlier items only work with short form syntax - public void testYamlReferencingEarlierItemLongForm() throws Exception { + public void testYamlReferencingEarlierItemLongFormEntity() throws Exception { addCatalogItems( "brooklyn.catalog:", " itemType: entity", @@ -165,6 +183,33 @@ public void testYamlReferencingEarlierItemLongForm() throws Exception { " - id: yaml.reference", " version: " + TEST_VERSION, " item:", + // deliberately: discouraged syntax for itemType entity + " services:", + " - type: yaml.basic"); + + String entityName = "YAML -> catalog item -> yaml url"; + Entity app = createAndStartApplication( + "services:", + "- name: " + entityName, + " type: " + ver("yaml.reference")); + + checkChildEntitySpec(app, entityName); + } + + @Test // references work fine with templates because we don't parse templates + public void testYamlReferencingEarlierItemLongFormTemplate() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " itemType: template", + " items:", + " - id: yaml.basic", + " version: " + TEST_VERSION, + " item:", + " services:", + " - type: org.apache.brooklyn.entity.stock.BasicEntity", + " - id: yaml.reference", + " version: " + TEST_VERSION, + " item:", " services:", " - type: yaml.basic"); @@ -178,7 +223,7 @@ public void testYamlReferencingEarlierItemLongForm() throws Exception { } @Test(groups="WIP") //Not able to use caller provided catalog items when referencing entity specs (as opposed to catalog meta) - public void testYamlUrlReferencingCallerCatalogItem() throws Exception { + public void testYamlReferencingEarlierItemInUrl() throws Exception { addCatalogItems( "brooklyn.catalog:", " itemType: entity", @@ -186,13 +231,34 @@ public void testYamlUrlReferencingCallerCatalogItem() throws Exception { " - id: yaml.basic", " version: " + TEST_VERSION, " item:", - " services:", - " - type: org.apache.brooklyn.entity.stock.BasicApplication", + " type: org.apache.brooklyn.entity.stock.BasicApplication", + " - id: yaml.reference", + " version: " + TEST_VERSION, + " item: classpath://yaml-ref-catalog.yaml"); // this references yaml.basic above + + String entityName = "YAML -> catalog item -> yaml url"; + Entity app = createAndStartApplication( + "services:", + "- name: " + entityName, + " type: " + ver("yaml.reference")); + + checkChildEntitySpec(app, entityName); + } + + @Test(groups="WIP") //Not able to use caller provided catalog items when referencing entity specs (as opposed to catalog meta) + public void testYamlReferencingEarlierItemInUrlAsType() throws Exception { + addCatalogItems( + "brooklyn.catalog:", + " itemType: entity", + " items:", + " - id: yaml.basic", + " version: " + TEST_VERSION, + " item:", + " type: org.apache.brooklyn.entity.stock.BasicApplication", " - id: yaml.reference", " version: " + TEST_VERSION, " item:", - " services:", - " - type: classpath://yaml-ref-catalog.yaml"); // this references yaml.basic above + " type: classpath://yaml-ref-catalog.yaml"); // this references yaml.basic above String entityName = "YAML -> catalog item -> yaml url"; Entity app = createAndStartApplication(