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.netconf.server;
10 import io.netty.channel.ChannelFuture;
11 import io.netty.channel.EventLoopGroup;
12 import io.netty.channel.nio.NioEventLoopGroup;
13 import io.netty.util.HashedWheelTimer;
14 import java.net.InetSocketAddress;
15 import org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.netconf.server.osgi.AggregatedNetconfOperationServiceFactory;
20 public class NetconfDispatcherImplTest {
21 private EventLoopGroup nettyGroup;
22 private NetconfServerDispatcherImpl dispatch;
23 private HashedWheelTimer hashedWheelTimer;
26 public void setUp() throws Exception {
27 nettyGroup = new NioEventLoopGroup();
29 AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
31 SessionIdProvider idProvider = new DefaultSessionIdProvider();
32 hashedWheelTimer = new HashedWheelTimer();
34 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
35 new NetconfServerSessionNegotiatorFactoryBuilder()
36 .setAggregatedOpService(factoriesListener)
37 .setTimer(hashedWheelTimer)
38 .setIdProvider(idProvider)
39 .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
40 .setConnectionTimeoutMillis(5000)
43 ServerChannelInitializer serverChannelInitializer =
44 new ServerChannelInitializer(serverNegotiatorFactory);
46 dispatch = new NetconfServerDispatcherImpl(
47 serverChannelInitializer, nettyGroup, nettyGroup);
51 public void tearDown() throws Exception {
52 hashedWheelTimer.stop();
53 nettyGroup.shutdownGracefully();
57 public void test() throws Exception {
58 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
59 ChannelFuture server = dispatch.createServer(addr);