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 java.lang.management.ManagementFactory;
16 import java.net.InetSocketAddress;
17 import org.junit.After;
18 import org.junit.Before;
19 import org.junit.Test;
20 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
21 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
23 public class NetconfDispatcherImplTest {
25 private EventLoopGroup nettyGroup;
28 public void setUp() throws Exception {
29 nettyGroup = new NioEventLoopGroup();
33 public void tearDown() throws Exception {
34 nettyGroup.shutdownGracefully();
38 public void test() throws Exception {
40 DefaultCommitNotificationProducer commitNot = new DefaultCommitNotificationProducer(
41 ManagementFactory.getPlatformMBeanServer());
42 NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
44 SessionIdProvider idProvider = new SessionIdProvider();
45 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
46 new HashedWheelTimer(), factoriesListener, idProvider);
48 NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
49 factoriesListener, commitNot, idProvider);
50 NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory);
53 NetconfServerDispatcher dispatch = new NetconfServerDispatcher(
54 serverChannelInitializer, nettyGroup, nettyGroup);
56 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
57 ChannelFuture s = dispatch.createServer(addr);