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 2015/08/11 22:42:54 UTC

[16/18] incubator-brooklyn git commit: Adds CatalogYamlAppTest.testAddCatalogItemWithCircularReference

Adds CatalogYamlAppTest.testAddCatalogItemWithCircularReference

A work-in-progress test, demonstrating a StackOverflowError.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/36fb5e9d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/36fb5e9d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/36fb5e9d

Branch: refs/heads/master
Commit: 36fb5e9dcbe5f72a3be577006d5375aecea08cad
Parents: a5fbce7
Author: Aled Sage <al...@gmail.com>
Authored: Tue Aug 4 23:29:43 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Aug 11 20:04:32 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/catalog/CatalogYamlAppTest.java    | 73 ++++++++++++++++++++
 1 file changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/36fb5e9d/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlAppTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlAppTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlAppTest.java
new file mode 100644
index 0000000..48ecb42
--- /dev/null
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogYamlAppTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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 io.brooklyn.camp.brooklyn.catalog;
+
+import org.testng.annotations.Test;
+
+import io.brooklyn.camp.brooklyn.AbstractYamlTest;
+
+
+public class CatalogYamlAppTest extends AbstractYamlTest {
+    
+    /**
+     * "Contrived" example was encountered by a customer in a real use-case!
+     * I couldn't yet simplify it further while still reproducing the failure.
+     * Throws StackOverlfowError, without giving a nice error message about 
+     * "BasicEntity" cyclic reference.
+     * 
+     * The circular reference comes from the member spec referencing 
+     * "brooklyn.entity.basic.BasicEntity", but that has been defined in the
+     * catalog as this new blueprint (which overrides the previous value of it
+     * being a reference to the Java class).
+     * 
+     * We need to use an id that matches something else already on the classpath.
+     * Otherwise we'd get an error telling us "could not resolve item ..." when
+     * attempting to add the initial catalog item.
+     */
+    @Test(groups="WIP") // TODO Fix this!
+    public void testAddCatalogItemWithCircularReference() throws Exception {
+        // Add a catalog item with a circular reference to its own id.
+        addCatalogItems(
+                "brooklyn.catalog:",
+                "  id: brooklyn.entity.basic.BasicEntity",
+                "  version: "+TEST_VERSION,
+                "services:",
+                "- type: brooklyn.entity.basic.BasicApplication",
+                "  brooklyn.config:",
+                "    memberSpec:",
+                "      $brooklyn:entitySpec:",
+                "      - type: brooklyn.entity.basic.BasicApplication",
+                "        brooklyn.children:",
+                "        - type: brooklyn.entity.basic.BasicEntity");
+
+        try {
+            // Use the blueprint from the catalog that has the circular reference.
+            // This should really give a nice error (rather than a StackOverflowError!).
+            addCatalogItems(
+                    "brooklyn.catalog:",
+                    "  id: another.app.in.the.catalog",
+                    "  version: "+TEST_VERSION,
+                    "services:",
+                    "- type: brooklyn.entity.basic.BasicEntity");
+            deleteCatalogEntity("another.app.in.the.catalog");
+        } finally {
+            deleteCatalogEntity("brooklyn.entity.basic.BasicEntity");
+        }
+    }
+}