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.5-SNAPSHOT"));
59 ret.add(mavenBundle("org.opendaylight.yangtools", "yang-binding", "0.5.9-SNAPSHOT"));
60 ret.add(mavenBundle("org.opendaylight.yangtools", "yang-common", "0.5.9-SNAPSHOT"));
61 ret.add(mavenBundle("org.opendaylight.yangtools.model", "ietf-inet-types", "2010.09.24.1"));
66 private Bundle getBundle(final String name) {
67 final String bn = GROUP + "." + name;
68 for (Bundle b : ctx.getBundles()) {
69 if (bn.equals(b.getSymbolicName())) {
76 private void testBundle(final String name) {
77 final Bundle b = getBundle(name);
78 assertNotNull("Bundle '" + name + "' not found", b);
79 assertEquals("Bundle '" + name + "' is not in ACTIVE state", Bundle.ACTIVE, b.getState());
83 public final Option[] config() {
84 final List<Option> options = coreBundles();
86 for (final String s : prerequisiteBundles()) {
87 options.add(mavenBundle(GROUP, s, VERSION));
90 for (final String s : requiredBundles()) {
91 options.add(mavenBundle(GROUP, s, VERSION));
94 options.addAll(Arrays.asList(junitBundles()));
95 return options.toArray(new Option[0]);
99 public final void testBundleActivation() throws BundleException {
100 for (final String s : requiredBundles()) {