Bug 591: Minimize the use of Xtend in sal-binding-broker-impl
[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 org.junit.After;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
19 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
20
21 import java.lang.management.ManagementFactory;
22 import java.net.InetSocketAddress;
23
24 public class NetconfDispatcherImplTest {
25
26     private EventLoopGroup nettyGroup;
27     private NetconfServerDispatcher dispatch;
28     private DefaultCommitNotificationProducer commitNot;
29     private HashedWheelTimer hashedWheelTimer;
30
31     @Before
32     public void setUp() throws Exception {
33         nettyGroup = new NioEventLoopGroup();
34
35         commitNot = new DefaultCommitNotificationProducer(
36                 ManagementFactory.getPlatformMBeanServer());
37         NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
38
39         SessionIdProvider idProvider = new SessionIdProvider();
40         hashedWheelTimer = new HashedWheelTimer();
41         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
42                 hashedWheelTimer, factoriesListener, idProvider, 5000);
43
44         NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
45                 factoriesListener, commitNot, idProvider, null);
46         NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory);
47
48         dispatch = new NetconfServerDispatcher(
49                 serverChannelInitializer, nettyGroup, nettyGroup);
50     }
51
52     @After
53     public void tearDown() throws Exception {
54         hashedWheelTimer.stop();
55         commitNot.close();
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 s = dispatch.createServer(addr);
63         s.get();
64     }
65 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.