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.api.SessionIdProvider;
19 import org.opendaylight.netconf.server.impl.DefaultSessionIdProvider;
20 import org.opendaylight.netconf.server.osgi.AggregatedNetconfOperationServiceFactory;
22 public class NetconfDispatcherImplTest {
23 private EventLoopGroup nettyGroup;
24 private NetconfServerDispatcherImpl dispatch;
25 private HashedWheelTimer hashedWheelTimer;
28 public void setUp() throws Exception {
29 nettyGroup = new NioEventLoopGroup();
31 AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
33 SessionIdProvider idProvider = new DefaultSessionIdProvider();
34 hashedWheelTimer = new HashedWheelTimer();
36 NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
37 new NetconfServerSessionNegotiatorFactoryBuilder()
38 .setAggregatedOpService(factoriesListener)
39 .setTimer(hashedWheelTimer)
40 .setIdProvider(idProvider)
41 .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
42 .setConnectionTimeoutMillis(5000)
45 ServerChannelInitializer serverChannelInitializer =
46 new ServerChannelInitializer(serverNegotiatorFactory);
48 dispatch = new NetconfServerDispatcherImpl(
49 serverChannelInitializer, nettyGroup, nettyGroup);
53 public void tearDown() throws Exception {
54 hashedWheelTimer.stop();
55 nettyGroup.shutdownGracefully();
59 public void test() throws Exception {
60 InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
61 ChannelFuture server = dispatch.createServer(addr);