You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/05/08 11:57:30 UTC
[2/3] brooklyn-server git commit: Delete catalog.xml support
Delete catalog.xml support
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/e0feddb7
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/e0feddb7
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/e0feddb7
Branch: refs/heads/master
Commit: e0feddb7f0aaa43baed6d6be29325be97ec24f16
Parents: a32cdd6
Author: Aled Sage <al...@gmail.com>
Authored: Mon Mar 20 13:15:22 2017 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri May 5 11:16:26 2017 +0100
----------------------------------------------------------------------
.../brooklyn/api/catalog/CatalogItem.java | 2 -
.../catalog/AbstractCatalogXmlTest.java | 108 ----------
.../camp/brooklyn/catalog/CatalogScanTest.java | 198 ++++++++++++++++++
.../brooklyn/catalog/CatalogXmlOsgiTest.java | 37 ----
.../brooklyn/catalog/CatalogXmlVersionTest.java | 57 ------
.../brooklyn/test/lite/CampYamlLiteTest.java | 24 ---
.../src/test/resources/osgi-catalog.xml | 29 ---
.../src/test/resources/simple-catalog.xml | 47 -----
.../core/catalog/CatalogPredicates.java | 63 +++++-
.../catalog/internal/BasicBrooklynCatalog.java | 12 --
.../internal/CatalogBundleConverter.java | 63 ------
.../catalog/internal/CatalogClasspathDo.java | 5 +-
.../core/catalog/internal/CatalogDo.java | 14 --
.../core/catalog/internal/CatalogDto.java | 90 +--------
.../core/catalog/internal/CatalogDtoUtils.java | 66 ------
.../catalog/internal/CatalogInitialization.java | 87 ++------
.../core/catalog/internal/CatalogItemDo.java | 5 -
.../internal/CatalogItemDtoAbstract.java | 18 --
.../catalog/internal/CatalogXmlSerializer.java | 77 -------
.../internal/JavaCatalogToSpecTransformer.java | 9 +-
.../core/server/BrooklynServerConfig.java | 2 +-
.../main/resources/brooklyn-catalog-empty.xml | 20 --
.../core/catalog/internal/CatalogDtoTest.java | 36 +---
.../core/catalog/internal/CatalogLoadTest.java | 79 --------
.../core/catalog/internal/CatalogScanTest.java | 199 -------------------
.../core/mgmt/rebind/RebindCatalogItemTest.java | 84 ++++++--
...talogWhenCatalogPersistenceDisabledTest.java | 49 +++--
.../core/test/BrooklynAppLiveTestSupport.java | 3 +-
.../brooklyn/catalog/internal/osgi-catalog.xml | 31 ---
.../rebind/rebind-catalog-item-test-catalog.xml | 28 ---
.../apache/brooklyn/rest/api/CatalogApi.java | 11 -
.../rest/resources/CatalogResource.java | 22 +-
.../rest/resources/CatalogResetTest.java | 118 -----------
.../src/test/resources/reset-catalog.xml | 37 ----
.../entity/brooklynnode/BrooklynNode.java | 19 --
.../brooklynnode/BrooklynNodeSshDriver.java | 14 --
.../BrooklynNodeIntegrationTest.java | 24 ---
37 files changed, 389 insertions(+), 1398 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java b/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java
index 6f27af7..83159ba 100644
--- a/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java
+++ b/api/src/main/java/org/apache/brooklyn/api/catalog/CatalogItem.java
@@ -128,8 +128,6 @@ public interface CatalogItem<T,SpecT> extends BrooklynObject, Rebindable {
public Collection<CatalogBundle> getLibraries();
- public String toXmlString();
-
/** @return The underlying YAML for this item, if known;
* currently including `services:` or `brooklyn.policies:` prefix (but this will likely be removed) */
@Nullable public String getPlanYaml();
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/AbstractCatalogXmlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/AbstractCatalogXmlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/AbstractCatalogXmlTest.java
deleted file mode 100644
index f93a77d..0000000
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/AbstractCatalogXmlTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.catalog;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
-import org.apache.brooklyn.core.internal.BrooklynProperties;
-import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.util.osgi.OsgiTestResources;
-import org.apache.brooklyn.core.server.BrooklynServerConfig;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-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.os.Os;
-import org.apache.brooklyn.util.stream.ReaderInputStream;
-import org.apache.brooklyn.util.stream.Streams;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringReader;
-
-import com.google.common.io.ByteStreams;
-
-public class AbstractCatalogXmlTest extends AbstractYamlTest {
-
- private String catalogUrl;
-
- public AbstractCatalogXmlTest(String catalogUrl) {
- this.catalogUrl = catalogUrl;
- }
-
- @Override
- protected LocalManagementContext newTestManagementContext() {
- ResourceUtils ru = new ResourceUtils(this);
- File jar = createJar(ru);
- File catalog = createCatalog(ru, jar);
-
- BrooklynProperties properties = BrooklynProperties.Factory.newEmpty();
- properties.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL, catalog.toURI().toString());
- return LocalManagementContextForTests.builder(true)
- .useProperties(properties)
- .enableOsgiReusable()
- .build();
- }
-
- protected Entity startApp(String type) throws Exception {
- String yaml = "name: simple-app-yaml\n" +
- "location: localhost\n" +
- "services: \n" +
- " - type: " + type;
- return createAndStartApplication(yaml);
- }
-
- private File createCatalog(ResourceUtils ru, File tmpJar) {
- String catalogTemplate = ru.getResourceAsString(catalogUrl);
- String catalog = catalogTemplate.replace("${osgi-entities-path}", tmpJar.toURI().toString());
- File catalogTmp = Os.newTempFile("simple-catalog-", ".xml");
- copy(catalog, catalogTmp);
- return catalogTmp;
- }
-
- private File createJar(ResourceUtils ru) {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
- File tmpJar = Os.newTempFile("osgi-entities-", ".jar");
- InputStream in = ru.getResourceFromUrl("classpath://" + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
- copy(in, tmpJar);
- return tmpJar;
- }
-
- private void copy(String src, File dst) {
- try {
- copy(new ReaderInputStream(new StringReader(src), "UTF-8"), dst);
- } catch (Exception e) {
- throw Exceptions.propagate(e);
- }
- }
-
- private void copy(InputStream in, File tmpJar) {
- try {
- OutputStream out = new FileOutputStream(tmpJar);
- ByteStreams.copy(in, out);
- Streams.closeQuietly(in);
- Streams.closeQuietly(out);
- } catch (Exception e) {
- throw Exceptions.propagate(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogScanTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogScanTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogScanTest.java
new file mode 100644
index 0000000..f7dd66b
--- /dev/null
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogScanTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.catalog;
+
+import java.net.URLEncoder;
+import java.util.List;
+
+import org.apache.brooklyn.api.catalog.BrooklynCatalog;
+import org.apache.brooklyn.api.catalog.CatalogItem;
+import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherNoServer;
+import org.apache.brooklyn.core.catalog.CatalogPredicates;
+import org.apache.brooklyn.core.catalog.internal.MyCatalogItems.MySillyAppTemplate;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.server.BrooklynServerConfig;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.util.core.ResourceUtils;
+import org.apache.brooklyn.util.net.Urls;
+import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+public class CatalogScanTest {
+
+ // TODO setUp/tearDown copied from AbstractYamlTest
+
+ // Moved from brooklyn-core. When we deleted support for catalog.xml, the scanned catalog
+ // was then only stored in camp format, which meant we needed the camp parser.
+
+ private static final Logger log = LoggerFactory.getLogger(CatalogScanTest.class);
+
+ private BrooklynCatalog defaultCatalog, annotsCatalog, fullCatalog;
+
+ private List<LocalManagementContext> mgmts = Lists.newCopyOnWriteArrayList();
+ private List<BrooklynCampPlatformLauncherNoServer> launchers = Lists.newCopyOnWriteArrayList();
+
+ /** Override to enable OSGi in the management context for all tests in the class. */
+ protected boolean disableOsgi() {
+ return true;
+ }
+
+ protected boolean useDefaultProperties() {
+ return false;
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+ for (LocalManagementContext mgmt : mgmts) {
+ Entities.destroyAll(mgmt);
+ }
+ mgmts.clear();
+
+ for (BrooklynCampPlatformLauncherNoServer launcher : launchers) {
+ launcher.stopServers();
+ }
+ launchers.clear();
+ }
+
+ private LocalManagementContext newManagementContext(BrooklynProperties props) {
+ final LocalManagementContext localMgmt = LocalManagementContextForTests.builder(true)
+ .disableOsgi(disableOsgi())
+ .useProperties(props)
+ .build();
+ mgmts.add(localMgmt);
+
+ BrooklynCampPlatformLauncherNoServer launcher = new BrooklynCampPlatformLauncherNoServer() {
+ @Override
+ protected LocalManagementContext newMgmtContext() {
+ return localMgmt;
+ }
+ };
+ launchers.add(launcher);
+ launcher.launch();
+
+ return localMgmt;
+ }
+
+ private synchronized void loadTheDefaultCatalog(boolean lookOnDiskForDefaultCatalog) {
+ if (defaultCatalog!=null) return;
+ BrooklynProperties props = BrooklynProperties.Factory.newEmpty();
+ props.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL.getName(),
+ // if default catalog is picked up from the system, we might get random stuff from ~/.brooklyn/ instead of the default;
+ // useful as an integration check that we default correctly, but irritating for people to use if they have such a catalog installed
+ (lookOnDiskForDefaultCatalog ? "" :
+ "data:,"+Urls.encode(new ResourceUtils(this).getResourceAsString("classpath:/brooklyn/default.catalog.bom"))));
+ LocalManagementContext mgmt = newManagementContext(props);
+ defaultCatalog = mgmt.getCatalog();
+ log.info("ENTITIES loaded for DEFAULT: "+defaultCatalog.getCatalogItems(Predicates.alwaysTrue()));
+ }
+
+ @SuppressWarnings("deprecation")
+ private synchronized void loadAnnotationsOnlyCatalog() {
+ if (annotsCatalog!=null) return;
+ BrooklynProperties props = BrooklynProperties.Factory.newEmpty();
+ props.put(BrooklynServerConfig.BROOKLYN_CATALOG_URL.getName(),
+ "data:,"+URLEncoder.encode("brooklyn.catalog: {scanJavaAnnotations: true}"));
+ LocalManagementContext mgmt = newManagementContext(props);
+ annotsCatalog = mgmt.getCatalog();
+ log.info("ENTITIES loaded with annotation: "+annotsCatalog.getCatalogItems(Predicates.alwaysTrue()));
+ }
+
+ @Test
+ public void testLoadAnnotations() {
+ loadAnnotationsOnlyCatalog();
+ BrooklynCatalog c = annotsCatalog;
+
+ Iterable<CatalogItem<Object,Object>> bases = c.getCatalogItems(CatalogPredicates.displayName(Predicates.containsPattern("MyBaseEntity")));
+ Assert.assertEquals(Iterables.size(bases), 0, "should have been empty: "+bases);
+
+ Iterable<CatalogItem<Object,Object>> asdfjkls = c.getCatalogItems(CatalogPredicates.displayName(Predicates.containsPattern("__asdfjkls__shouldnotbefound")));
+ Assert.assertEquals(Iterables.size(asdfjkls), 0);
+
+ Iterable<CatalogItem<Object,Object>> silly1 = c.getCatalogItems(CatalogPredicates.displayName(Predicates.equalTo("MySillyAppTemplate")));
+ CatalogItem<Object, Object> silly1El = Iterables.getOnlyElement(silly1);
+
+ CatalogItem<Application,EntitySpec<? extends Application>> s1 = c.getCatalogItem(Application.class, silly1El.getSymbolicName(), silly1El.getVersion());
+ Assert.assertEquals(s1, silly1El);
+
+ Assert.assertEquals(s1.getDescription(), "Some silly app test");
+
+ Class<?> app = ((EntitySpec<?>)c.peekSpec(s1)).getImplementation();
+ Assert.assertEquals(app, MySillyAppTemplate.class);
+ }
+
+ @Test
+ public void testAnnotationLoadsSomeApps() {
+ loadAnnotationsOnlyCatalog();
+ Iterable<CatalogItem<Object,Object>> silly1 = annotsCatalog.getCatalogItems(CatalogPredicates.displayName(Predicates.equalTo("MySillyAppTemplate")));
+ Assert.assertEquals(Iterables.getOnlyElement(silly1).getDescription(), "Some silly app test");
+ }
+
+ @Test
+ public void testAnnotationLoadsSomeAppBuilders() {
+ loadAnnotationsOnlyCatalog();
+ Iterable<CatalogItem<Object,Object>> silly1 = annotsCatalog.getCatalogItems(CatalogPredicates.displayName(Predicates.equalTo("MySillyAppBuilderTemplate")));
+ Assert.assertEquals(Iterables.getOnlyElement(silly1).getDescription(), "Some silly app builder test");
+ }
+
+ @Test
+ public void testAnnotationIsDefault() {
+ doTestAnnotationIsDefault(false);
+ }
+
+ // see comment in load method; likely fails if a custom catalog is installed in ~/.brooklyn/
+ @Test(groups="Integration", enabled=false)
+ public void testAnnotationIsDefaultOnDisk() {
+ doTestAnnotationIsDefault(true);
+ }
+
+ private void doTestAnnotationIsDefault(boolean lookOnDiskForDefaultCatalog) {
+ loadTheDefaultCatalog(lookOnDiskForDefaultCatalog);
+ Iterable<CatalogItem<Object, Object>> defaults = defaultCatalog.getCatalogItems(Predicates.alwaysTrue());
+ int numInDefault = Iterables.size(defaults);
+
+ loadAnnotationsOnlyCatalog();
+ Iterable<CatalogItem<Object, Object>> annotatedItems = annotsCatalog.getCatalogItems(Predicates.alwaysTrue());
+ int numFromAnnots = Iterables.size(annotatedItems);
+
+ Assert.assertEquals(numInDefault, numFromAnnots, "defaults="+defaults+"; annotatedItems="+annotatedItems);
+ Assert.assertTrue(numInDefault>0, "Expected more than 0 entries");
+ }
+
+ // a simple test asserting no errors when listing the real catalog, and listing them for reference
+ // also useful to test variants in a stored catalog to assert they all load
+ // TODO integration tests which build up catalogs assuming other things are installed
+ @Test
+ public void testListCurrentCatalogItems() {
+ LocalManagementContext mgmt = newManagementContext(BrooklynProperties.Factory.newDefault());
+ log.info("ITEMS\n"+Strings.join(mgmt.getCatalog().getCatalogItems(), "\n"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
deleted file mode 100644
index 2161fec..0000000
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.catalog;
-
-import org.testng.annotations.Test;
-
-public class CatalogXmlOsgiTest extends AbstractCatalogXmlTest {
-
- public CatalogXmlOsgiTest(String catalogUrl) {
- super("classpath://osgi-catalog.xml");
- }
-
- @Test
- public void testOsgiItem() throws Exception {
- startApp("OsgiApp");
- // previously OSGi libraries were not supported with old-style catalog items;
- // now they are (2015-10), even though the XML is not supported,
- // we may use the same type instantiator from CAMP and elsewhere
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
deleted file mode 100644
index b47bf76..0000000
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlVersionTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.catalog;
-
-import static org.testng.Assert.assertTrue;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-public class CatalogXmlVersionTest extends AbstractCatalogXmlTest {
-
- public CatalogXmlVersionTest(String catalogUrl) {
- super("classpath://simple-catalog.xml");
- }
-
- @DataProvider(name = "types")
- public Object[][] createTypes() {
- return new Object[][] {
- {"org.apache.brooklyn.entity.stock.BasicApplication"},
- {"org.apache.brooklyn.entity.stock.BasicApplication:0.0.0.SNAPSHOT"},
- {"org.apache.brooklyn.entity.stock.BasicApplication:2.0"},
- {"BasicApp"}, // test that items with symbolicName not matching the type work
- {"BasicApp:0.0.0.SNAPSHOT"},
- {"BasicApp:2.0"},
- {"org.apache.brooklyn.test.osgi.entities.SimpleApplication"}, //test that classpath is used
- };
- }
-
- @Test(dataProvider = "types")
- public void testXmlCatalogItem(String type) throws Exception {
- startApp(type);
- }
-
- @Test
- public void testJavaPrefixDoesNotLoadXMLCatalogItem() throws Exception {
- Entity entity = startApp("java:org.apache.brooklyn.camp.brooklyn.catalog.TestBasicApp");
- assertTrue(entity instanceof TestBasicApp, "Entity is not a " + TestBasicApp.class.getName() + ", instead the type is " + entity.getEntityType().getName());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
index 1257b3e..68c7fed 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
@@ -191,30 +191,6 @@ public class CampYamlLiteTest {
assertMgmtHasSampleMyCatalogApp(symbolicName, bundleUrl);
}
- @SuppressWarnings("deprecation")
- @Test
- public void testResetXmlWithCustomEntity() throws IOException {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
-
- String symbolicName = "my.catalog.app.id";
- String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL;
- String yaml = getSampleMyCatalogAppYaml(symbolicName, bundleUrl);
-
- LocalManagementContext mgmt2 = LocalManagementContextForTests.newInstanceWithOsgi();
- try {
- CampPlatformWithJustBrooklynMgmt platform2 = new CampPlatformWithJustBrooklynMgmt(mgmt2);
- MockWebPlatform.populate(platform2, TestAppAssemblyInstantiator.class);
-
- mgmt2.getCatalog().addItems(yaml);
- String xml = ((BasicBrooklynCatalog) mgmt2.getCatalog()).toXmlString();
- ((BasicBrooklynCatalog) mgmt.getCatalog()).reset(CatalogDto.newDtoFromXmlContents(xml, "copy of temporary catalog"));
- } finally {
- mgmt2.terminate();
- }
-
- assertMgmtHasSampleMyCatalogApp(symbolicName, bundleUrl);
- }
-
private String getSampleMyCatalogAppYaml(String symbolicName, String bundleUrl) {
return Joiner.on("\n").join(
"brooklyn.catalog:",
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/resources/osgi-catalog.xml
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/resources/osgi-catalog.xml b/camp/camp-brooklyn/src/test/resources/osgi-catalog.xml
deleted file mode 100644
index 0586f3b..0000000
--- a/camp/camp-brooklyn/src/test/resources/osgi-catalog.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<catalog>
- <name>OSGi catalogue</name>
- <template name="Osgi App" type="org.apache.brooklyn.test.osgi.entities.SimpleApplication">
- <symbolicName>OsgiApp</symbolicName>
- <libraries>
- <bundle>${osgi-entities-path}</bundle>
- </libraries>
- </template>
-</catalog>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/camp/camp-brooklyn/src/test/resources/simple-catalog.xml
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/resources/simple-catalog.xml b/camp/camp-brooklyn/src/test/resources/simple-catalog.xml
deleted file mode 100644
index 8b73ffa..0000000
--- a/camp/camp-brooklyn/src/test/resources/simple-catalog.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<catalog>
- <name>Simple catalogue</name>
- <template name="Basic App" type="org.apache.brooklyn.entity.stock.BasicApplication" />
- <template name="Basic App" type="org.apache.brooklyn.entity.stock.BasicApplication" version="2.0" />
- <template name="Basic App" type="org.apache.brooklyn.entity.stock.BasicApplication">
- <symbolicName>BasicApp</symbolicName>
- </template>
- <template name="Basic App" type="org.apache.brooklyn.entity.stock.BasicApplication" version="2.0">
- <symbolicName>BasicApp</symbolicName>
- </template>
- <template name="Custom App" type="org.apache.brooklyn.entity.stock.BasicApplication">
- <symbolicName>org.apache.brooklyn.camp.brooklyn.catalog.TestBasicApp</symbolicName>
- <!-- Tests that "java:" prefix won't load an old-style catalog item with the same id -->
- </template>
- <template name="Osgi App" type="org.apache.brooklyn.test.osgi.entities.SimpleApplication">
- <symbolicName>OsgiApp</symbolicName>
- <libraries>
- <bundle>${osgi-entities-path}</bundle>
- </libraries>
- </template>
- <catalog>
- <template name="Simple App" type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" />
- <classpath>
- <entry>${osgi-entities-path}</entry>
- </classpath>
- </catalog>
-</catalog>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogPredicates.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogPredicates.java b/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogPredicates.java
index 576aa6b..6232c77 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogPredicates.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/CatalogPredicates.java
@@ -18,6 +18,10 @@
*/
package org.apache.brooklyn.core.catalog;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.StringWriter;
+
import javax.annotation.Nullable;
import org.apache.brooklyn.api.catalog.CatalogItem;
@@ -28,16 +32,25 @@ import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.location.LocationSpec;
import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.api.mgmt.rebind.mementos.Memento;
import org.apache.brooklyn.api.policy.Policy;
import org.apache.brooklyn.api.policy.PolicySpec;
import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import org.apache.brooklyn.core.mgmt.persist.XmlMementoSerializer;
+import org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
public class CatalogPredicates {
+ private static final Logger LOG = LoggerFactory.getLogger(CatalogPredicates.class);
+
public static <T,SpecT> Predicate<CatalogItem<T,SpecT>> isCatalogItemType(final CatalogItemType ciType) {
// TODO PERSISTENCE WORKAROUND kept anonymous function in case referenced in persisted state
new Predicate<CatalogItem<T,SpecT>>() {
@@ -261,29 +274,69 @@ public class CatalogPredicates {
}
}
- public static <T,SpecT> Predicate<CatalogItem<T,SpecT>> xml(final Predicate<? super String> filter) {
+ public static <T,SpecT> Predicate<CatalogItem<T,SpecT>> stringRepresentationMatches(final Predicate<? super String> filter) {
+ // TODO Previously the impl relied on catalogItem.toXmlString() to get a string
+ // representation, which the filter could then be applied to. We've deleted that
+ // (as part of deleting support for ~/.brooklyn/catalog.xml, which was deprecated
+ // back in 0.7.0).
+ // Now we piggy-back off the persistence serialization. However, we really don't
+ // want to let users rely on that! We'll presumably swap out the string representation
+ // at some point in the future.
+ return new StringRepresentationMatches<>(checkNotNull(filter, "filter"));
+ }
+ private static class StringRepresentationMatches<T, SpecT> implements Predicate<CatalogItem<T,SpecT>> {
+ private final Predicate<? super String> filter;
+ StringRepresentationMatches(final Predicate<? super String> filter) {
+ this.filter = filter;
+ }
+ @Override
+ public boolean apply(@Nullable CatalogItem<T,SpecT> item) {
+ try {
+ Memento memento = MementosGenerators.newBasicMemento(item);
+ XmlMementoSerializer<CatalogItem<?,?>> serializer = new XmlMementoSerializer<CatalogItem<?,?>>(
+ CatalogPredicates.class.getClassLoader(),
+ ImmutableMap.<String,String>of());
+ StringWriter writer = new StringWriter();
+ serializer.serialize(memento, writer);
+ return filter.apply(writer.toString());
+ } catch (Exception e) {
+ // If we propagated exceptions, then we'd risk aborting the checks for other catalog items.
+ // Play it safe, in case there's something messed up with just one catalog item.
+ Exceptions.propagateIfFatal(e);
+ LOG.debug("Problem producing string representation of "+item+"; assuming no match, and continuing", e);
+ return false;
+ }
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private static <T,SpecT> Predicate<CatalogItem<T,SpecT>> xml(final Predicate<? super String> filter) {
// TODO PERSISTENCE WORKAROUND kept anonymous function in case referenced in persisted state
new Predicate<CatalogItem<T,SpecT>>() {
@Override
public boolean apply(@Nullable CatalogItem<T,SpecT> item) {
- return (item != null) && filter.apply(item.toXmlString());
+ throw new IllegalStateException();
}
};
- return new XmlMatches<T,SpecT>(filter);
+ throw new UnsupportedOperationException();
}
/**
* @since 0.8.0
+ * @deprecated since 0.11.0 (should have been 0.7.0, when catalog.xml was deprecated!)
+ *
+ * TODO Kept for backwards compatibility, in case it is reference in customer persisted state.
*/
+ @SuppressWarnings("unused")
private static class XmlMatches<T,SpecT> implements Predicate<CatalogItem<T,SpecT>> {
private final Predicate<? super String> filter;
public XmlMatches(Predicate<? super String> filter) {
- this.filter = filter;
+ throw new IllegalStateException();
}
@Override
public boolean apply(@Nullable CatalogItem<T,SpecT> item) {
- return (item != null) && filter.apply(item.toXmlString());
+ throw new IllegalStateException();
}
@Override
public String toString() {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index 2634ecf..31b6ce5 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -1180,18 +1180,6 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
};
}
- transient CatalogXmlSerializer serializer;
-
- public String toXmlString() {
- if (serializer==null) loadSerializer();
- return serializer.toString(catalog.dto);
- }
-
- private synchronized void loadSerializer() {
- if (serializer==null)
- serializer = new CatalogXmlSerializer();
- }
-
private static class SpecCache {
private final Map<String, AbstractBrooklynObjectSpec<?,?>> cache = Collections.synchronizedMap(
Maps.<String, AbstractBrooklynObjectSpec<?,?>>newLinkedHashMap());
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleConverter.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleConverter.java
deleted file mode 100644
index 79b39c3..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogBundleConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.core.catalog.internal;
-
-import com.thoughtworks.xstream.converters.Converter;
-import com.thoughtworks.xstream.converters.MarshallingContext;
-import com.thoughtworks.xstream.converters.UnmarshallingContext;
-import com.thoughtworks.xstream.converters.reflection.ReflectionConverter;
-import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
-import com.thoughtworks.xstream.io.HierarchicalStreamReader;
-import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
-import com.thoughtworks.xstream.mapper.Mapper;
-
-
-/**
- * Convert old-style catalog.xml file formats to the latest version.
- * The code is needed only during transition to the new version, can be removed after a while.
- */
-@Deprecated
-public class CatalogBundleConverter implements Converter {
-
- private ReflectionConverter delegateConverter;
-
- public CatalogBundleConverter(Mapper mapper, ReflectionProvider reflectionProvider) {
- this.delegateConverter = new ReflectionConverter(mapper, reflectionProvider);
- }
-
- @Override
- public boolean canConvert(@SuppressWarnings("rawtypes") Class type) {
- return type == CatalogBundleDto.class;
- }
-
- @Override
- public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
- context.convertAnother(source, delegateConverter);
- }
-
- @Override
- public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
- if (reader.hasMoreChildren()) {
- return context.convertAnother(context.currentObject(), CatalogBundleDto.class, delegateConverter);
- } else {
- return new CatalogBundleDto(null, null, reader.getValue());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogClasspathDo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogClasspathDo.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogClasspathDo.java
index d183c7e..c41eed9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogClasspathDo.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogClasspathDo.java
@@ -166,9 +166,8 @@ public class CatalogClasspathDo {
Stopwatch timer = Stopwatch.createStarted();
ReflectionScanner scanner = null;
- if (!catalog.isLocal()) {
- log.warn("Scanning not supported for remote catalogs; ignoring scan request in "+catalog);
- } else if (classpath.getEntries() == null || classpath.getEntries().isEmpty()) {
+
+ if (classpath.getEntries() == null || classpath.getEntries().isEmpty()) {
// scan default classpath:
ClassLoader baseCL = null;
Iterable<URL> baseCP = null;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDo.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDo.java
index f30803e..4852929 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDo.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDo.java
@@ -30,7 +30,6 @@ import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.javalang.AggregateClassLoader;
-import org.apache.brooklyn.util.net.Urls;
import org.apache.brooklyn.util.time.CountdownTimer;
import org.apache.brooklyn.util.time.Duration;
import org.slf4j.Logger;
@@ -110,7 +109,6 @@ public class CatalogDo {
log.warn("Catalog "+this+" being initialised with different mgmt "+mgmt+" when already managed by "+this.mgmt, new Throwable("source of reparented "+this));
this.parent = parent;
this.mgmt = mgmt;
- dto.populate();
loadCatalogClasspath();
loadCatalogItems(failOnLoadError);
isLoaded = true;
@@ -312,18 +310,6 @@ public class CatalogDo {
return "Loaded:" + dto + "(" + size + ")";
}
- /** is "local" if it and all ancestors are not based on any remote urls */
- public boolean isLocal() {
- if (dto.url != null) {
- String proto = Urls.getProtocol(dto.url);
- if (proto != null) {
- // 'file' is the only protocol accepted as "local"
- if (!"file".equals(proto)) return false;
- }
- }
- return parent == null || parent.isLocal();
- }
-
/** classloader for only the entries in this catalog's classpath */
public ClassLoader getLocalClassLoader() {
if (classpath != null) return classpath.getLocalClassLoader();
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDto.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDto.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDto.java
index 1047488..14b9fea 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDto.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDto.java
@@ -18,21 +18,15 @@
*/
package org.apache.brooklyn.core.catalog.internal;
-import java.io.InputStream;
-import java.io.StringReader;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.brooklyn.api.catalog.CatalogItem;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
-import org.apache.brooklyn.util.stream.Streams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
@@ -42,11 +36,10 @@ import com.google.common.collect.Lists;
@Beta
public class CatalogDto {
+ @SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(CatalogDto.class);
String id;
- String url;
- String contents;
String contentsDescription;
String name;
String description;
@@ -64,36 +57,6 @@ public class CatalogDto {
return result.dto;
}
- /** @deprecated since 0.7.0 use {@link #newDtoFromXmlUrl(String)} if you must, but note the xml format itself is deprecated */
- @Deprecated
- public static CatalogDto newDtoFromUrl(String url) {
- return newDtoFromXmlUrl(url);
- }
-
- /** @deprecated since 0.7.0 the xml format is deprecated; use YAML parse routines on BasicBrooklynCatalog */
- @Deprecated
- public static CatalogDto newDtoFromXmlUrl(String url) {
- if (LOG.isDebugEnabled()) LOG.debug("Retrieving catalog from: {}", url);
- try {
- InputStream source = ResourceUtils.create().getResourceFromUrl(url);
- String contents = Streams.readFullyStringAndClose(source);
- return newDtoFromXmlContents(contents, url);
- } catch (Throwable t) {
- Exceptions.propagateIfFatal(t);
- throw new PropagatedRuntimeException("Unable to retrieve catalog from " + url + ": " + t, t);
- }
- }
-
- /** @deprecated since 0.7.0 the xml format is deprecated; use YAML parse routines on BasicBrooklynCatalog */
- @Deprecated
- public static CatalogDto newDtoFromXmlContents(String xmlContents, String originDescription) {
- CatalogDto result = (CatalogDto) new CatalogXmlSerializer().deserialize(new StringReader(xmlContents));
- result.contentsDescription = originDescription;
-
- if (LOG.isDebugEnabled()) LOG.debug("Retrieved catalog from: {}", originDescription);
- return result;
- }
-
/**
* Creates a DTO.
* <p>
@@ -122,13 +85,6 @@ public class CatalogDto {
return result;
}
- public static CatalogDto newLinkedInstance(String url) {
- CatalogDto result = new CatalogDto();
- result.contentsDescription = url;
- result.contents = ResourceUtils.create().getResourceAsString(url);
- return result;
- }
-
/** @deprecated since 0.7.0 use {@link #newDtoFromCatalogItems(Collection, String)}, supplying a description for tracking */
@Deprecated
public static CatalogDto newDtoFromCatalogItems(Collection<CatalogItem<?, ?>> entries) {
@@ -147,46 +103,6 @@ public class CatalogDto {
return result;
}
- void populate() {
- if (contents==null) {
- if (url != null) {
- contents = ResourceUtils.create().getResourceAsString(url);
- contentsDescription = url;
- } else if (contentsDescription==null) {
- LOG.debug("Catalog DTO has no contents and no description; ignoring call to populate it. Description should be set to suppress this message.");
- return;
- } else {
- LOG.trace("Nothing needs doing (no contents or URL) for catalog with contents described as "+contentsDescription+".");
- return;
- }
- }
-
- CatalogDto remoteDto = newDtoFromXmlContents(contents, contentsDescription);
- try {
- copyFrom(remoteDto, true);
- } catch (Exception e) {
- Exceptions.propagate(e);
- }
- }
-
- /**
- * @throws NullPointerException If source is null (and !skipNulls)
- */
- void copyFrom(CatalogDto source, boolean skipNulls) throws IllegalAccessException {
- if (source==null) {
- if (skipNulls) return;
- throw new NullPointerException("source DTO is null, when copying to "+this);
- }
-
- if (!skipNulls || source.id != null) id = source.id;
- if (!skipNulls || source.contentsDescription != null) contentsDescription = source.contentsDescription;
- if (!skipNulls || source.contents != null) contents = source.contents;
- if (!skipNulls || source.name != null) name = source.name;
- if (!skipNulls || source.description != null) description = source.description;
- if (!skipNulls || source.classpath != null) classpath = source.classpath;
- if (!skipNulls || source.entries != null) entries = source.entries;
- }
-
@Override
public String toString() {
return Objects.toStringHelper(this)
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoUtils.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoUtils.java
deleted file mode 100644
index 93a5cc1..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoUtils.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.core.catalog.internal;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.apache.brooklyn.core.catalog.internal.CatalogClasspathDo.CatalogScanningModes;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CatalogDtoUtils {
-
- private static final Logger log = LoggerFactory.getLogger(CatalogDtoUtils.class);
-
- public static CatalogDto newDefaultLocalScanningDto(CatalogScanningModes scanMode) {
- return CatalogDto.newDefaultLocalScanningDto(scanMode);
- }
-
- /** throws if there are any problems in retrieving or copying */
- public static void populateFromUrl(CatalogDto dto, String url) {
- CatalogDto remoteDto = newDtoFromUrl(url);
- try {
- copyDto(remoteDto, dto, true);
- } catch (Exception e) {
- Exceptions.propagate(e);
- }
- }
-
- /** does a shallow copy.
- * "skipNulls" means not to copy any fields from the source which are null */
- static void copyDto(CatalogDto source, CatalogDto target, boolean skipNulls) throws IllegalArgumentException, IllegalAccessException {
- target.copyFrom(source, skipNulls);
- }
-
- public static CatalogDto newDtoFromUrl(String url) {
- if (log.isDebugEnabled()) log.debug("Retrieving catalog from: {}", url);
- try {
- InputStream source = ResourceUtils.create().getResourceFromUrl(url);
- CatalogDto result = (CatalogDto) new CatalogXmlSerializer().deserialize(new InputStreamReader(source));
- if (log.isDebugEnabled()) log.debug("Retrieved catalog from: {}", url);
- return result;
- } catch (Throwable t) {
- log.debug("Unable to retrieve catalog from: "+url+" ("+t+")");
- throw Exceptions.propagate(t);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
index 95e593f..45e7e7a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java
@@ -60,11 +60,10 @@ public class CatalogInitialization implements ManagementContextInjectable {
A4) go to B1
B1) look for --catalog-initial, if so read it, then go to C1
- B2) look for BrooklynServerConfig.BROOKLYN_CATALOG_URL, if so, read it, supporting YAML or XML (warning if XML), then go to C1
+ B2) look for BrooklynServerConfig.BROOKLYN_CATALOG_URL, if so, read it, supporting YAML, then go to C1
B3) look for ~/.brooklyn/catalog.bom, if exists, read it then go to C1
- B4) look for ~/.brooklyn/brooklyn.xml, if exists, warn, read it then go to C1
- B5) read all classpath://brooklyn/default.catalog.bom items, if they exist (and for now they will)
- B6) go to C1
+ B4) read all classpath://brooklyn/default.catalog.bom items, if they exist (and for now they will)
+ B5) go to C1
C1) if --catalog-add, read and add those items
@@ -238,8 +237,6 @@ public class CatalogInitialization implements ManagementContextInjectable {
}
}
- private enum PopulateMode { YAML, XML, AUTODETECT }
-
protected void populateInitial(BasicBrooklynCatalog catalog) {
if (disallowLocal) {
if (!hasRunFinalInitialization()) {
@@ -249,35 +246,28 @@ public class CatalogInitialization implements ManagementContextInjectable {
}
// B1) look for --catalog-initial, if so read it, then go to C1
-// B2) look for BrooklynServerConfig.BROOKLYN_CATALOG_URL, if so, read it, supporting YAML or XML (warning if XML), then go to C1
+// B2) look for BrooklynServerConfig.BROOKLYN_CATALOG_URL, if so, read it, supporting YAML, then go to C1
// B3) look for ~/.brooklyn/catalog.bom, if exists, read it then go to C1
-// B4) look for ~/.brooklyn/brooklyn.xml, if exists, warn, read it then go to C1
-// B5) read all classpath://brooklyn/default.catalog.bom items, if they exist (and for now they will)
-// B6) go to C1
+// B4) read all classpath://brooklyn/default.catalog.bom items, if they exist (and for now they will)
+// B5) go to C1
if (initialUri!=null) {
- populateInitialFromUri(catalog, initialUri, PopulateMode.AUTODETECT);
+ populateInitialFromUri(catalog, initialUri);
return;
}
String catalogUrl = managementContext.getConfig().getConfig(BrooklynServerConfig.BROOKLYN_CATALOG_URL);
if (Strings.isNonBlank(catalogUrl)) {
- populateInitialFromUri(catalog, catalogUrl, PopulateMode.AUTODETECT);
+ populateInitialFromUri(catalog, catalogUrl);
return;
}
catalogUrl = Os.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.bom");
if (new File(catalogUrl).exists()) {
- populateInitialFromUri(catalog, new File(catalogUrl).toURI().toString(), PopulateMode.YAML);
+ populateInitialFromUri(catalog, new File(catalogUrl).toURI().toString());
return;
}
- catalogUrl = Os.mergePaths(BrooklynServerConfig.getMgmtBaseDir( managementContext.getConfig() ), "catalog.xml");
- if (new File(catalogUrl).exists()) {
- populateInitialFromUri(catalog, new File(catalogUrl).toURI().toString(), PopulateMode.XML);
- return;
- }
-
// otherwise look for for classpath:/brooklyn/default.catalog.bom --
// there is one on the classpath which says to scan, and provides a few templates;
// if one is supplied by user in the conf/ dir that will override the item from the classpath
@@ -285,7 +275,7 @@ public class CatalogInitialization implements ManagementContextInjectable {
catalogUrl = "classpath:/brooklyn/default.catalog.bom";
if (new ResourceUtils(this).doesUrlExist(catalogUrl)) {
- populateInitialFromUri(catalog, catalogUrl, PopulateMode.YAML);
+ populateInitialFromUri(catalog, catalogUrl);
return;
}
@@ -293,59 +283,20 @@ public class CatalogInitialization implements ManagementContextInjectable {
return;
}
- private void populateInitialFromUri(BasicBrooklynCatalog catalog, String catalogUrl, PopulateMode mode) {
+ private void populateInitialFromUri(BasicBrooklynCatalog catalog, String catalogUrl) {
log.debug("Loading initial catalog from {}", catalogUrl);
- Exception problem = null;
- Object result = null;
-
- String contents = null;
try {
- contents = new ResourceUtils(this).getResourceAsString(catalogUrl);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- if (problem==null) problem = e;
- }
+ String contents = new ResourceUtils(this).getResourceAsString(catalogUrl);
- if (contents!=null && (mode==PopulateMode.YAML || mode==PopulateMode.AUTODETECT)) {
- // try YAML first
- try {
- catalog.reset(MutableList.<CatalogItem<?,?>>of());
- result = catalog.addItems(contents);
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- if (problem==null) problem = e;
- }
- }
-
- if (result==null && contents!=null && (mode==PopulateMode.XML || mode==PopulateMode.AUTODETECT)) {
- // then try XML
- try {
- populateInitialFromUriXml(catalog, catalogUrl, contents);
- // clear YAML problem
- problem = null;
- } catch (Exception e) {
- Exceptions.propagateIfFatal(e);
- if (problem==null) problem = e;
- }
- }
-
- if (result!=null) {
+ catalog.reset(MutableList.<CatalogItem<?,?>>of());
+ Object result = catalog.addItems(contents);
+
log.debug("Loaded initial catalog from {}: {}", catalogUrl, result);
- }
- if (problem!=null) {
- log.warn("Error importing catalog from " + catalogUrl + ": " + problem, problem);
- // TODO inform mgmt of error
- }
-
- }
-
- // deprecated XML format
- @SuppressWarnings("deprecation")
- private void populateInitialFromUriXml(BasicBrooklynCatalog catalog, String catalogUrl, String contents) {
- CatalogDto dto = CatalogDto.newDtoFromXmlContents(contents, catalogUrl);
- if (dto!=null) {
- catalog.reset(dto);
+
+ } catch (Exception e) {
+ Exceptions.propagateIfFatal(e);
+ log.warn("Error importing catalog from " + catalogUrl + ": " + e, e);
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDo.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDo.java
index 90697fe..7e8a956 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDo.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDo.java
@@ -231,11 +231,6 @@ public class CatalogItemDo<T,SpecT> implements CatalogItem<T,SpecT>, BrooklynObj
}
@Override
- public String toXmlString() {
- return itemDto.toXmlString();
- }
-
- @Override
public Class<SpecT> getSpecType() {
return itemDto.getSpecType();
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java
index 5aec768..1201395 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogItemDtoAbstract.java
@@ -232,20 +232,6 @@ public abstract class CatalogItemDtoAbstract<T, SpecT> extends AbstractBrooklynO
@Override
public abstract Class<SpecT> getSpecType();
- transient CatalogXmlSerializer serializer;
-
- @Override
- public String toXmlString() {
- if (serializer==null) loadSerializer();
- return serializer.toString(this);
- }
-
- private synchronized void loadSerializer() {
- if (serializer == null) {
- serializer = new CatalogXmlSerializer();
- }
- }
-
@Override
public RebindSupport<CatalogItemMemento> getRebindSupport() {
return new BasicCatalogItemRebindSupport(this);
@@ -385,10 +371,6 @@ public abstract class CatalogItemDtoAbstract<T, SpecT> extends AbstractBrooklynO
this.tags = tags;
}
- protected void setSerializer(CatalogXmlSerializer serializer) {
- this.serializer = serializer;
- }
-
/**
* Parses an instance of CatalogLibrariesDto from the given List. Expects the list entries
* to be either Strings or Maps of String -> String. Will skip items that are not.
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogXmlSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogXmlSerializer.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogXmlSerializer.java
deleted file mode 100644
index 42381e6..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogXmlSerializer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.core.catalog.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.core.catalog.internal.CatalogClasspathDo.CatalogScanningModes;
-import org.apache.brooklyn.core.mgmt.persist.DeserializingClassRenamesProvider;
-import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
-import org.apache.brooklyn.util.core.xstream.EnumCaseForgivingSingleValueConverter;
-import org.apache.brooklyn.util.core.xstream.XmlSerializer;
-
-public class CatalogXmlSerializer extends XmlSerializer<Object> {
-
- @SuppressWarnings("deprecation")
- public CatalogXmlSerializer() {
- super(DeserializingClassRenamesProvider.INSTANCE.loadDeserializingMapping());
-
- xstream.addDefaultImplementation(ArrayList.class, Collection.class);
-
- //Doesn't work well for non-standard lists, like Lists.transform results
- xstream.aliasType("list", List.class);
- xstream.aliasType("map", Map.class);
-
- xstream.useAttributeFor("id", String.class);
-
- xstream.aliasType("catalog", CatalogDto.class);
- xstream.useAttributeFor(CatalogDto.class, "url");
- xstream.addImplicitCollection(CatalogDto.class, "catalogs", CatalogDto.class);
- xstream.addImplicitCollection(CatalogDto.class, "entries", CatalogTemplateItemDto.class);
- xstream.addImplicitCollection(CatalogDto.class, "entries", CatalogEntityItemDto.class);
- xstream.addImplicitCollection(CatalogDto.class, "entries", CatalogPolicyItemDto.class);
- xstream.addImplicitCollection(CatalogDto.class, "entries", CatalogLocationItemDto.class);
-
- xstream.aliasType("template", CatalogTemplateItemDto.class);
- xstream.aliasType("entity", CatalogEntityItemDto.class);
- xstream.aliasType("policy", CatalogPolicyItemDto.class);
- xstream.aliasType("location", CatalogPolicyItemDto.class);
-
- xstream.aliasField("registeredType", CatalogItemDtoAbstract.class, "symbolicName");
- xstream.aliasAttribute(CatalogItemDtoAbstract.class, "displayName", "name");
- xstream.useAttributeFor(CatalogItemDtoAbstract.class, "type");
- xstream.useAttributeFor(CatalogItemDtoAbstract.class, "version");
- xstream.aliasType("bundle", CatalogBundleDto.class);
- xstream.registerConverter(new CatalogBundleConverter(xstream.getMapper(), xstream.getReflectionProvider()));
-
- xstream.useAttributeFor(CatalogClasspathDto.class, "scan");
- xstream.addImplicitCollection(CatalogClasspathDto.class, "entries", "entry", String.class);
- xstream.registerConverter(new EnumCaseForgivingSingleValueConverter(CatalogScanningModes.class));
-
- // Note: the management context is being omitted because it is unnecessary for
- // representations of catalogues generated with this serializer.
- xstream.omitField(AbstractBrooklynObject.class, "managementContext");
- xstream.omitField(AbstractBrooklynObject.class, "_legacyConstruction");
- xstream.omitField(AbstractBrooklynObject.class, "hasWarnedOfNoManagementContextWhenPersistRequested");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/catalog/internal/JavaCatalogToSpecTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/JavaCatalogToSpecTransformer.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/JavaCatalogToSpecTransformer.java
index 4e4fcb0..41d6d71 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/JavaCatalogToSpecTransformer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/JavaCatalogToSpecTransformer.java
@@ -42,8 +42,7 @@ import org.slf4j.LoggerFactory;
* defines the java class name and OSGi bundles to use.
* <p>
* This is used where a {@link RegisteredType} is defined simply with the name of a java class
- * (no YAML etc); and for legacy old-style (c0.7.0) catalog items (defined in catalog.xml only)
- * with structure, only a single type.
+ * (no YAML etc).
*/
public class JavaCatalogToSpecTransformer implements PlanToSpecTransformer {
private static final Logger log = LoggerFactory.getLogger(JavaCatalogToSpecTransformer.class);
@@ -76,7 +75,11 @@ public class JavaCatalogToSpecTransformer implements PlanToSpecTransformer {
@SuppressWarnings("deprecation")
String javaType = item.getJavaType();
if (javaType != null) {
- log.warn("Deprecated functionality (since 0.9.0). Using old-style xml catalog items with java type attribute for " + item);
+ // TODO This log.warn previously said "Using old-style xml catalog items with java type attribute".
+ // However, nothing in this code is specific to catalog.xml. Perhaps that is the only way this code
+ // can be reached? We should investigate further when we have time - if we can confirm it was only
+ // used for catalog.xml, then this can be deleted.
+ log.warn("Deprecated functionality (since 0.9.0). Using old-style java type attribute for " + item);
Class<?> type;
try {
// java types were deprecated before we added osgi support so this isn't necessary,
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/java/org/apache/brooklyn/core/server/BrooklynServerConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/server/BrooklynServerConfig.java b/core/src/main/java/org/apache/brooklyn/core/server/BrooklynServerConfig.java
index 26d76dc..da5922e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/server/BrooklynServerConfig.java
+++ b/core/src/main/java/org/apache/brooklyn/core/server/BrooklynServerConfig.java
@@ -98,7 +98,7 @@ public class BrooklynServerConfig {
+ "this key is DEPRECATED in favor of promotion and demotion specific flags now defaulting to true");
public static final ConfigKey<String> BROOKLYN_CATALOG_URL = ConfigKeys.newStringConfigKey("brooklyn.catalog.url",
- "The URL of a custom catalog.bom or catalog.xml descriptor to load");
+ "The URL of a custom catalog.bom to load");
/** @deprecated since 0.7.0 replaced by {@link CatalogInitialization}; also note, default removed
* (it was overridden anyway, and in almost all cases the new behaviour is still the default behaviour) */
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/main/resources/brooklyn-catalog-empty.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/brooklyn-catalog-empty.xml b/core/src/main/resources/brooklyn-catalog-empty.xml
deleted file mode 100644
index 898b498..0000000
--- a/core/src/main/resources/brooklyn-catalog-empty.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<catalog/>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoTest.java b/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoTest.java
index 228c922..afcdda7 100644
--- a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogDtoTest.java
@@ -21,22 +21,7 @@ package org.apache.brooklyn.core.catalog.internal;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import org.apache.brooklyn.api.catalog.CatalogItem.CatalogBundle;
-import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
-import org.apache.brooklyn.core.catalog.internal.CatalogBundleDto;
-import org.apache.brooklyn.core.catalog.internal.CatalogDo;
-import org.apache.brooklyn.core.catalog.internal.CatalogDto;
-import org.apache.brooklyn.core.catalog.internal.CatalogEntityItemDto;
-import org.apache.brooklyn.core.catalog.internal.CatalogItemBuilder;
-import org.apache.brooklyn.core.catalog.internal.CatalogItemDo;
-import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
-import org.apache.brooklyn.core.catalog.internal.CatalogXmlSerializer;
import org.apache.brooklyn.core.catalog.internal.CatalogClasspathDo.CatalogScanningModes;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.mgmt.BrooklynTags;
@@ -47,6 +32,12 @@ import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.util.core.BrooklynMavenArtifacts;
import org.apache.brooklyn.util.maven.MavenRetriever;
import org.apache.commons.lang3.ClassUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@@ -72,20 +63,8 @@ public class CatalogDtoTest {
checkCatalogHealthy(root);
}
- @Test(groups="Integration")
- public void testCatalogSerializeAndLookup() {
- CatalogDto root = buildExampleCatalog();
- CatalogXmlSerializer serializer = new CatalogXmlSerializer();
-
- String xml = serializer.toString(root);
- log.info("Example catalog serialized as:\n"+xml);
-
- CatalogDto root2 = (CatalogDto) serializer.fromString(xml);
- checkCatalogHealthy(root2);
- }
-
protected void checkCatalogHealthy(CatalogDto root) {
- assertEquals(root.catalogs.size(), 4);
+ assertEquals(root.catalogs.size(), 3, "dtos="+root.catalogs);
CatalogDo loader = new CatalogDo(managementContext, root).load();
// test app comes from jar, by default
@@ -142,7 +121,6 @@ public class CatalogDtoTest {
testEntitiesJavaCatalog.addEntry(osgiEntity);
root.addCatalog(osgiCatalog.dto);
- root.addCatalog(CatalogDto.newLinkedInstance("classpath://brooklyn-catalog-empty.xml"));
return root.dto;
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0feddb7/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogLoadTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogLoadTest.java b/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogLoadTest.java
deleted file mode 100644
index d1862a6..0000000
--- a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/CatalogLoadTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.core.catalog.internal;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.catalog.CatalogItem.CatalogBundle;
-import org.apache.brooklyn.core.catalog.internal.CatalogDto;
-import org.apache.brooklyn.core.catalog.internal.CatalogItemDtoAbstract;
-import org.apache.brooklyn.core.catalog.internal.CatalogXmlSerializer;
-import org.apache.brooklyn.util.core.ResourceUtils;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Iterables;
-
-public class CatalogLoadTest {
-
- CatalogXmlSerializer serializer;
-
- @BeforeMethod
- public void setUp() {
- serializer = new CatalogXmlSerializer();
- }
-
- private String loadFile(String file) {
- return ResourceUtils.create(this).getResourceAsString(file);
- }
-
- // CAMP YAML parsing not available in core, so YAML catalog tests are in camp, e.g. CatalogYamlEntityTest
-
- @Test
- public void testLoadXmlCatalog() {
- CatalogDto catalog = (CatalogDto) serializer.fromString(
- loadFile("classpath://brooklyn/catalog/internal/osgi-catalog.xml"));
- assertNotNull(catalog);
- assertEquals(catalog.name, "OSGi catalogue");
- assertEquals(Iterables.size(catalog.getUniqueEntries()), 1, "Catalog entries = " + Joiner.on(", ").join(catalog.getUniqueEntries()));
-
- CatalogItemDtoAbstract<?,?> template = Iterables.getOnlyElement(catalog.getUniqueEntries());
- assertEquals(template.getDisplayName(), "Entity name");
- assertEquals(template.getVersion(), "9.1.3");
- assertEquals(template.getJavaType(), "com.example.ExampleApp");
- assertEquals(template.getLibraries().size(), 2,
- "Template bundles=" + Joiner.on(", ").join(template.getLibraries()));
-
- boolean foundBundle1 = false, foundBundle2 = false;
- for (CatalogBundle bundle : template.getLibraries()) {
- if (bundle.getUrl().equals("file://path/to/bundle.jar")) {
- foundBundle1 = true;
- }
- if (bundle.getUrl().equals("http://www.url.com/for/bundle.jar")) {
- foundBundle2 = true;
- }
- }
- assertTrue(foundBundle1);
- assertTrue(foundBundle2);
- }
-
-}