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
9 package org.opendaylight.controller.netconf.impl;
11 import io.netty.channel.ChannelFuture;
12 import io.netty.channel.EventLoopGroup;
13 import io.netty.channel.nio.NioEventLoopGroup;
14 import io.netty.util.HashedWheelTimer;
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
20 import java.lang.management.ManagementFactory;
21 import java.net.InetSocketAddress;
23 public class NetconfDispatcherImplTest {
25 private EventLoopGroup nettyGroup;
26 private NetconfServerDispatcher dispatch;
27 private DefaultCommitNotificationProducer commitNot;
28 private HashedWheelTimer hashedWheelTimer;
32 public void setUp() throws Exception {
33 nettyGroup = new NioEventLoopGroup();
35 commitNot = new DefaultCommitNotificationProducer(
36 ManagementFactory.getPlatformMBeanServer());
37 NetconfOperationServiceFactoryListenerImpl factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
39 SessionIdProvider idProvider = new SessionIdProvider();
40 hashedWheelTimer = new HashedWheelTimer();
41 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
42 hashedWheelTimer, factoriesListener, idProvider, 5000, commitNot, ConcurrentClientsTest.createMockedMonitoringService());
44 NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory);
46 dispatch = new NetconfServerDispatcher(
47 serverChannelInitializer, nettyGroup, nettyGroup);
51 public void tearDown() throws Exception {
52 hashedWheelTimer.stop();
54 nettyGroup.shutdownGracefully();
58 public void test() throws Exception {
59 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
60 ChannelFuture s = dispatch.createServer(addr);