2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.integration;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
13 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
15 import java.util.ArrayList;
16 import java.util.Arrays;
17 import java.util.Collection;
18 import java.util.List;
20 import javax.inject.Inject;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.ops4j.pax.exam.Configuration;
25 import org.ops4j.pax.exam.Option;
26 import org.ops4j.pax.exam.junit.PaxExam;
27 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
28 import org.ops4j.pax.exam.spi.reactors.PerMethod;
29 import org.osgi.framework.Bundle;
30 import org.osgi.framework.BundleContext;
31 import org.osgi.framework.BundleException;
33 @RunWith(PaxExam.class)
34 @ExamReactorStrategy(PerMethod.class)
35 public abstract class AbstractBundleTest {
36 private static final String GROUP = "org.opendaylight.bgpcep";
37 private static final String VERSION = "0.3.0-SNAPSHOT";
42 abstract protected Collection<String> prerequisiteBundles();
43 abstract protected Collection<String> requiredBundles();
45 private List<Option> coreBundles() {
46 final List<Option> ret = new ArrayList<>();
48 ret.add(mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"));
49 ret.add(mavenBundle("ch.qos.logback", "logback-core", "1.0.9"));
50 ret.add(mavenBundle("com.google.guava", "guava", "14.0.1"));
51 ret.add(mavenBundle("commons-codec", "commons-codec", "1.7"));
52 ret.add(mavenBundle("io.netty", "netty-buffer", "4.0.9.Final"));
53 ret.add(mavenBundle("io.netty", "netty-codec", "4.0.9.Final"));
54 ret.add(mavenBundle("io.netty", "netty-common", "4.0.9.Final"));
55 ret.add(mavenBundle("io.netty", "netty-transport", "4.0.9.Final"));
56 ret.add(mavenBundle("org.slf4j", "slf4j-api", "1.7.2"));
58 ret.add(mavenBundle("org.opendaylight.yangtools", "concepts", "0.6.0-SNAPSHOT"));
59 ret.add(mavenBundle("org.opendaylight.yangtools", "yang-binding", "0.6.0-SNAPSHOT"));
60 ret.add(mavenBundle("org.opendaylight.yangtools", "yang-common", "0.6.0-SNAPSHOT"));
61 ret.add(mavenBundle("org.opendaylight.yangtools.model", "ietf-inet-types", "2010.09.24.2-SNAPSHOT"));
63 ret.add(mavenBundle("org.javassist", "javassist", "3.17.1-GA"));
64 ret.add(mavenBundle("org.opendaylight.controller", "config-api", "0.2.3-SNAPSHOT"));
65 ret.add(mavenBundle("org.opendaylight.controller", "protocol-framework", "0.4.0-SNAPSHOT"));
66 ret.add(mavenBundle("org.opendaylight.controller", "sal-common-api", "1.0-SNAPSHOT"));
67 ret.add(mavenBundle("org.opendaylight.controller", "sal-binding-api", "1.0-SNAPSHOT"));
68 ret.add(mavenBundle("org.opendaylight.controller", "sal-binding-broker-impl", "1.0-SNAPSHOT"));
69 ret.add(mavenBundle("org.opendaylight.controller", "sal-binding-config", "1.0-SNAPSHOT"));
70 ret.add(mavenBundle("org.opendaylight.controller", "sal-common", "1.0-SNAPSHOT"));
71 ret.add(mavenBundle("org.opendaylight.yangtools.thirdparty", "xtend-lib-osgi", "2.4.3"));
76 private Bundle getBundle(final String name) {
77 final String bn = GROUP + "." + name;
78 for (Bundle b : ctx.getBundles()) {
79 if (bn.equals(b.getSymbolicName())) {
86 private void testBundle(final String name) {
87 final Bundle b = getBundle(name);
88 assertNotNull("Bundle '" + name + "' not found", b);
89 assertEquals("Bundle '" + name + "' is not in ACTIVE state", Bundle.ACTIVE, b.getState());
93 public final Option[] config() {
94 final List<Option> options = coreBundles();
96 for (final String s : prerequisiteBundles()) {
97 options.add(mavenBundle(GROUP, s, VERSION));
100 for (final String s : requiredBundles()) {
101 options.add(mavenBundle(GROUP, s, VERSION));
104 options.addAll(Arrays.asList(junitBundles()));
105 return options.toArray(new Option[0]);
109 public final void testBundleActivation() throws BundleException {
110 for (final String s : requiredBundles()) {