2 * Copyright (c) 2015 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
9 package org.opendaylight.controller.mdsal.it.base;
11 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
12 import static org.ops4j.pax.exam.CoreOptions.composite;
14 import javax.inject.Inject;
16 import org.junit.Before;
17 import org.opendaylight.controller.config.it.base.AbstractConfigTestBase;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
19 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
20 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
21 import org.ops4j.pax.exam.Option;
22 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
23 import org.ops4j.pax.exam.util.Filter;
24 import org.osgi.framework.BundleContext;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase implements BindingAwareProvider {
30 private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
31 private static final int REGISTRATION_TIMEOUT = 70000;
32 @Inject @Filter(timeout=60000)
33 private BundleContext context;
34 @Inject @Filter(timeout=60000)
35 private BindingAwareBroker broker;
36 private ProviderContext session = null;
38 public ProviderContext getSession() {
43 public void onSessionInitiated(ProviderContext session) {
44 LOG.info("Session Initiated: {}",session);
45 this.session = session;
50 public void setup() throws Exception {
52 long start = System.nanoTime();
53 broker.registerProvider(this);
54 for(int i=0;i<REGISTRATION_TIMEOUT;i++) {
56 long stop = System.nanoTime();
57 LOG.info("Registered session {} with the MD-SAL after {} ns",
65 throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
69 public Option getLoggingOption() {
70 Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
71 logConfiguration(AbstractMdsalTestBase.class),
72 LogLevel.INFO.name());
73 option = composite(option, super.getLoggingOption());