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.NetconfOperationServiceFactoryListener;
19 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
21 import java.lang.management.ManagementFactory;
22 import java.net.InetSocketAddress;
24 public class NetconfDispatcherImplTest {
26 private EventLoopGroup nettyGroup;
29 public void setUp() throws Exception {
30 nettyGroup = new NioEventLoopGroup();
34 public void tearDown() throws Exception {
35 nettyGroup.shutdownGracefully();
39 public void test() throws Exception {
41 DefaultCommitNotificationProducer commitNot = new DefaultCommitNotificationProducer(
42 ManagementFactory.getPlatformMBeanServer());
43 NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
45 SessionIdProvider idProvider = new SessionIdProvider();
46 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
47 new HashedWheelTimer(), factoriesListener, idProvider);
49 NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
50 factoriesListener, commitNot, idProvider, null);
51 NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory);
54 NetconfServerDispatcher dispatch = new NetconfServerDispatcher(
55 serverChannelInitializer, nettyGroup, nettyGroup);
57 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
58 ChannelFuture s = dispatch.createServer(addr);