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
8 package org.opendaylight.ovsdb.openstack.netvirt.it;
10 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
12 import java.util.Calendar;
14 import javax.inject.Inject;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
19 import org.ops4j.pax.exam.Option;
20 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
21 import org.ops4j.pax.exam.util.Filter;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 import com.google.common.collect.ObjectArrays;
27 public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase implements BindingAwareProvider {
29 private static final Logger LOG = LoggerFactory.getLogger(AbstractMdsalTestBase.class);
30 private static final int REGISTRATION_TIMEOUT = 10000;
31 @Inject @Filter(timeout = 60000)
32 private BindingAwareBroker broker;
33 private ProviderContext session = null;
35 public ProviderContext getSession() {
40 public void onSessionInitiated(ProviderContext session) {
41 LOG.info("Session Initiated: {}",session);
42 this.session = session;
46 public void setup() throws Exception {
48 Calendar start = Calendar.getInstance();
49 broker.registerProvider(this);
50 for (int timer = 0;timer < REGISTRATION_TIMEOUT;timer++) {
51 if (session != null) {
52 Calendar stop = Calendar.getInstance();
53 LOG.info("Registered with the MD-SAL after {} ms",
54 stop.getTimeInMillis() - start.getTimeInMillis());
60 throw new RuntimeException("Session not initiated after " + REGISTRATION_TIMEOUT + " ms");
64 public Option[] getLoggingOptions() {
65 Option[] options = new Option[] {
66 editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
67 logConfiguration(AbstractMdsalTestBase.class),
68 LogLevel.INFO.name()),
70 options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);