Exctract EventLoopGroup instances to constructorparameters for netconf client and...
[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 com.google.common.base.Optional;
12 import io.netty.channel.ChannelFuture;
13 import io.netty.channel.EventLoopGroup;
14 import io.netty.channel.nio.NioEventLoopGroup;
15 import io.netty.util.HashedWheelTimer;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListener;
20 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
21
22 import javax.net.ssl.SSLContext;
23 import java.lang.management.ManagementFactory;
24 import java.net.InetSocketAddress;
25
26 public class NetconfDispatcherImplTest {
27
28     private EventLoopGroup nettyGroup;
29
30     @Before
31     public void setUp() throws Exception {
32         nettyGroup = new NioEventLoopGroup();
33     }
34
35     @After
36     public void tearDown() throws Exception {
37         nettyGroup.shutdownGracefully();
38     }
39
40     @Test
41     public void test() throws Exception {
42
43         DefaultCommitNotificationProducer commitNot = new DefaultCommitNotificationProducer(
44                 ManagementFactory.getPlatformMBeanServer());
45         NetconfOperationServiceFactoryListener factoriesListener = new NetconfOperationServiceFactoryListenerImpl();
46
47         SessionIdProvider idProvider = new SessionIdProvider();
48         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
49                 new HashedWheelTimer(), factoriesListener, idProvider);
50
51         NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory(
52                 factoriesListener, commitNot, idProvider);
53         NetconfServerDispatcher.ServerSslChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerSslChannelInitializer(Optional.<SSLContext>absent(), serverNegotiatorFactory, listenerFactory);
54
55
56         NetconfServerDispatcher dispatch = new NetconfServerDispatcher(
57                 serverChannelInitializer, nettyGroup, nettyGroup);
58
59         InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 8333);
60         ChannelFuture s = dispatch.createServer(addr);
61
62         commitNot.close();
63     }
64 }