Remove CloseableUtil
[netconf.git] / protocol / netconf-server / src / test / java / org / opendaylight / netconf / server / 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 package org.opendaylight.netconf.server;
9
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;
19
20 public class NetconfDispatcherImplTest {
21     private EventLoopGroup nettyGroup;
22     private NetconfServerDispatcherImpl dispatch;
23     private HashedWheelTimer hashedWheelTimer;
24
25     @Before
26     public void setUp() throws Exception {
27         nettyGroup = new NioEventLoopGroup();
28
29         AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
30
31         SessionIdProvider idProvider = new DefaultSessionIdProvider();
32         hashedWheelTimer = new HashedWheelTimer();
33
34         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
35                 new NetconfServerSessionNegotiatorFactoryBuilder()
36                         .setAggregatedOpService(factoriesListener)
37                         .setTimer(hashedWheelTimer)
38                         .setIdProvider(idProvider)
39                         .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
40                         .setConnectionTimeoutMillis(5000)
41                         .build();
42
43         ServerChannelInitializer serverChannelInitializer =
44                 new ServerChannelInitializer(serverNegotiatorFactory);
45
46         dispatch = new NetconfServerDispatcherImpl(
47                 serverChannelInitializer, nettyGroup, nettyGroup);
48     }
49
50     @After
51     public void tearDown() throws Exception {
52         hashedWheelTimer.stop();
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 server = dispatch.createServer(addr);
60         server.get();
61     }
62 }