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.controller.netconf.it;
10 import io.netty.channel.EventLoopGroup;
11 import io.netty.channel.nio.NioEventLoopGroup;
12 import io.netty.util.HashedWheelTimer;
13 import org.junit.After;
14 import org.junit.Before;
15 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
16 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
17 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
18 import org.opendaylight.controller.netconf.impl.NetconfServerSessionListenerFactory;
19 import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
20 import org.opendaylight.controller.netconf.impl.SessionIdProvider;
21 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
22 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
24 public class AbstractNetconfConfigTest extends AbstractConfigTest {
26 protected EventLoopGroup nettyThreadgroup;
27 private HashedWheelTimer hashedWheelTimer;
30 public void setUpAbstractNetconfConfigTest() {
31 nettyThreadgroup = new NioEventLoopGroup();
32 hashedWheelTimer = new HashedWheelTimer();
36 protected NetconfServerDispatcher createDispatcher(
37 NetconfOperationServiceFactoryListenerImpl factoriesListener, SessionMonitoringService sessionMonitoringService,
38 DefaultCommitNotificationProducer commitNotifier) {
39 SessionIdProvider idProvider = new SessionIdProvider();
41 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
42 hashedWheelTimer, factoriesListener, idProvider, 5000);
44 NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
45 factoriesListener, commitNotifier, idProvider,
46 sessionMonitoringService);
48 NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(
49 serverNegotiatorFactory, listenerFactory);
50 return new NetconfServerDispatcher(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup);
55 public void cleanUpTimer() {
56 hashedWheelTimer.stop();
57 nettyThreadgroup.shutdownGracefully();