Skip to content
Permalink
Browse files

Upgrade Pax Exam + centralize project version usage.

  • Loading branch information...
alesj committed Jul 31, 2012
1 parent 77f3bc6 commit 18615971d195f30aabeaa326b584af1ff2a915b7
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source
~ Copyright 2012, Red Hat, Inc., and individual contributors
~ by the @authors tag. See the copyright.txt in the distribution for a
~ full listing of individual contributors.
~
~ 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.
-->

<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">
@@ -33,6 +33,11 @@

<description>Integration tests launcher for Weld-OSGi</description>

<properties>
<version.pax.exam>2.5.0</version.pax.exam>
<version.org.apache.felix>4.0.3</version.org.apache.felix>
</properties>

<url>http://www.seamframework.org/Weld</url>
<licenses>
<license>
@@ -64,28 +69,28 @@
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>2.0.0-RC3</version>
<version>${version.pax.exam}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
<version>2.0.0-RC3</version>
<version>${version.pax.exam}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
<version>2.0.0-RC3</version>
<version>${version.pax.exam}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>3.2.0</version>
<version>${version.org.apache.felix}</version>
<scope>test</scope>
</dependency>

@@ -33,7 +33,7 @@
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
@@ -42,14 +42,15 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment(
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle2").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle3").version("1.2.0-SNAPSHOT")
Environment.toCDIOSGiEnvironment(
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle2"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle3")
)
);
}

@SuppressWarnings("unchecked")
@Test
//@Ignore
public void eventTest(BundleContext context) throws InterruptedException, InvalidSyntaxException, BundleException {
@@ -17,6 +17,8 @@

package org.jboss.weld.environment.osgi.tests.framework;

import java.util.Collection;

import org.jboss.weld.environment.osgi.spi.CDIContainer;
import org.jboss.weld.environment.osgi.spi.CDIContainerFactory;
import org.jboss.weld.environment.osgi.tests.util.Environment;
@@ -32,9 +34,7 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

import java.util.Collection;

import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
@@ -43,9 +43,9 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment(
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-scanner").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-innerscanner").version("1.2.0-SNAPSHOT")
Environment.toCDIOSGiEnvironment(
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-scanner"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-innerscanner")
)
);
}
@@ -32,7 +32,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
@@ -41,8 +41,8 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment(
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-importing").version("1.2.0-SNAPSHOT")
Environment.toCDIOSGiEnvironment(
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-importing")
)
);
}
@@ -1,5 +1,7 @@
package org.jboss.weld.environment.osgi.tests.framework;

import java.lang.reflect.Field;

import org.jboss.weld.environment.osgi.tests.util.Environment;
import org.junit.Assert;
import org.junit.Test;
@@ -11,15 +13,13 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;

import java.lang.reflect.Field;

import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
public class LifeCycleTest {
@Configuration
public static Option[] configure() {
return options(Environment.CDIOSGiEnvironment());
return options(Environment.toCDIOSGiEnvironment());
}

@Test
@@ -17,6 +17,12 @@

package org.jboss.weld.environment.osgi.tests.framework;

import java.util.Collection;

import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;

import org.jboss.weld.environment.osgi.spi.CDIContainer;
import org.jboss.weld.environment.osgi.spi.CDIContainerFactory;
import org.jboss.weld.environment.osgi.tests.util.Environment;
@@ -33,12 +39,7 @@
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import java.util.Collection;

import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
@@ -47,10 +48,10 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment(
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle2").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle3").version("1.2.0-SNAPSHOT")
Environment.toCDIOSGiEnvironment(
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle2"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle3")
)
);
}
@@ -17,20 +17,23 @@

package org.jboss.weld.environment.osgi.tests.integration;

import org.junit.Ignore;
import java.util.ArrayList;
import java.util.Collection;

import junit.framework.Assert;
import org.jboss.weld.environment.osgi.spi.CDIContainer;
import org.jboss.weld.environment.osgi.spi.CDIContainerFactory;
import junit.framework.Assert;
import org.jboss.weld.environment.osgi.tests.util.Environment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.jboss.weld.environment.osgi.tests.util.Environment;
import org.osgi.framework.*;

import java.util.ArrayList;
import java.util.Collection;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

import static org.ops4j.pax.exam.CoreOptions.options;

@@ -40,7 +43,7 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment()
Environment.toCDIOSGiEnvironment()
);
}

@@ -53,29 +56,29 @@ public void CDIContainerFactoryTest(BundleContext context) throws InterruptedExc
CDIContainerFactory factory = (CDIContainerFactory) context.getService(factoryReference);

Collection<CDIContainer> containers = factory.containers();
Assert.assertNotNull("The container collection was null",containers);
Assert.assertEquals("The container collection was not empty",0,containers.size());
Assert.assertNotNull("The container collection was null", containers);
Assert.assertEquals("The container collection was not empty", 0, containers.size());

