eec96592d8e4e6e72e701a5596de52e17a1d7738
[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.NetconfOperationServiceFactoryListener;
21 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
22
23 public class NetconfDispatcherImplTest {
24
25     private EventLoopGroup nettyGroup;
26
27     @Before
28     public void setUp() throws Exception {
29         nettyGroup = new NioEventLoopGroup();
30     }
31
32     @After
33     public void tearDown() throws Exception {
34         nettyGroup.shutdownGracefully();
35     }
36
37     @Test
38     public void test() throws Exception {
39
40         DefaultCommitNotificationProducer commitNot = new DefaultCommitNotificationProducer(
41                 ManagementFactory.getPlatformMBeanServer());
42         NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
43
44         SessionIdProvider idProvider = new SessionIdProvider();
45         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
46                 new HashedWheelTimer(), factoriesListener, idProvider);
47
48         NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
49                 factoriesListener, commitNot, idProvider);
50         NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(serverNegotiatorFactory, listenerFactory);
51
52
53         NetconfServerDispatcher dispatch = new NetconfServerDispatcher(
54                 serverChannelInitializer, nettyGroup, nettyGroup);
55
56         InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
57         ChannelFuture s = dispatch.createServer(addr);
58
59         commitNot.close();
60     }
61 }