Merge "BUG 2676 : Introduce API for accessing akka dispatchers"
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / NetconfDispatcherImplTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.impl;
10
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.AggregatedNetconfOperationServiceFactory;
21
22 public class NetconfDispatcherImplTest {
23
24     private EventLoopGroup nettyGroup;
25     private NetconfServerDispatcherImpl dispatch;
26     private DefaultCommitNotificationProducer commitNot;
27     private HashedWheelTimer hashedWheelTimer;
28
29
30     @Before
31     public void setUp() throws Exception {
32         nettyGroup = new NioEventLoopGroup();
33
34         commitNot = new DefaultCommitNotificationProducer(
35                 ManagementFactory.getPlatformMBeanServer());
36         AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
37
38         SessionIdProvider idProvider = new SessionIdProvider();
39         hashedWheelTimer = new HashedWheelTimer();
40         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
41                 hashedWheelTimer, factoriesListener, idProvider, 5000, commitNot, ConcurrentClientsTest.createMockedMonitoringService());
42
43         NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
44
45         dispatch = new NetconfServerDispatcherImpl(
46                 serverChannelInitializer, nettyGroup, nettyGroup);
47     }
48
49     @After
50     public void tearDown() throws Exception {
51         hashedWheelTimer.stop();
52         commitNot.close();
53         nettyGroup.shutdownGracefully();
54     }
55
56     @Test
57     public void test() throws Exception {
58         InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
59         ChannelFuture s = dispatch.createServer(addr);
60         s.get();
61     }
62 }