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/04/12 09:45:44 UTC

[1/2] brooklyn-dist git commit: Adds tests for OSGI loading of external config providers

Repository: brooklyn-dist
Updated Branches:
  refs/heads/master dc5b609d8 -> 669242da9


Adds tests for OSGI loading of external config providers


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

Branch: refs/heads/master
Commit: 88a94f509ad517abe6c3ef4d6e2e270f04a69885
Parents: dc5b609
Author: Martin Harris <gi...@nakomis.com>
Authored: Tue Apr 11 13:48:27 2017 +0100
Committer: Martin Harris <gi...@nakomis.com>
Committed: Wed Apr 12 10:35:56 2017 +0100

----------------------------------------------------------------------
 karaf/itest/pom.xml                             |  15 ++
 ...xternalConfigBrooklynPropertiesOsgiTest.java | 136 +++++++++++++++++++
 2 files changed, 151 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/88a94f50/karaf/itest/pom.xml
----------------------------------------------------------------------
diff --git a/karaf/itest/pom.xml b/karaf/itest/pom.xml
index b11d783..cca593b 100644
--- a/karaf/itest/pom.xml
+++ b/karaf/itest/pom.xml
@@ -207,6 +207,21 @@
             <version>${tinybundles.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>tests</scope>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>brooklyn-utils-common</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/brooklyn-dist/blob/88a94f50/karaf/itest/src/test/java/org/apache/brooklyn/core/dsl/external/ExternalConfigBrooklynPropertiesOsgiTest.java
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/java/org/apache/brooklyn/core/dsl/external/ExternalConfigBrooklynPropertiesOsgiTest.java b/karaf/itest/src/test/java/org/apache/brooklyn/core/dsl/external/ExternalConfigBrooklynPropertiesOsgiTest.java
new file mode 100644
index 0000000..7776d96
--- /dev/null
+++ b/karaf/itest/src/test/java/org/apache/brooklyn/core/dsl/external/ExternalConfigBrooklynPropertiesOsgiTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.dsl.external;
+
+import static org.apache.brooklyn.KarafTestUtils.defaultOptionsWith;
+import static org.apache.brooklyn.util.osgi.OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SYMBOLIC_NAME_FULL;
+import static org.apache.brooklyn.util.osgi.OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_VERSION;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemProperties;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+
+import java.io.InputStream;
+
+import javax.inject.Inject;
+
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
+import org.apache.brooklyn.util.core.osgi.Osgis;
+import org.apache.brooklyn.util.guava.Maybe;
+import org.apache.brooklyn.util.osgi.OsgiTestResources;
+import org.apache.karaf.features.BootFinished;
+import org.apache.karaf.features.FeaturesService;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.exam.util.Filter;
+import org.osgi.framework.Bundle;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class ExternalConfigBrooklynPropertiesOsgiTest {
+
+    @Inject
+    @Filter(timeout = 120000)
+    protected FeaturesService featuresService;
+
+    @Inject
+    @Filter(timeout = 120000)
+    protected ConfigurationAdmin configAdmin;
+
+    @Inject
+    @Filter(timeout = 120000)
+    protected ManagementContext managementContext;
+
+    /**
+     * To make sure the tests run only when the boot features are fully
+     * installed
+     */
+    @Inject
+    @Filter(timeout = 120000)
+    BootFinished bootFinished;
+
+    @Configuration
+    public static Option[] configuration() throws Exception {
+        InputStream entityBundle = ExternalConfigBrooklynPropertiesOsgiTest.class.getResourceAsStream(OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
+        InputStream entityPrefixedBundle = ExternalConfigBrooklynPropertiesOsgiTest.class.getResourceAsStream(OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH);
+
+        if (entityBundle == null || entityPrefixedBundle == null) {
+            return defaultOptionsWith(
+                    editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "globalBrooklynPropertiesFile", ""),
+                    editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "localBrooklynPropertiesFile", "")
+//                    // Uncomment this for remote debugging the tests on port 5005
+//                    , KarafDistributionOption.debugConfiguration()
+            );
+        }
+
+        Assume.assumeNotNull(entityBundle, entityPrefixedBundle);
+
+        return defaultOptionsWith(
+                editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "globalBrooklynPropertiesFile", ""),
+                editConfigurationFilePut("etc/org.apache.brooklyn.osgilauncher.cfg", "localBrooklynPropertiesFile", ""),
+
+                // The dummy providers simply return the key name as the value
+                editConfigurationFilePut("etc/brooklyn.cfg", "brooklyn.external.unprefixedprovider", OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_UNPREFIXED_DUMMY_EXTERNAL_CONFIG_SUPPLIER),
+                editConfigurationFilePut("etc/brooklyn.cfg", "unprefixedproperty", "$brooklyn:external(\"unprefixedprovider\", \"unprefixedvalue\")"),
+                systemProperties(systemProperty("org.apache.brooklyn.classloader.fallback.bundles").value(BROOKLYN_TEST_OSGI_ENTITIES_SYMBOLIC_NAME_FULL + ":" + BROOKLYN_TEST_OSGI_ENTITIES_VERSION)),
+                streamBundle(entityBundle),
+
+                editConfigurationFilePut("etc/brooklyn.cfg", "brooklyn.external.prefixedprovider",
+                        OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_SYMBOLIC_NAME_FULL + ":" +
+                        OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PREFIXED_DUMMY_EXTERNAL_CONFIG_SUPPLIER),
+                editConfigurationFilePut("etc/brooklyn.cfg", "myproperty", "$brooklyn:external(\"prefixedprovider\", \"myvalue\")"),
+                streamBundle(entityPrefixedBundle)
+
+//                // Uncomment this for remote debugging the tests on port 5005
+//                , KarafDistributionOption.debugConfiguration()
+        );
+    }
+
+    @Before
+    public void beforeMethod() {
+        Maybe<Bundle> bundle = Osgis.bundleFinder(((ManagementContextInternal)managementContext).getOsgiManager().get().getFramework())
+                .symbolicName(BROOKLYN_TEST_OSGI_ENTITIES_SYMBOLIC_NAME_FULL)
+                .find();
+
+        Maybe<Bundle> prefixedBundle = Osgis.bundleFinder(((ManagementContextInternal)managementContext).getOsgiManager().get().getFramework())
+                .symbolicName(BROOKLYN_TEST_OSGI_ENTITIES_SYMBOLIC_NAME_FULL)
+                .find();
+
+        Assume.assumeTrue(bundle.isPresent());
+        Assume.assumeTrue(prefixedBundle.isPresent());
+    }
+
+    @Test
+    public void testOSGIWithPrefix() throws Exception {
+        Assert.assertEquals("unprefixedvalue", managementContext.getConfig().getConfig(ConfigKeys.newStringConfigKey("unprefixedproperty")));
+        Assert.assertEquals("myvalue", managementContext.getConfig().getConfig(ConfigKeys.newStringConfigKey("myproperty")));
+    }
+
+}


[2/2] brooklyn-dist git commit: Closes #89

Posted by sv...@apache.org.
Closes #89

Adds tests for OSGI loading of external config providers


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

Branch: refs/heads/master
Commit: 669242da97e368c152ca8c242960905a7136087b
Parents: dc5b609 88a94f5
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Apr 12 12:45:37 2017 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Apr 12 12:45:37 2017 +0300

----------------------------------------------------------------------
 karaf/itest/pom.xml                             |  15 ++
 ...xternalConfigBrooklynPropertiesOsgiTest.java | 136 +++++++++++++++++++
 2 files changed, 151 insertions(+)
----------------------------------------------------------------------