You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/02/26 12:27:31 UTC

[3/6] incubator-brooklyn git commit: Don't load old-style catalog items when "java:" prefix is used

Don't load old-style catalog items when "java:" prefix is used


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

Branch: refs/heads/master
Commit: e09ddb0ca23c432b5d0e89e6a9776f5d9bec510b
Parents: 2bd6480
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Feb 25 16:32:17 2015 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Feb 25 16:32:17 2015 +0200

----------------------------------------------------------------------
 .../BrooklynComponentTemplateResolver.java      |  2 +-
 .../brooklyn/catalog/CatalogXmlVersionTest.java | 15 ++++++++++-
 .../camp/brooklyn/catalog/TestBasicApp.java     | 27 ++++++++++++++++++++
 .../camp/brooklyn/catalog/TestBasicAppImpl.java | 24 +++++++++++++++++
 .../camp/src/test/resources/simple-catalog.xml  |  4 +++
 5 files changed, 70 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e09ddb0c/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index 416f2e8..05faed5 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -222,7 +222,7 @@ public class BrooklynComponentTemplateResolver {
 
     private String getJavaType() {
         CatalogItem<Entity, EntitySpec<?>> item = getCatalogItem();
-        if (item != null && item.getJavaType() != null) {
+        if (!isJavaTypePrefix() && item != null && item.getJavaType() != null) {
             return item.getJavaType();
         } else {
             return getBrooklynType();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e09ddb0c/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
index 5ae5493..cf1e211 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
@@ -18,6 +18,7 @@
  */
 package io.brooklyn.camp.brooklyn.catalog;
 
+import static org.testng.Assert.assertTrue;
 import io.brooklyn.camp.brooklyn.AbstractYamlTest;
 
 import org.testng.annotations.DataProvider;
@@ -25,6 +26,7 @@ import org.testng.annotations.Test;
 
 import brooklyn.config.BrooklynProperties;
 import brooklyn.config.BrooklynServerConfig;
+import brooklyn.entity.Entity;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.test.entity.LocalManagementContextForTests;
 
@@ -50,10 +52,21 @@ public class CatalogXmlVersionTest extends AbstractYamlTest {
 
     @Test(dataProvider = "types")
     public void testXmlCatalogItem(String type) throws Exception {
+        startApp(type);
+    }
+
+    @Test
+    public void testJavaPrefixDoesNotLoadXMLCatalogItem() throws Exception {
+        Entity entity = startApp("java:io.brooklyn.camp.brooklyn.catalog.TestBasicApp");
+        assertTrue(entity instanceof TestBasicApp, "Entity is not a " + TestBasicApp.class.getName() + ", instead the type is " + entity.getEntityType().getName());
+    }
+
+    private Entity startApp(String type) throws Exception {
         String yaml = "name: simple-app-yaml\n" +
                 "location: localhost\n" +
                 "services: \n" +
                 "  - type: " + type;
-        createAndStartApplication(yaml);
+        return createAndStartApplication(yaml);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e09ddb0c/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
new file mode 100644
index 0000000..46347c5
--- /dev/null
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicApp.java
@@ -0,0 +1,27 @@
+/*
+ * 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 brooklyn.entity.basic.BasicApplication;
+import brooklyn.entity.proxying.ImplementedBy;
+
+@ImplementedBy(TestBasicAppImpl.class)
+public interface TestBasicApp extends BasicApplication {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e09ddb0c/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
new file mode 100644
index 0000000..952ccd9
--- /dev/null
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/catalog/TestBasicAppImpl.java
@@ -0,0 +1,24 @@
+/*
+ * 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 brooklyn.entity.basic.BasicApplicationImpl;
+
+public class TestBasicAppImpl extends BasicApplicationImpl implements TestBasicApp {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e09ddb0c/usage/camp/src/test/resources/simple-catalog.xml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/simple-catalog.xml b/usage/camp/src/test/resources/simple-catalog.xml
index b0d88cc..e3a1214 100644
--- a/usage/camp/src/test/resources/simple-catalog.xml
+++ b/usage/camp/src/test/resources/simple-catalog.xml
@@ -34,4 +34,8 @@
         <symbolicName>BasicApp</symbolicName>
         <description>An example application</description>
     </template>
+    <template name="Custom App" type="brooklyn.entity.basic.BasicApplication">
+        <symbolicName>io.brooklyn.camp.brooklyn.catalog.TestBasicApp</symbolicName>
+        <!-- Tests that "java:" prefix won't load an old-style catalog item with the same id -->
+    </template>
 </catalog>