You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/12/21 13:10:54 UTC
[04/12] incubator-brooklyn git commit: Test loading
downstream-project into catalogue
Test loading downstream-project into catalogue
Acceptance test that auto-checks whether projects using
downstream-parent will work when loaded from bundle libraries rather
than the classpath.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/816f6179
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/816f6179
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/816f6179
Branch: refs/heads/master
Commit: 816f6179dd1256a1019dbf961bca68120fe4c6a2
Parents: ac9ea5d
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Thu Dec 17 12:26:20 2015 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Thu Dec 17 12:28:04 2015 +0000
----------------------------------------------------------------------
usage/qa/pom.xml | 17 ++-
.../downstreamparent/DownstreamParentTest.java | 64 ++++++++++
.../test/projects/downstream-parent-test/README | 5 +
.../projects/downstream-parent-test/pom.xml | 120 +++++++++++++++++++
.../src/main/java/com/example/HelloEntity.java | 26 ++++
.../main/java/com/example/HelloEntityImpl.java | 31 +++++
.../src/main/resources/blueprint.yaml | 19 +++
.../src/main/resources/catalog.bom | 33 +++++
8 files changed, 314 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/pom.xml
----------------------------------------------------------------------
diff --git a/usage/qa/pom.xml b/usage/qa/pom.xml
index fd0266d..35ba6ec 100644
--- a/usage/qa/pom.xml
+++ b/usage/qa/pom.xml
@@ -83,6 +83,12 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-verifier</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -102,7 +108,16 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes combine.children="append">
+ <exclude>src/test/projects/downstream-parent-test/README</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
-
+v
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/java/org/apache/brooklyn/qa/downstreamparent/DownstreamParentTest.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/java/org/apache/brooklyn/qa/downstreamparent/DownstreamParentTest.java b/usage/qa/src/test/java/org/apache/brooklyn/qa/downstreamparent/DownstreamParentTest.java
new file mode 100644
index 0000000..33c4c42
--- /dev/null
+++ b/usage/qa/src/test/java/org/apache/brooklyn/qa/downstreamparent/DownstreamParentTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.qa.downstreamparent;
+
+import static org.testng.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.brooklyn.util.net.Networking;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+public class DownstreamParentTest {
+
+ private static final String PROJECTS_DIR = "src/test/projects";
+ private static final String WORK_DIR = "target/ut/";
+
+ /**
+ * Asserts that a trivial project using brooklyn-downstream-parent can be
+ * loaded into Brooklyn's catalogue and its entities deployed.
+ */
+ @Test(groups = "Integration")
+ public void testDownstreamProjectsCanBeLoadedIntoBrooklynCatalogByDefault() throws Exception {
+ int port = Networking.nextAvailablePort(57000);
+ File dir = getBasedir("downstream-parent-test");
+ Verifier verifier = new Verifier(dir.getAbsolutePath());
+ verifier.setMavenDebug(true);
+ verifier.executeGoal("post-integration-test", ImmutableMap.of(
+ "bindPort", String.valueOf(port)));
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog("Hello from the init method of the HelloEntity");
+ }
+
+ /** Replicates the behaviour of getBasedir in JUnit's TestResources class */
+ public File getBasedir(String project) throws IOException {
+ File src = (new File(PROJECTS_DIR, project)).getCanonicalFile();
+ assertTrue(src.isDirectory(), "Test project directory does not exist: " + src.getPath());
+ File basedir = (new File(WORK_DIR, getClass().getSimpleName() + "_" + project)).getCanonicalFile();
+ FileUtils.deleteDirectory(basedir);
+ assertTrue(basedir.mkdirs(), "Test project working directory created");
+ FileUtils.copyDirectoryStructure(src, basedir);
+ return basedir;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/README
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/README b/usage/qa/src/test/projects/downstream-parent-test/README
new file mode 100644
index 0000000..3f2f574
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/README
@@ -0,0 +1,5 @@
+A successful build of this project (`mvn clean verify`) means that projects that
+use brooklyn-downstream-parent can be loaded into Brooklyn's catalogue by default.
+
+If the build fails there is almost certainly something wrong with the parent and
+the wider consumers of Brooklyn will probably face similar problems.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/pom.xml
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/pom.xml b/usage/qa/src/test/projects/downstream-parent-test/pom.xml
new file mode 100644
index 0000000..7e3c0e0
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/pom.xml
@@ -0,0 +1,120 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.brooklyn.downstream-parent-test</groupId>
+ <artifactId>catalogue-load-test</artifactId>
+ <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ <packaging>jar</packaging>
+
+ <name>Downstream parent catalogue load test test</name>
+
+ <parent>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-downstream-parent</artifactId>
+ <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ </parent>
+
+ <repositories>
+ <repository>
+ <id>apache-snapshots</id>
+ <url>https://repository.apache.org/content/repositories/snapshots/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>sonatype-nexus-snapshots</id>
+ <name>Sonatype Nexus Snapshots</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-all</artifactId>
+ <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>io.brooklyn.maven</groupId>
+ <artifactId>brooklyn-maven-plugin</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>Run and deploy Brooklyn</id>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <bindPort>${bindPort}</bindPort>
+ <!--
+ Make sure that the test entities aren't already on the classpath.
+ -->
+ <outputDirOnClasspath>false</outputDirOnClasspath>
+ <arguments>
+ <argument>--catalogInitial</argument>
+ <argument>${project.build.outputDirectory}/catalog.bom</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>Deploy entity from catalogue</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>deploy</goal>
+ </goals>
+ <configuration>
+ <blueprint>${project.build.outputDirectory}/blueprint.yaml</blueprint>
+ </configuration>
+ </execution>
+ <execution>
+ <id>Stop Brooklyn</id>
+ <goals>
+ <goal>stop-server</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntity.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntity.java b/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntity.java
new file mode 100644
index 0000000..242708b
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntity.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;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+
+@ImplementedBy(HelloEntityImpl.class)
+public interface HelloEntity extends Entity {
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntityImpl.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntityImpl.java b/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntityImpl.java
new file mode 100644
index 0000000..76d9ffd
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/src/main/java/com/example/HelloEntityImpl.java
@@ -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.
+ */
+package com.example;
+
+import org.apache.brooklyn.core.entity.AbstractEntity;
+
+public class HelloEntityImpl extends AbstractEntity implements HelloEntity {
+
+ @Override
+ public void init() {
+ super.init();
+ System.out.println("Hello from the init method of the HelloEntity");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/blueprint.yaml
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/blueprint.yaml b/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/blueprint.yaml
new file mode 100644
index 0000000..76cc82e
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/blueprint.yaml
@@ -0,0 +1,19 @@
+# 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.
+#
+services:
+- type: downstream-project
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/816f6179/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/catalog.bom
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/catalog.bom b/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/catalog.bom
new file mode 100644
index 0000000..c168c72
--- /dev/null
+++ b/usage/qa/src/test/projects/downstream-parent-test/src/main/resources/catalog.bom
@@ -0,0 +1,33 @@
+# 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: 1.0
+
+ brooklyn.libraries:
+ - "file://${project.build.directory}/${project.build.finalName}.${project.packaging}"
+
+ items:
+
+ - id: downstream-project
+ name: Downstream project
+ itemType: template
+ description: |
+ A downstream project
+ item:
+ services:
+ - type: com.example.HelloEntity