fix ServiceHandler SpotBugs false positives
[transportpce.git] / tests / honeynode / 1.2.1 / netconf-impl / src / test / java / org / opendaylight / 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.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.net.InetSocketAddress;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
20
21 public class NetconfDispatcherImplTest {
22
23     private EventLoopGroup nettyGroup;
24     private NetconfServerDispatcherImpl dispatch;
25     private HashedWheelTimer hashedWheelTimer;
26
27
28     @Before
29     public void setUp() throws Exception {
30         nettyGroup = new NioEventLoopGroup();
31
32         AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
33
34         SessionIdProvider idProvider = new SessionIdProvider();
35         hashedWheelTimer = new HashedWheelTimer();
36
37         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
38                 new NetconfServerSessionNegotiatorFactoryBuilder()
39                         .setAggregatedOpService(factoriesListener)
40                         .setTimer(hashedWheelTimer)
41                         .setIdProvider(idProvider)
42                         .setMonitoringService(ConcurrentClientsTest.createMockedMonitoringService())
43                         .setConnectionTimeoutMillis(5000)
44                         .build();
45
46         NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer =
47                 new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory);
48
49         dispatch = new NetconfServerDispatcherImpl(
50                 serverChannelInitializer, nettyGroup, nettyGroup);
51     }
52
53     @After
54     public void tearDown() throws Exception {
55         hashedWheelTimer.stop();
56         nettyGroup.shutdownGracefully();
57     }
58
59     @Test
60     public void test() throws Exception {
61         InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
62         ChannelFuture server = dispatch.createServer(addr);
63         server.get();
64     }
65 }