forked from x-stream/xstream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A quick, simple IT using PAX to validate OSGi config. Closes x-stream…
- Loading branch information
1 parent
47277a9
commit f41407e
Showing
4 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<artifactId>xstream-parent</artifactId> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<version>1.4.12-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>xstream-its</artifactId> | ||
<name>XStream ITs</name> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-junit4</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-invoker-junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-container-native</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-inject</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-extender-service</artifactId> | ||
<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> | ||
<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.ops4j.pax.exam</groupId> | ||
<artifactId>pax-exam-link-assembly</artifactId> | ||
<version>${version.pax.exam}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>org.apache.felix.framework</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.core</artifactId> | ||
<version>4.3.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test-resources</directory> | ||
<filtering>true</filtering> | ||
</testResource> | ||
</testResources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>failsafe</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
project.version=${project.version} |
77 changes: 77 additions & 0 deletions
77
xstream-its/src/test/com/thoughtworks/xstream/XStreamIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2003, 2004, 2005, 2006 Joe Walnes. | ||
* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 XStream Committers. | ||
* All rights reserved. | ||
* | ||
* The software in this package is published under the terms of the BSD | ||
* style license a copy of which has been included with this distribution in | ||
* the LICENSE.txt file. | ||
* | ||
* Created on 26. September 2003 by Joe Walnes | ||
*/ | ||
package com.thoughtworks.xstream; | ||
|
||
import java.io.InputStream; | ||
import java.util.Properties; | ||
|
||
import javax.inject.Inject; | ||
|
||
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.osgi.framework.Bundle; | ||
import org.osgi.framework.BundleContext; | ||
|
||
import static java.lang.String.format; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.ops4j.pax.exam.CoreOptions.junitBundles; | ||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle; | ||
import static org.ops4j.pax.exam.CoreOptions.options; | ||
|
||
@RunWith(PaxExam.class) | ||
@ExamReactorStrategy(PerMethod.class) | ||
public class XStreamIT | ||
{ | ||
@Inject | ||
BundleContext bundleContext; | ||
|
||
@Configuration | ||
public Option[] config() throws Exception { | ||
Properties properties = new Properties(); | ||
try (InputStream is = getClass().getResourceAsStream("/project.properties")) { | ||
properties.load(is); | ||
} | ||
String xstreamVersion = properties.getProperty("project.version"); | ||
|
||
return options( | ||
junitBundles(), | ||
mavenBundle().groupId("com.thoughtworks.xstream").artifactId("xstream").version(xstreamVersion) | ||
); | ||
} | ||
|
||
@Test | ||
public void smokeTest() { | ||
assertNotNull("BundleContext was not injected", bundleContext); | ||
|
||
boolean xstreamBundleFound = false; | ||
int xstreamBundleState = -1; | ||
for (Bundle bundle : bundleContext.getBundles()) { | ||
if ("xstream".equals(bundle.getSymbolicName())) { | ||
xstreamBundleFound = true; | ||
xstreamBundleState = bundle.getState(); | ||
} | ||
} | ||
|
||
assertTrue("XStream bundle was not loaded", xstreamBundleFound); | ||
assertEquals( | ||
format("XStream bundle was not active (was: %d)", xstreamBundleState), | ||
xstreamBundleState, Bundle.ACTIVE | ||
); | ||
} | ||
} |