Repository: brooklyn-server Updated Branches: refs/heads/master 5f1588ed2 -> 923abe7b3
BROOKLYN-409: add test Includes new osgi test bundle with prefix "com.example.brooklyn" Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/ed560a74 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/ed560a74 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/ed560a74 Branch: refs/heads/master Commit: ed560a740574bb4398d2debba353f90608b46ce9 Parents: b034a27 Author: Aled Sage <aled.s...@gmail.com> Authored: Wed Dec 14 11:30:24 2016 +0000 Committer: Aled Sage <aled.s...@gmail.com> Committed: Tue Dec 20 10:14:54 2016 +0000 ---------------------------------------------------------------------- .../CatalogOsgiVersionMoreEntityRebindTest.java | 88 +++++++++++++++++++ .../osgi/com-example-entities/pom.xml | 87 ++++++++++++++++++ .../test/osgi/entities/SimpleApplication.java | 27 ++++++ .../osgi/entities/SimpleApplicationImpl.java | 26 ++++++ .../entities/SimpleEffectorInitializer.java | 48 ++++++++++ .../test/osgi/entities/SimpleEntity.java | 38 ++++++++ .../test/osgi/entities/SimpleEntityImpl.java | 25 ++++++ .../test/osgi/entities/SimpleLocation.java | 35 ++++++++ .../test/osgi/entities/SimpleObject.java | 56 ++++++++++++ .../test/osgi/entities/SimplePolicy.java | 40 +++++++++ .../src/main/resources/catalog.bom | 27 ++++++ .../brooklyn/test/osgi/entities/icon.gif | Bin 0 -> 43 bytes .../brooklyn/test/osgi/resources/message.txt | 16 ++++ .../main/resources/yaml-ref-back-catalog.bom | 31 +++++++ .../main/resources/yaml-ref-osgi-entity.yaml | 21 +++++ .../main/resources/yaml-ref-parent-catalog.bom | 34 +++++++ .../brooklyn/util/osgi/OsgiTestResources.java | 19 ++++ .../brooklyn-test-osgi-com-example-entities.jar | Bin 0 -> 21436 bytes 18 files changed, 618 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java ---------------------------------------------------------------------- diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java new file mode 100644 index 0000000..5c131f5 --- /dev/null +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java @@ -0,0 +1,88 @@ +/* + * 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.assertEquals; + +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.policy.Policy; +import org.apache.brooklyn.camp.brooklyn.AbstractYamlRebindTest; +import org.apache.brooklyn.core.entity.StartableApplication; +import org.apache.brooklyn.core.mgmt.osgi.OsgiVersionMoreEntityTest; +import org.apache.brooklyn.core.test.entity.TestEntity; +import org.apache.brooklyn.entity.stock.BasicApplication; +import org.apache.brooklyn.test.support.TestResourceUnavailableException; +import org.apache.brooklyn.util.osgi.OsgiTestResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; + +/** Many of the same tests as per {@link OsgiVersionMoreEntityTest} but using YAML for catalog and entities, so catalog item ID is set automatically */ +public class CatalogOsgiVersionMoreEntityRebindTest extends AbstractYamlRebindTest { + + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory.getLogger(CatalogOsgiVersionMoreEntityRebindTest.class); + + @Override + protected boolean useOsgi() { + return true; + } + + // See https://issues.apache.org/jira/browse/BROOKLYN-409 + @Test + public void testPolicyInBundleReferencedByStockCatalogItem() throws Exception { + TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH); + + String policyType = OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_POLICY; + + addCatalogItems( + "brooklyn.catalog:", + " id: wrapped-entity", + " version: 1.0", + " item:", + " services:", + " - type: " + TestEntity.class.getName()); + + addCatalogItems( + "brooklyn.catalog:", + " id: with-policy-from-library", + " version: 1.0", + " brooklyn.libraries:", + " - classpath:" + OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH, + " item:", + " services:", + " - type: " + BasicApplication.class.getName(), + " brooklyn.children:", + " - type: wrapped-entity:1.0", + " brooklyn.policies:", + " - type: " + policyType); + + Entity app = createAndStartApplication("services: [ { type: 'with-policy-from-library:1.0' } ]"); + Entity entity = Iterables.getOnlyElement(app.getChildren()); + Policy policy = Iterables.getOnlyElement(entity.policies()); + assertEquals(policy.getPolicyType().getName(), policyType); + + StartableApplication newApp = rebind(); + Entity newEntity = Iterables.getOnlyElement(newApp.getChildren()); + Policy newPolicy = Iterables.getOnlyElement(newEntity.policies()); + assertEquals(newPolicy.getPolicyType().getName(), policyType); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/pom.xml ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/pom.xml b/utils/common/dependencies/osgi/com-example-entities/pom.xml new file mode 100644 index 0000000..310f198 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/pom.xml @@ -0,0 +1,87 @@ +<?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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <packaging>jar</packaging> + + <!-- + Deliberately not using "org.apache.brooklyn", because those are white-listed for + class-loading purposes. This is *only* used for testing, and is not released to + maven-central etc, so it's ok to use a groupId that we don't actually own! + --> + <groupId>com.example.brooklyn.test.resources.osgi</groupId> + <artifactId>brooklyn-test-osgi-com-example-entities</artifactId> + <version>0.1.0</version> + + <name>OSGi bundled test entities</name> + + <description> + Simple entities for testing the OSGi functionality + </description> + + <parent> + <groupId>org.apache.brooklyn</groupId> + <artifactId>brooklyn-parent</artifactId> + <version>0.11.0-SNAPSHOT</version><!-- BROOKLYN_VERSION --> + <relativePath>../../../../../../../parent/pom.xml</relativePath> + </parent> + <dependencies> + <dependency> + <groupId>org.apache.brooklyn</groupId> + <artifactId>brooklyn-core</artifactId> + <version>${brooklyn.version}</version> + </dependency> + <dependency> + <groupId>org.apache.brooklyn</groupId> + <artifactId>brooklyn-api</artifactId> + <version>${brooklyn.version}</version> + </dependency> + <dependency> + <groupId>org.apache.brooklyn</groupId> + <artifactId>brooklyn-utils-common</artifactId> + <version>${brooklyn.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <outputDirectory>../../../src/test/resources/brooklyn/osgi</outputDirectory> + <finalName>brooklyn-test-osgi-com-example-entities</finalName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-Version>${project.version}</Bundle-Version> + <Brooklyn-Feature-BuildId>${buildNumber}</Brooklyn-Feature-BuildId> + <Brooklyn-Feature-BuildBranch>${scmBranch}</Brooklyn-Feature-BuildBranch> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplication.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplication.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplication.java new file mode 100644 index 0000000..bdaa254 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplication.java @@ -0,0 +1,27 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.api.entity.ImplementedBy; +import org.apache.brooklyn.core.entity.StartableApplication; + +@ImplementedBy(SimpleApplicationImpl.class) +public interface SimpleApplication extends StartableApplication { + +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplicationImpl.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplicationImpl.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplicationImpl.java new file mode 100644 index 0000000..793158b --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleApplicationImpl.java @@ -0,0 +1,26 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.core.entity.AbstractApplication; +import org.apache.brooklyn.core.entity.StartableApplication; + +public class SimpleApplicationImpl extends AbstractApplication implements StartableApplication, SimpleApplication { + +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEffectorInitializer.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEffectorInitializer.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEffectorInitializer.java new file mode 100644 index 0000000..edbdf18 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEffectorInitializer.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 The Apache Software Foundation. + * + * Licensed 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.core.effector.AddEffector; +import org.apache.brooklyn.core.effector.EffectorBody; +import org.apache.brooklyn.core.effector.Effectors; +import org.apache.brooklyn.util.core.config.ConfigBag; + +public class SimpleEffectorInitializer extends AddEffector { + + public SimpleEffectorInitializer() { + super(newEffectorBuilder().build()); + } + + public static Effectors.EffectorBuilder<Void> newEffectorBuilder() { + ConfigBag bag = ConfigBag.newInstance(); + bag.put(EFFECTOR_NAME, SimpleEffectorInitializer.class.getSimpleName()); + + return AddEffector.newEffectorBuilder(Void.class, bag) + .description("A bare-bones effector") + .impl(new Body()); + } + + + public static class Body extends EffectorBody<Void> { + + @Override + public Void call(ConfigBag parameters) { + return null; + } + + } + +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntity.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntity.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntity.java new file mode 100644 index 0000000..558720c --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntity.java @@ -0,0 +1,38 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + + +import org.apache.brooklyn.api.catalog.Catalog; +import org.apache.brooklyn.api.entity.Entity; +import org.apache.brooklyn.api.entity.ImplementedBy; +import org.apache.brooklyn.api.sensor.AttributeSensor; +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.sensor.Sensors; + + +@Catalog(name="A Simple Entity", description="Simple entity for test purposes") +@ImplementedBy(SimpleEntityImpl.class) +public interface SimpleEntity extends Entity { + + ConfigKey<Object> SIMPLE_CONFIG = ConfigKeys.newConfigKey(Object.class, "simple.config"); + + AttributeSensor<Object> SIMPLE_SENSOR = Sensors.newSensor(Object.class, "simple.sensor"); +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntityImpl.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntityImpl.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntityImpl.java new file mode 100644 index 0000000..98442bf --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleEntityImpl.java @@ -0,0 +1,25 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.core.entity.AbstractEntity; + +public class SimpleEntityImpl extends AbstractEntity implements SimpleEntity { + +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleLocation.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleLocation.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleLocation.java new file mode 100644 index 0000000..aad1dd6 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleLocation.java @@ -0,0 +1,35 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.location.AbstractLocation; +import org.apache.brooklyn.util.core.flags.SetFromFlag; + +public class SimpleLocation extends AbstractLocation { + @SetFromFlag("config1") + public static final ConfigKey<String> CONFIG1 = ConfigKeys.newStringConfigKey("config1"); + + @SetFromFlag("config2") + public static final ConfigKey<String> CONFIG2 = ConfigKeys.newStringConfigKey("config2"); + + @SetFromFlag("config3") + public static final ConfigKey<String> CONFIG3 = ConfigKeys.newStringConfigKey("config3"); +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleObject.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleObject.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleObject.java new file mode 100644 index 0000000..a899ccd --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimpleObject.java @@ -0,0 +1,56 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +public class SimpleObject { + + private String val; + + public SimpleObject() { + } + + public SimpleObject(String val) { + this.val = val; + } + + public String getVal() { + return val; + } + + public void setVal(String val) { + this.val = val; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof SimpleObject)) return false; + String oVal = ((SimpleObject)obj).val; + return (val == null) ? oVal == null : val.equals(oVal); + } + + @Override + public int hashCode() { + return (val == null) ? 0 : val.hashCode(); + } + + @Override + public String toString() { + return "SimpleObject["+val+"]"; + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimplePolicy.java ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimplePolicy.java b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimplePolicy.java new file mode 100644 index 0000000..8db160d --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/entities/SimplePolicy.java @@ -0,0 +1,40 @@ +/* + * 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 com.example.brooklyn.test.osgi.entities; + +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.policy.AbstractPolicy; +import org.apache.brooklyn.util.core.flags.SetFromFlag; + +public class SimplePolicy extends AbstractPolicy { + @SetFromFlag("config1") + public static final ConfigKey<String> CONFIG1 = ConfigKeys.newStringConfigKey("config1"); + + @SetFromFlag("config2") + public static final ConfigKey<String> CONFIG2 = ConfigKeys.newStringConfigKey("config2"); + + @SetFromFlag("config3") + public static final ConfigKey<String> CONFIG3 = ConfigKeys.newStringConfigKey("config3"); + + @Override + protected <T> void doReconfigureConfig(ConfigKey<T> key, T val) { + // no-op; allow any config to be set + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/catalog.bom ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/catalog.bom b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/catalog.bom new file mode 100644 index 0000000..a767eff --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/catalog.bom @@ -0,0 +1,27 @@ +# 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. + + +brooklyn.catalog: + version: "0.11.0-SNAPSHOT" # BROOKLYN_VERSION + itemType: entity + description: For testing loading catalog.bom with catalog scan + displayName: I Haz Catalog + items: + - id: com.example.simpleTest + item: + type: com.example.brooklyn.test.osgi.entities.SimpleEntity http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/entities/icon.gif ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/entities/icon.gif b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/entities/icon.gif new file mode 100644 index 0000000..e565824 Binary files /dev/null and b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/entities/icon.gif differ http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/resources/message.txt ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/resources/message.txt b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/resources/message.txt new file mode 100644 index 0000000..c99a620 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/com/example/brooklyn/test/osgi/resources/message.txt @@ -0,0 +1,16 @@ +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. http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-back-catalog.bom ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-back-catalog.bom b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-back-catalog.bom new file mode 100644 index 0000000..6d117c9 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-back-catalog.bom @@ -0,0 +1,31 @@ +# 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. + + +brooklyn.catalog: + version: 0.1.2 + itemType: entity + displayName: I Haz Catalog + libraries: + # References a bundle which doesn't contain SimpleEntity on purpose + # Expects that the caller will already include a reference to the bundle + # and checks that this doesn't override parent's libraries, but adds to them + - classpath:/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.jar + items: + - id: back-reference + item: + type: com.example.yaml.nested.catalog.simple http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-osgi-entity.yaml ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-osgi-entity.yaml b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-osgi-entity.yaml new file mode 100644 index 0000000..c9b1c55 --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-osgi-entity.yaml @@ -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. +# +name: Basic entity +services: +- name: service + type: org.apache.brooklyn.entity.stock.BasicEntity http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-parent-catalog.bom ---------------------------------------------------------------------- diff --git a/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-parent-catalog.bom b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-parent-catalog.bom new file mode 100644 index 0000000..da0543b --- /dev/null +++ b/utils/common/dependencies/osgi/com-example-entities/src/main/resources/yaml-ref-parent-catalog.bom @@ -0,0 +1,34 @@ +# 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. + + +brooklyn.catalog: + version: 0.1.2 + itemType: entity + displayName: I Haz Catalog + libraries: + # References a bundle which doesn't contain SimpleEntity on purpose + # Expects that the caller will already include a reference to the bundle + # and checks that this doesn't override parent's libraries, but adds to them + - classpath:/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.2.0.jar + items: + - id: com.example.yaml.nested.catalog.simple + item: + type: com.example.brooklyn.test.osgi.entities.SimpleEntity + - id: yaml.nested.catalog.more + item: + type: org.apache.brooklyn.test.osgi.entities.more.MoreEntity http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/src/test/java/org/apache/brooklyn/util/osgi/OsgiTestResources.java ---------------------------------------------------------------------- diff --git a/utils/common/src/test/java/org/apache/brooklyn/util/osgi/OsgiTestResources.java b/utils/common/src/test/java/org/apache/brooklyn/util/osgi/OsgiTestResources.java index 574316d..83a44ef 100644 --- a/utils/common/src/test/java/org/apache/brooklyn/util/osgi/OsgiTestResources.java +++ b/utils/common/src/test/java/org/apache/brooklyn/util/osgi/OsgiTestResources.java @@ -53,6 +53,25 @@ public class OsgiTestResources { public static final String BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY_SENSOR_NAME = "simple.sensor"; /** + * brooklyn-test-com-example-osgi-entities (v 0.1.0) - + * defines an entity and an application, to confirm it can be read and used by brooklyn. + * Uses a different symbolic name than the "org.apache.brooklyn" prefix, to test that it's + * not just "white-listing" of such bundles that allows tests to pass. + */ + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_SYMBOLIC_NAME_FINAL_PART = "brooklyn-test-osgi-com-example-entities"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_SYMBOLIC_NAME_FULL = + "com.example.brooklyn.test.resources.osgi."+BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_SYMBOLIC_NAME_FINAL_PART; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH = "/brooklyn/osgi/brooklyn-test-osgi-com-example-entities.jar"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_APPLICATION = "com.example.brooklyn.test.osgi.entities.SimpleApplication"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_ENTITY = "com.example.brooklyn.test.osgi.entities.SimpleEntity"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_POLICY = "com.example.brooklyn.test.osgi.entities.SimplePolicy"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_LOCATION = "com.example.brooklyn.test.osgi.entities.SimpleLocation"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_EFFECTOR = "com.example.brooklyn.test.osgi.entities.SimpleEffectorInitializer"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_OBJECT = "com.example.brooklyn.test.osgi.entities.SimpleObject"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_ENTITY_CONFIG_NAME = "simple.config"; + public static final String BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_ENTITY_SENSOR_NAME = "simple.sensor"; + + /** * brooklyn-test-osgi-more-entities_0.1.0 - * another bundle with a minimal sayHi effector, used to test versioning and dependencies * (this one has no dependencies, but see also {@value #BROOKLYN_TEST_MORE_ENTITIES_V2_PATH}) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ed560a74/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-com-example-entities.jar ---------------------------------------------------------------------- diff --git a/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-com-example-entities.jar b/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-com-example-entities.jar new file mode 100644 index 0000000..d92ab9f Binary files /dev/null and b/utils/common/src/test/resources/brooklyn/osgi/brooklyn-test-osgi-com-example-entities.jar differ