Fix tests after rebase with master
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c6094973 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c6094973 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c6094973 Branch: refs/heads/master Commit: c60949739d4eaa00ef2647d6aba920b449a5c95b Parents: 5c37de2 Author: Geoff Macartney <[email protected]> Authored: Mon Feb 20 13:45:06 2017 +0000 Committer: Geoff Macartney <[email protected]> Committed: Thu Apr 20 11:20:36 2017 +0100 ---------------------------------------------------------------------- .../catalog/CatalogOsgiYamlEntityTest.java | 112 +++++++++++++------ .../brooklyn/catalog/CatalogYamlEntityTest.java | 47 +------- .../rebind/RebindConfigInheritanceTest.java | 1 + 3 files changed, 78 insertions(+), 82 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c6094973/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiYamlEntityTest.java ---------------------------------------------------------------------- diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiYamlEntityTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiYamlEntityTest.java index 53b27f1..102f476 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiYamlEntityTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiYamlEntityTest.java @@ -57,6 +57,8 @@ public class CatalogOsgiYamlEntityTest extends AbstractYamlTest { // The non-osgi tests are much faster to run! private static final String SIMPLE_ENTITY_TYPE = OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY; + private static final String MORE_ENTITIES_POM_PROPERTIES_PATH = + "META-INF/maven/org.apache.brooklyn.test.resources.osgi/brooklyn-test-osgi-more-entities/pom.properties"; @Override protected boolean disableOsgi() { @@ -743,43 +745,81 @@ public class CatalogOsgiYamlEntityTest extends AbstractYamlTest { deleteCatalogEntity(symbolicNameOuter); } - // The test is disabled as it fails. The entity will get assigned the outer-most catalog - // item which doesn't have the necessary libraries with visibility to the entity's classpath - // When loading resources from inside the entity then we will use the wrong BCLCS. A workaround - // has been implemented which explicitly adds the entity's class loader to the fallbacks. - @Test(groups="WIP") - public void testCatalogItemIdInReferencedItems() throws Exception { - TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH); - - String symbolicNameInner = "my.catalog.app.id.inner"; - String symbolicNameOuter = "my.catalog.app.id.outer"; - addCatalogItems( - "brooklyn.catalog:", - " version: " + TEST_VERSION, - " items:", - " - id: " + symbolicNameInner, - " name: My Catalog App", - " description: My description", - " icon_url: classpath://path/to/myicon.jpg", - " libraries:", - " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL, - " item: " + SIMPLE_ENTITY_TYPE, - " - id: " + symbolicNameOuter, - " item: " + symbolicNameInner); - - String yaml = "name: " + symbolicNameOuter + "\n" + - "services: \n" + - " - serviceType: "+ver(symbolicNameOuter); - Entity app = createAndStartApplication(yaml); - Entity entity = app.getChildren().iterator().next(); - - // Fails - assertEquals(entity.getCatalogItemId(), ver(symbolicNameInner)); - - deleteCatalogEntity(symbolicNameInner); - deleteCatalogEntity(symbolicNameOuter); - } + @Test + public void testDeepCatalogItemCanLoadResources() throws Exception { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH); + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_MORE_ENTITIES_0_1_0_PATH); + + String symbolicNameInner = "my.catalog.app.id.inner"; + String symbolicNameFiller = "my.catalog.app.id.filler"; + String symbolicNameOuter = "my.catalog.app.id.outer"; + addCatalogItems( + "brooklyn.catalog:", + " version: " + TEST_VERSION, + " items:", + " - id: " + symbolicNameInner, + " name: My Catalog App", + " brooklyn.libraries:", + " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL, + " item: " + SIMPLE_ENTITY_TYPE, + " - id: " + symbolicNameFiller, + " name: Filler App", + " brooklyn.libraries:", + " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_MORE_ENTITIES_0_1_0_URL, + " item: " + symbolicNameInner, + " - id: " + symbolicNameOuter, + " item: " + symbolicNameFiller); + + String yaml = "name: " + symbolicNameOuter + "\n" + + "services: \n" + + " - serviceType: "+ver(symbolicNameOuter); + Entity app = createAndStartApplication(yaml); + Entity entity = app.getChildren().iterator().next(); + + final String catalogBom = ResourceUtils.create(entity).getResourceAsString("classpath://" + MORE_ENTITIES_POM_PROPERTIES_PATH); + assertTrue(catalogBom.contains("artifactId=brooklyn-test-osgi-more-entities")); + + deleteCatalogEntity(symbolicNameOuter); + deleteCatalogEntity(symbolicNameFiller); + deleteCatalogEntity(symbolicNameInner); + } + + @Test + public void testCatalogItemIdInReferencedItems() throws Exception { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH); + + String symbolicNameInner = "my.catalog.app.id.inner"; + String symbolicNameOuter = "my.catalog.app.id.outer"; + addCatalogItems( + "brooklyn.catalog:", + " version: " + TEST_VERSION, + " items:", + " - id: " + symbolicNameInner, + " name: My Catalog App", + " description: My description", + " icon_url: classpath://path/to/myicon.jpg", + " brooklyn.libraries:", + " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL, + " item: " + SIMPLE_ENTITY_TYPE, + " - id: " + symbolicNameOuter, + " item: " + symbolicNameInner); + + String yaml = "name: " + symbolicNameOuter + "\n" + + "services: \n" + + " - serviceType: "+ver(symbolicNameOuter); + + Entity app = createAndStartApplication(yaml); + + Entity entity = app.getChildren().iterator().next(); + assertEquals(entity.getCatalogItemId(), ver(symbolicNameOuter)); + assertEquals(entity.getCatalogItemSuperIds().size(), 2); + assertEquals(entity.getCatalogItemSuperIds().get(0), ver(symbolicNameOuter)); + assertEquals(entity.getCatalogItemSuperIds().get(1), ver(symbolicNameInner)); + + deleteCatalogEntity(symbolicNameInner); + deleteCatalogEntity(symbolicNameOuter); + } private void registerAndLaunchAndAssertSimpleEntity(String symbolicName, String serviceType) throws Exception { addCatalogOSGiEntity(symbolicName, serviceType); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c6094973/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java ---------------------------------------------------------------------- diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java index cc26c22..d491860 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java @@ -18,9 +18,6 @@ */ package org.apache.brooklyn.camp.brooklyn.catalog; -import static org.apache.brooklyn.util.osgi.OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_MESSAGE_RESOURCE; -import static org.apache.commons.io.FileUtils.getFile; -import static org.apache.commons.io.FileUtils.readFileToString; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -37,20 +34,15 @@ import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest; import org.apache.brooklyn.config.ConfigKey; import org.apache.brooklyn.core.catalog.internal.CatalogUtils; import org.apache.brooklyn.core.config.ConfigKeys; -import org.apache.brooklyn.core.entity.BrooklynConfigKeys; -import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest; import org.apache.brooklyn.core.test.entity.TestEntity; import org.apache.brooklyn.core.test.entity.TestEntityImpl; import org.apache.brooklyn.core.typereg.RegisteredTypes; -import org.apache.brooklyn.entity.software.base.SoftwareProcess; -import org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess; +import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess; 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.core.ResourceUtils; import org.apache.brooklyn.util.exceptions.Exceptions; import org.apache.brooklyn.util.osgi.OsgiTestResources; -import org.apache.commons.io.FileUtils; import org.testng.Assert; import org.testng.annotations.Test; @@ -632,43 +624,6 @@ public class CatalogYamlEntityTest extends AbstractYamlTest { mgmt().getCatalog().deleteCatalogItem(id, version); } - @Test - public void testDeepCatalogItemCanLoadResources() throws Exception { - - String symbolicNameInner = "my.catalog.app.id.inner"; - String symbolicNameFiller = "my.catalog.app.id.filler"; - String symbolicNameOuter = "my.catalog.app.id.outer"; - addCatalogItems( - "brooklyn.catalog:", - " version: " + TEST_VERSION, - " items:", - " - id: " + symbolicNameInner, - " name: My Catalog App", - " brooklyn.libraries:", - " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL, - " item: " + SIMPLE_ENTITY_TYPE, - " - id: " + symbolicNameFiller, - " name: Filler App", - " brooklyn.libraries:", - " - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_MORE_ENTITIES_0_1_0_URL, - " item: " + symbolicNameInner, - " - id: " + symbolicNameOuter, - " item: " + symbolicNameFiller); - - String yaml = "name: " + symbolicNameOuter + "\n" + - "services: \n" + - " - serviceType: "+ver(symbolicNameOuter); - Entity app = createAndStartApplication(yaml); - Entity entity = app.getChildren().iterator().next(); - - final String catalogBom = ResourceUtils.create(entity).getResourceAsString("classpath://" + MORE_ENTITIES_POM_PROPERTIES_PATH); - assertTrue(catalogBom.contains("artifactId=brooklyn-test-osgi-more-entities")); - - deleteCatalogEntity(symbolicNameOuter); - deleteCatalogEntity(symbolicNameFiller); - deleteCatalogEntity(symbolicNameInner); - } - @Test public void testCatalogItemIdInReferencedItems() throws Exception { String symbolicNameInner = "my.catalog.app.id.inner"; http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c6094973/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java index 06ad60f..f48a53a 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java @@ -117,6 +117,7 @@ public class RebindConfigInheritanceTest extends RebindTestFixtureWithApp { checkNewAppNonInheritingKey1(rebindedApp); String origMementoTidied = origMemento.substring(origMemento.indexOf("<entity>")); + origMementoTidied = origMementoTidied.replaceFirst("</displayName>", "</displayName>\n <catalogItemSuperIds class=\"ImmutableList\"/>"); origMementoTidied = Strings.replaceAllNonRegex(origMementoTidied, "VERSION", BrooklynVersion.get()); Asserts.assertEquals(origMementoTidied, newMemento); }