CDIContainer container;
int i = 0;
for(Bundle b : context.getBundles()) {
for (Bundle b : context.getBundles()) {
container = factory.container(b);
Assert.assertNull("The bundle already got a container",container);
Assert.assertNull("The bundle already got a container", container);
container = factory.createContainer(b);
Assert.assertNotNull("The container creation failed", container);
Assert.assertNull("The container was already added in container collection",factory.container(b));
Assert.assertNull("The container was already added in container collection", factory.container(b));
factory.addContainer(container);
container = factory.container(b);
Assert.assertNotNull("The container cannot be retrieved",container);
Assert.assertEquals("The container was not correctly added in container collection",++i,containers.size());
Assert.assertNotNull("The container cannot be retrieved", container);
Assert.assertEquals("The container was not correctly added in container collection", ++i, containers.size());
}
Assert.assertEquals("Too much or too less registered containers",context.getBundles().length,i);
Assert.assertEquals("Too much or too less registered containers", context.getBundles().length, i);

for(Bundle b : context.getBundles()) {
for (Bundle b : context.getBundles()) {
factory.removeContainer(b);
Assert.assertEquals("The container was not correctly removed from container collection",--i,containers.size());
Assert.assertEquals("The container was not correctly removed from container collection", --i, containers.size());
}
Assert.assertEquals("There still containers in the container collection",0,i);
Assert.assertEquals("There still containers in the container collection", 0, i);

}

@@ -90,31 +93,31 @@ public void CDIContainerTest(BundleContext context) throws InterruptedException,
CDIContainer container = factory.createContainer(context.getBundle());

Assert.assertEquals("The container had the wrong bundle", context.getBundle(), container.getBundle());
Assert.assertFalse("The container was declared as STARTED",container.isStarted());
Assert.assertNotNull("The registration collection was null",container.getRegistrations());
Assert.assertEquals("The registration collection was not empty",0,container.getRegistrations().size());
Assert.assertFalse("The container was declared as STARTED", container.isStarted());
Assert.assertNotNull("The registration collection was null", container.getRegistrations());
Assert.assertEquals("The registration collection was not empty", 0, container.getRegistrations().size());

Collection<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
container.setRegistrations(registrations);
Assert.assertNotNull("The registration collection was null",container.getRegistrations());
Assert.assertEquals("The registration collection was not empty",0,container.getRegistrations().size());
Assert.assertNotNull("The registration collection was null", container.getRegistrations());
Assert.assertEquals("The registration collection was not empty", 0, container.getRegistrations().size());

ServiceRegistration registration = context.registerService(String.class.getName(),"STRING",null);
ServiceRegistration registration = context.registerService(String.class.getName(), "STRING", null);
registrations.add(registration);
container.setRegistrations(registrations);
Assert.assertNotNull("The registration collection was null",container.getRegistrations());
Assert.assertEquals("The registration collection had the wrong number of registration",1,container.getRegistrations().size());
Assert.assertNotNull("The registration collection was null", container.getRegistrations());
Assert.assertEquals("The registration collection had the wrong number of registration", 1, container.getRegistrations().size());

registration = context.registerService(String.class.getName(),"STRING2",null);
registration = context.registerService(String.class.getName(), "STRING2", null);
registrations.add(registration);
container.setRegistrations(registrations);
Assert.assertNotNull("The registration collection was null",container.getRegistrations());
Assert.assertEquals("The registration collection had the wrong number of registration",2,container.getRegistrations().size());
Assert.assertNotNull("The registration collection was null", container.getRegistrations());
Assert.assertEquals("The registration collection had the wrong number of registration", 2, container.getRegistrations().size());

registrations.clear();
container.setRegistrations(registrations);
Assert.assertNotNull("The registration collection was null",container.getRegistrations());
Assert.assertEquals("The registration collection was not empty",0,container.getRegistrations().size());
Assert.assertNotNull("The registration collection was null", container.getRegistrations());
Assert.assertEquals("The registration collection was not empty", 0, container.getRegistrations().size());

}
}
@@ -31,7 +31,7 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.jboss.weld.environment.osgi.tests.util.Environment.toMavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;

@RunWith(JUnit4TestRunner.class)
@@ -40,9 +40,9 @@
@Configuration
public static Option[] configure() {
return options(
Environment.CDIOSGiEnvironment(
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1").version("1.2.0-SNAPSHOT"),
mavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-cdi-spi").version("1.2.0-SNAPSHOT")
Environment.toCDIOSGiEnvironment(
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-bundle1"),
toMavenBundle("org.jboss.weld.osgi.tests", "weld-osgi-cdi-spi")
)
);
}

0 comments on commit 1861597

Please sign in to comment.
You can’t perform that action at this time.