You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2017/02/13 06:26:47 UTC
[7/9] brooklyn-server git commit: Split ReferencedYamlTest for
non-osgi and osgi
Split ReferencedYamlTest for non-osgi and osgi
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/8f0021ed
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/8f0021ed
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/8f0021ed
Branch: refs/heads/master
Commit: 8f0021eddb3df379dad227c31b9f4b29e9dfaeba
Parents: c5ae189
Author: Aled Sage <al...@gmail.com>
Authored: Fri Feb 10 21:55:56 2017 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Feb 10 22:16:09 2017 +0000
----------------------------------------------------------------------
.../camp/brooklyn/ReferencedOsgiYamlTest.java | 230 +++++++++++++++++++
.../camp/brooklyn/ReferencedYamlTest.java | 191 ---------------
2 files changed, 230 insertions(+), 191 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8f0021ed/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedOsgiYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedOsgiYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedOsgiYamlTest.java
new file mode 100644
index 0000000..4fc647d
--- /dev/null
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedOsgiYamlTest.java
@@ -0,0 +1,230 @@
+/*
+ * 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 org.apache.brooklyn.camp.brooklyn;
+
+import java.util.Collection;
+
+import org.apache.brooklyn.api.catalog.BrooklynCatalog;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
+import org.apache.brooklyn.entity.stock.BasicEntity;
+import org.apache.brooklyn.test.support.TestResourceUnavailableException;
+import org.apache.brooklyn.util.osgi.OsgiTestResources;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+public class ReferencedOsgiYamlTest extends AbstractYamlTest {
+
+ @Override
+ protected boolean disableOsgi() {
+ return false;
+ }
+
+ @Test
+ public void testCatalogReferencingYamlUrlFromOsgiBundle() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " id: yaml.reference",
+ " version: " + TEST_VERSION,
+ " itemType: entity",
+ " libraries:",
+ " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " item:",
+ " type: classpath://yaml-ref-osgi-entity.yaml");
+
+ String entityName = "YAML -> catalog item -> yaml url (osgi)";
+ Entity app = createAndStartApplication(
+ "services:",
+ "- name: " + entityName,
+ " type: " + ver("yaml.reference"));
+
+ checkChildEntitySpec(app, entityName);
+ }
+
+ /**
+ * Tests that a YAML referenced by URL from a catalog item
+ * will have access to the catalog item's bundles.
+ */
+ @Test
+ public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ String parentCatalogId = "my.catalog.app.id.url.parent";
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " id: " + parentCatalogId,
+ " version: " + TEST_VERSION,
+ " itemType: entity",
+ " libraries:",
+ " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " item:",
+ " type: classpath://yaml-ref-bundle-without-libraries.yaml");
+
+ Entity app = createAndStartApplication(
+ "services:",
+ "- type: " + ver(parentCatalogId));
+
+ Collection<Entity> children = app.getChildren();
+ Assert.assertEquals(children.size(), 1);
+ Entity child = Iterables.getOnlyElement(children);
+ Assert.assertEquals(child.getEntityType().getName(), "org.apache.brooklyn.test.osgi.entities.SimpleEntity");
+
+ deleteCatalogEntity(parentCatalogId);
+ }
+
+ @Test
+ public void testCatalogReference() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " brooklyn.libraries:",
+ " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " items:",
+ " - classpath://yaml-ref-parent-catalog.bom");
+
+ assertCatalogReference();
+ }
+
+ @Test
+ public void testCatalogReferenceByExplicitUrl() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " brooklyn.libraries:",
+ " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " items:",
+ " - include: classpath://yaml-ref-parent-catalog.bom");
+
+ assertCatalogReference();
+ }
+
+ @Test
+ public void testCatalogReferenceByMultipleUrls() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " items:",
+ " - include: classpath://yaml-ref-simple.bom",
+ " - include: classpath://yaml-ref-more.bom"
+ );
+
+ assertCatalogReference();
+ }
+
+ @Test
+ public void testCatalogReferenceByMultipleUrlsSimplerSyntax() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " items:",
+ " - classpath://yaml-ref-simple.bom",
+ " - classpath://yaml-ref-more.bom"
+ );
+
+ assertCatalogReference();
+ }
+
+
+ @Test
+ public void testCatalogReferenceSeesPreviousItems() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " brooklyn.libraries:",
+ " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " items:",
+ " - id: yaml.nested.catalog.simple",
+ " itemType: entity",
+ " item:",
+ " type: " + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY,
+ " - include: classpath://yaml-ref-back-catalog.bom");
+
+ String entityNameSimple = "YAML -> catalog -> catalog (osgi)";
+ Entity app = createAndStartApplication(
+ "services:",
+ "- name: " + entityNameSimple,
+ " type: back-reference");
+
+ Collection<Entity> children = app.getChildren();
+ Assert.assertEquals(children.size(), 1);
+ Entity childSimple = Iterables.getOnlyElement(children);
+ Assert.assertEquals(childSimple.getDisplayName(), entityNameSimple);
+ Assert.assertEquals(childSimple.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
+ }
+
+ @Test
+ public void testCatalogReferenceMixesMetaAndUrl() throws Exception {
+ TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " brooklyn.libraries:",
+ " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+ " items:",
+ " - include: classpath://yaml-ref-parent-catalog.bom",
+ " items:",
+ " - id: yaml.nested.catalog.nested",
+ " itemType: entity",
+ " item:",
+ " type: " + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
+
+ BrooklynCatalog catalog = mgmt().getCatalog();
+ Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.nested", BrooklynCatalog.DEFAULT_VERSION));
+ Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.simple", BrooklynCatalog.DEFAULT_VERSION));
+ Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.more", BrooklynCatalog.DEFAULT_VERSION));
+ }
+
+ protected void assertCatalogReference() throws Exception {
+ String entityNameSimple = "YAML -> catalog -> catalog simple (osgi)";
+ String entityNameMore = "YAML -> catalog -> catalog more (osgi)";
+ Entity app = createAndStartApplication(
+ "services:",
+ "- name: " + entityNameSimple,
+ " type: yaml.nested.catalog.simple",
+ "- name: " + entityNameMore,
+ " type: yaml.nested.catalog.more");
+
+ Collection<Entity> children = app.getChildren();
+ Assert.assertEquals(children.size(), 2);
+ Entity childSimple = Iterables.get(children, 0);
+ Assert.assertEquals(childSimple.getDisplayName(), entityNameSimple);
+ Assert.assertEquals(childSimple.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
+
+ Entity childMore = Iterables.get(children, 1);
+ Assert.assertEquals(childMore.getDisplayName(), entityNameMore);
+ Assert.assertEquals(childMore.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
+ }
+
+ private void checkChildEntitySpec(Entity app, String entityName) {
+ Collection<Entity> children = app.getChildren();
+ Assert.assertEquals(children.size(), 1);
+ Entity child = Iterables.getOnlyElement(children);
+ Assert.assertEquals(child.getDisplayName(), entityName);
+ Assert.assertEquals(child.getEntityType().getName(), BasicEntity.class.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/8f0021ed/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ReferencedYamlTest.java
----------------------------------------------------------------------
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 8775496..8de36fe 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
@@ -20,13 +20,9 @@ package org.apache.brooklyn.camp.brooklyn;
import java.util.Collection;
-import org.apache.brooklyn.api.catalog.BrooklynCatalog;
import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
import org.apache.brooklyn.entity.stock.BasicApplication;
import org.apache.brooklyn.entity.stock.BasicEntity;
-import org.apache.brooklyn.test.support.TestResourceUnavailableException;
-import org.apache.brooklyn.util.osgi.OsgiTestResources;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -34,11 +30,6 @@ import com.google.common.collect.Iterables;
public class ReferencedYamlTest extends AbstractYamlTest {
- @Override
- protected boolean disableOsgi() {
- return false;
- }
-
@Test
public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
String entityName = "Reference child name";
@@ -118,29 +109,6 @@ public class ReferencedYamlTest extends AbstractYamlTest {
}
@Test
- public void testCatalogReferencingYamlUrlFromOsgiBundle() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " id: yaml.reference",
- " version: " + TEST_VERSION,
- " itemType: entity",
- " libraries:",
- " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " item:",
- " type: classpath://yaml-ref-osgi-entity.yaml");
-
- String entityName = "YAML -> catalog item -> yaml url (osgi)";
- Entity app = createAndStartApplication(
- "services:",
- "- name: " + entityName,
- " type: " + ver("yaml.reference"));
-
- checkChildEntitySpec(app, entityName);
- }
-
- @Test
public void testYamlUrlReferencingCatalog() throws Exception {
addCatalogItems(
"brooklyn.catalog:",
@@ -185,165 +153,6 @@ public class ReferencedYamlTest extends AbstractYamlTest {
checkChildEntitySpec(app, entityName);
}
- /**
- * Tests that a YAML referenced by URL from a catalog item
- * will have access to the catalog item's bundles.
- */
- @Test
- public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- String parentCatalogId = "my.catalog.app.id.url.parent";
- addCatalogItems(
- "brooklyn.catalog:",
- " id: " + parentCatalogId,
- " version: " + TEST_VERSION,
- " itemType: entity",
- " libraries:",
- " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " item:",
- " type: classpath://yaml-ref-bundle-without-libraries.yaml");
-
- Entity app = createAndStartApplication(
- "services:",
- "- type: " + ver(parentCatalogId));
-
- Collection<Entity> children = app.getChildren();
- Assert.assertEquals(children.size(), 1);
- Entity child = Iterables.getOnlyElement(children);
- Assert.assertEquals(child.getEntityType().getName(), "org.apache.brooklyn.test.osgi.entities.SimpleEntity");
-
- deleteCatalogEntity(parentCatalogId);
- }
-
- @Test
- public void testCatalogReference() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " brooklyn.libraries:",
- " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " items:",
- " - classpath://yaml-ref-parent-catalog.bom");
-
- assertCatalogReference();
- }
-
- @Test
- public void testCatalogReferenceByExplicitUrl() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " brooklyn.libraries:",
- " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " items:",
- " - include: classpath://yaml-ref-parent-catalog.bom");
-
- assertCatalogReference();
- }
-
- @Test
- public void testCatalogReferenceByMultipleUrls() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " items:",
- " - include: classpath://yaml-ref-simple.bom",
- " - include: classpath://yaml-ref-more.bom"
- );
-
- assertCatalogReference();
- }
-
- @Test
- public void testCatalogReferenceByMultipleUrlsSimplerSyntax() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " items:",
- " - classpath://yaml-ref-simple.bom",
- " - classpath://yaml-ref-more.bom"
- );
-
- assertCatalogReference();
- }
-
-
- @Test
- public void testCatalogReferenceSeesPreviousItems() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " brooklyn.libraries:",
- " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " items:",
- " - id: yaml.nested.catalog.simple",
- " itemType: entity",
- " item:",
- " type: " + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY,
- " - include: classpath://yaml-ref-back-catalog.bom");
-
- String entityNameSimple = "YAML -> catalog -> catalog (osgi)";
- Entity app = createAndStartApplication(
- "services:",
- "- name: " + entityNameSimple,
- " type: back-reference");
-
- Collection<Entity> children = app.getChildren();
- Assert.assertEquals(children.size(), 1);
- Entity childSimple = Iterables.getOnlyElement(children);
- Assert.assertEquals(childSimple.getDisplayName(), entityNameSimple);
- Assert.assertEquals(childSimple.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
- }
-
- @Test
- public void testCatalogReferenceMixesMetaAndUrl() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- addCatalogItems(
- "brooklyn.catalog:",
- " brooklyn.libraries:",
- " - " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
- " items:",
- " - include: classpath://yaml-ref-parent-catalog.bom",
- " items:",
- " - id: yaml.nested.catalog.nested",
- " itemType: entity",
- " item:",
- " type: " + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
-
- BrooklynCatalog catalog = mgmt().getCatalog();
- Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.nested", BrooklynCatalog.DEFAULT_VERSION));
- Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.simple", BrooklynCatalog.DEFAULT_VERSION));
- Assert.assertNotNull(catalog.getCatalogItem("yaml.nested.catalog.more", BrooklynCatalog.DEFAULT_VERSION));
- }
-
- protected void assertCatalogReference() throws Exception {
- String entityNameSimple = "YAML -> catalog -> catalog simple (osgi)";
- String entityNameMore = "YAML -> catalog -> catalog more (osgi)";
- Entity app = createAndStartApplication(
- "services:",
- "- name: " + entityNameSimple,
- " type: yaml.nested.catalog.simple",
- "- name: " + entityNameMore,
- " type: yaml.nested.catalog.more");
-
- Collection<Entity> children = app.getChildren();
- Assert.assertEquals(children.size(), 2);
- Entity childSimple = Iterables.get(children, 0);
- Assert.assertEquals(childSimple.getDisplayName(), entityNameSimple);
- Assert.assertEquals(childSimple.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY);
-
- Entity childMore = Iterables.get(children, 1);
- Assert.assertEquals(childMore.getDisplayName(), entityNameMore);
- Assert.assertEquals(childMore.getEntityType().getName(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY);
- }
-
private void checkChildEntitySpec(Entity app, String entityName) {
Collection<Entity> children = app.getChildren();
Assert.assertEquals(children.size(), 1);