From ba5c22ce599a4975cdda9ed8edcfacd58160184c Mon Sep 17 00:00:00 2001 From: Thomas Bouron Date: Tue, 20 Dec 2016 18:03:32 +0000 Subject: [PATCH] Allow a user to add or override deserialize configuration in karaf --- .../etc/org.apache.brooklyn.classrename.cfg | 21 +++++++++++++++++++ .../launcher/osgi/OsgiLauncherTest.java | 18 +++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 karaf/apache-brooklyn/src/main/resources/etc/org.apache.brooklyn.classrename.cfg diff --git a/karaf/apache-brooklyn/src/main/resources/etc/org.apache.brooklyn.classrename.cfg b/karaf/apache-brooklyn/src/main/resources/etc/org.apache.brooklyn.classrename.cfg new file mode 100644 index 0000000000..839eeadbf1 --- /dev/null +++ b/karaf/apache-brooklyn/src/main/resources/etc/org.apache.brooklyn.classrename.cfg @@ -0,0 +1,21 @@ +################################################################################ +# +# 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. +# +################################################################################ + +# This file can contains custom deserialization class mappings for the persistence state +# Syntax should be = \ No newline at end of file diff --git a/karaf/itest/src/test/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherTest.java b/karaf/itest/src/test/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherTest.java index b8251129fd..17035e4f87 100644 --- a/karaf/itest/src/test/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherTest.java +++ b/karaf/itest/src/test/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherTest.java @@ -25,14 +25,17 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; import java.io.IOException; +import java.util.Map; import javax.inject.Inject; import org.apache.brooklyn.KarafTestUtils; import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.core.mgmt.persist.DeserializingClassRenamesProvider; import org.apache.brooklyn.test.Asserts; import org.apache.brooklyn.test.IntegrationTest; import org.apache.karaf.features.BootFinished; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -53,7 +56,8 @@ public class OsgiLauncherTest { private static final String TEST_KEY_RUNTIME = "test.key"; private static final String TEST_VALUE_IN_CFG = "test.cfg"; private static final String TEST_KEY_IN_CFG = "test.key.in.cfg"; - + private static final String TEST_CLASS_IN_CFG = "com.acme"; + private static final String TEST_CLASS_RENAME_IN_CFG = "org.apache.brooklyn"; @Inject @Filter(timeout = 120000) protected ManagementContext mgmt; @@ -70,12 +74,18 @@ public class OsgiLauncherTest { @Filter(timeout = 120000) BootFinished bootFinished; + @Before + public void setup() { + DeserializingClassRenamesProvider.reset(); + } + @Configuration public static Option[] configuration() throws Exception { return defaultOptionsWith( editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "globalBrooklynPropertiesFile", ""), editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "localBrooklynPropertiesFile", ""), editConfigurationFilePut("etc/brooklyn.cfg", TEST_KEY_IN_CFG, TEST_VALUE_IN_CFG), + editConfigurationFilePut("etc/org.apache.brooklyn.class-rename.cfg", TEST_CLASS_IN_CFG, TEST_CLASS_RENAME_IN_CFG), features(KarafTestUtils.brooklynFeaturesRepository(), "brooklyn-osgi-launcher") // Uncomment this for remote debugging the tests on port 5005 // ,KarafDistributionOption.debugConfiguration() @@ -96,4 +106,10 @@ public void run() { } }); } + + @Test + public void testClassRenameConfig() throws IOException { + final Map map = DeserializingClassRenamesProvider.loadDeserializingClassRenames(); + assertEquals(TEST_CLASS_RENAME_IN_CFG, map.get(TEST_CLASS_IN_CFG)); + } }