You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/10/27 00:58:24 UTC
[06/12] incubator-brooklyn git commit: [BROOKLYN-183] Add pax-exam
integration tests stub project
[BROOKLYN-183] Add pax-exam integration tests stub project
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d944b7ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d944b7ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d944b7ab
Branch: refs/heads/master
Commit: d944b7abcbfbe9f2c5f13a550407f4dac4cc059a
Parents: c8161a6
Author: Ciprian Ciubotariu <ch...@gmx.net>
Authored: Fri Oct 2 19:11:46 2015 +0300
Committer: Ciprian Ciubotariu <ch...@gmx.net>
Committed: Sun Oct 25 01:04:51 2015 +0300
----------------------------------------------------------------------
karaf/itest/pom.xml | 164 +++++++++++++++++++
.../test/java/org/apache/brooklyn/MyTest.java | 93 +++++++++++
karaf/itest/src/test/resources/exam.properties | 21 +++
karaf/itest/src/test/resources/logback.xml | 43 +++++
karaf/pom.xml | 21 +++
5 files changed, 342 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d944b7ab/karaf/itest/pom.xml
----------------------------------------------------------------------
diff --git a/karaf/itest/pom.xml b/karaf/itest/pom.xml
new file mode 100644
index 0000000..416d748
--- /dev/null
+++ b/karaf/itest/pom.xml
@@ -0,0 +1,164 @@
+<?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>
+ <parent>
+ <artifactId>brooklyn-karaf</artifactId>
+ <groupId>org.apache.brooklyn</groupId>
+ <version>0.9.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-itest</artifactId>
+ <name>Brooklyn Karaf pax-exam itest</name>
+
+ <dependencies>
+ <!-- Pax Exam Dependencies -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-invoker-junit</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Karaf Container -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-karaf</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-inject</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-extender-service</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Preferred link because it does not require an mvn url handler implicitely. -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-assembly</artifactId>
+ <version>${pax.exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${org.osgi.core.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${org.osgi.compendium.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- framework to test with -->
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>standard</artifactId>
+ <version>${karaf.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <version>${karaf.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.system</groupId>
+ <artifactId>org.apache.karaf.system.core</artifactId>
+ <version>${karaf.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>apache-karaf</artifactId>
+ <version>${karaf.version}</version>
+ <type>zip</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.dev</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d944b7ab/karaf/itest/src/test/java/org/apache/brooklyn/MyTest.java
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/java/org/apache/brooklyn/MyTest.java b/karaf/itest/src/test/java/org/apache/brooklyn/MyTest.java
new file mode 100644
index 0000000..d7b4917
--- /dev/null
+++ b/karaf/itest/src/test/java/org/apache/brooklyn/MyTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+
+import java.io.File;
+
+import javax.inject.Inject;
+
+import org.apache.karaf.features.BootFinished;
+import org.apache.karaf.features.FeaturesService;
+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.karaf.options.LogLevelOption.LogLevel;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.BundleContext;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class MyTest {
+
+ @Inject
+ private BundleContext bc;
+
+
+ @Inject
+ protected FeaturesService featuresService;
+
+ /**
+ * To make sure the tests run only when the boot features are fully
+ * installed
+ */
+ @Inject
+ BootFinished bootFinished;
+
+ @Configuration
+ public static Option[] configuration() throws Exception {
+ return new Option[] {
+ karafDistributionConfiguration().frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
+ .type("zip").version("4.0.1"))
+ .unpackDirectory(new File("target/paxexam/unpack/"))
+ .useDeployFolder(false),
+ configureConsole().ignoreLocalConsole(),
+ logLevel(LogLevel.INFO),
+ keepRuntimeFolder(),
+ features(
+ maven().groupId("org.apache.karaf.features")
+ .artifactId("standard").type("xml")
+ .classifier("features").version("3.0.3"),
+ "eventadmin")
+ };
+ }
+
+ @Test
+ public void shouldHaveBundleContext() {
+ assertThat(bc, is(notNullValue()));
+ }
+
+ @Test
+ public void checkEventFeature() throws Exception {
+ assertThat(featuresService.isInstalled(featuresService.getFeature("eventadmin")), is(true));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d944b7ab/karaf/itest/src/test/resources/exam.properties
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/resources/exam.properties b/karaf/itest/src/test/resources/exam.properties
new file mode 100644
index 0000000..d516df6
--- /dev/null
+++ b/karaf/itest/src/test/resources/exam.properties
@@ -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.
+#
+################################################################################
+
+pax.exam.logging = none
+pax.exam.service.timeout = 5000
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d944b7ab/karaf/itest/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/karaf/itest/src/test/resources/logback.xml b/karaf/itest/src/test/resources/logback.xml
new file mode 100644
index 0000000..7c08bb7
--- /dev/null
+++ b/karaf/itest/src/test/resources/logback.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+<configuration>
+
+ <!-- log to System.out on console -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <!-- log to file test.log -->
+ <appender name="TEST_LOG" class="ch.qos.logback.core.FileAppender">
+ <file>test.log</file>
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="TEST_LOG" />
+ </root>
+ <logger name="org.ops4j.pax.exam" level="INFO" />
+
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d944b7ab/karaf/pom.xml
----------------------------------------------------------------------
diff --git a/karaf/pom.xml b/karaf/pom.xml
index e30adc3..9417336 100644
--- a/karaf/pom.xml
+++ b/karaf/pom.xml
@@ -37,6 +37,11 @@
<lifecycle-mapping-plugin.version>1.0.0</lifecycle-mapping-plugin.version>
+ <!-- pax-exam -->
+ <pax.exam.version>4.5.0</pax.exam.version>
+ <pax.url.version>2.4.1</pax.url.version>
+ <ops4j.base.version>1.5.0</ops4j.base.version>
+
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
@@ -45,7 +50,23 @@
<module>features</module>
<module>apache-brooklyn</module>
<module>commands</module>
+ <module>itest</module>
</modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.ops4j.base</groupId>
+ <artifactId>ops4j-base-lang</artifactId>
+ <version>${ops4j.base.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.base</groupId>
+ <artifactId>ops4j-base-util-property</artifactId>
+ <version>${ops4j.base.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<build>
<pluginManagement>