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