Fixed #21 Merge commit '519c9c859f397054c77461ca325e8d0dc82306cd' into dev

* commit '519c9c859f397054c77461ca325e8d0dc82306cd':
  osgi unit tests #21: switch to fax-exam-container-native (faster)
  osgi unit tests #21 : merge core-osgi and core
  osgi unit tests #21
  unit tests (exam.properties) #21
  osgi: unit tests (initial work) #21
  #21 osgi: unit tests (initial work)
pull/30/head
Brett Wooldridge 11 years ago
commit de746f139e

18
.gitignore vendored

@ -5,3 +5,21 @@
target/
dependency-reduced-pom.xml
.DS_Store
**/*.iml
*.class
*.jar
*.war
*.ear
*.iml
*.iws
*.ipr
.tm_*
.classpath
.project
.settings/
.idea/
.gradle/

@ -40,28 +40,32 @@
</developer>
</developers>
<properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<felix.bundle.plugin.version>2.4.0</felix.bundle.plugin.version>
<felix.version>4.2.1</felix.version>
<pax.exam.version>3.4.0</pax.exam.version>
<pax.url.version>1.6.0</pax.url.version>
</properties>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-parent</artifactId>
<version>1.2.5-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
<scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@ -69,16 +73,10 @@
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.8.0-rc3</version>
<version>0.8.0.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
@ -87,13 +85,6 @@
<version>1.01</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<type>maven-plugin</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
@ -136,12 +127,51 @@
<version>5.5.23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.0.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.0.Final</version>
<scope>compile</scope>
</dependency>
<!-- OSGi test -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>${felix.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<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-link-mvn</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId>
<version>${pax.url.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-reference</artifactId>
<version>${pax.url.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@ -152,6 +182,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<extensions>true</extensions>
<configuration>
<source>1.7</source>
<target>1.7</target>
@ -161,7 +192,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<version>${felix.bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
@ -185,13 +216,24 @@
<DynamicImport-Package>*</DynamicImport-Package>
</instructions>
</configuration>
<executions>
<!--
This execution makes sure that the manifest is available
when the tests are executed
-->
<execution>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<!-- outputDirectory>/absolute/path/to/the/output/directory</outputDirectory>
<!-- outputDirectory>/absolute/path/to/the/output/directory</outputDirectory>
<finalName>filename-of-generated-jar-file</finalName -->
<attach>true</attach>
</configuration>
@ -253,5 +295,29 @@
</plugins>
</build>
</profile>
<profile>
<id>felix</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>pax.exam.framework</name>
<value>felix</value>
</property>
</activation>
<properties>
<pax.exam.framework>felix</pax.exam.framework>
<pax.exam.logging>none</pax.exam.logging>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>${felix.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

@ -0,0 +1,91 @@
/*
* Copyright (C) 2013 Brett Wooldridge
*
* 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.zaxxer.hikari.osgi;
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.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import javax.inject.Inject;
import java.io.File;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.CoreOptions.*;
/**
* @author lburgazzoli
*/
@RunWith(PaxExam.class)
public class OSGiBundleTest
{
@Inject
BundleContext context;
@Configuration
public Option[] config()
{
return options(
systemProperty("org.osgi.framework.storage.clean").value("true"),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN"),
mavenBundle("org.slf4j","slf4j-api","1.7.5"),
mavenBundle("org.slf4j","slf4j-simple","1.7.5").noStart(),
mavenBundle("org.javassist", "javassist", "3.18.1-GA"),
new File("core/target/classes").exists()
? bundle("reference:file:core/target/classes")
: bundle("reference:file:../core/target/classes"),
junitBundles(),
systemPackage("com.sun.tools.attach"),
cleanCaches()
);
}
@Test
public void checkInject()
{
assertNotNull(context);
}
@Test
public void checkBundle()
{
Boolean bundleFound = false;
Boolean bundleActive = false;
Bundle[] bundles = context.getBundles();
for(Bundle bundle : bundles)
{
if(bundle != null)
{
if(bundle.getSymbolicName().equals("com.zaxxer.HikariCP"))
{
bundleFound = true;
if(bundle.getState() == Bundle.ACTIVE)
{
bundleActive = true;
}
}
}
}
assertTrue(bundleFound);
assertTrue(bundleActive);
}
}

@ -49,7 +49,6 @@
<modules>
<module>core</module>
</modules>
<dependencyManagement>

Loading…
Cancel
Save