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 com.google.common.base.Optional;
12 import io.netty.channel.ChannelFuture;
13 import io.netty.channel.EventLoopGroup;
14 import io.netty.channel.nio.NioEventLoopGroup;
15 import io.netty.util.HashedWheelTimer;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
20 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
22 import javax.net.ssl.SSLContext;
23 import java.lang.management.ManagementFactory;
24 import java.net.InetSocketAddress;
26 public class NetconfDispatcherImplTest {
28 private EventLoopGroup nettyGroup;
31 public void setUp() throws Exception {
32 nettyGroup = new NioEventLoopGroup();
36 public void tearDown() throws Exception {
37 nettyGroup.shutdownGracefully();
41 public void test() throws Exception {
43 DefaultCommitNotificationProducer commitNot = new DefaultCommitNotificationProducer(
44 ManagementFactory.getPlatformMBeanServer());
45 NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
47 SessionIdProvider idProvider = new SessionIdProvider();
48 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
49 new HashedWheelTimer(), factoriesListener, idProvider);
51 NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
52 factoriesListener, commitNot, idProvider);
53 NetconfServerDispatcher.ServerSslChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerSslChannelInitializer(Optional.<SSLContext>absent(), serverNegotiatorFactory, listenerFactory);
56 NetconfServerDispatcher dispatch = new NetconfServerDispatcher(
57 serverChannelInitializer, nettyGroup, nettyGroup);
59 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
60 ChannelFuture s = dispatch.createServer(addr);