Merge "Bug 509: Fixed incorrect merging of Data Store Writes / Events"
[controller.git] / opendaylight / netconf / netconf-it / src / test / java / org / opendaylight / controller / netconf / it / AbstractNetconfConfigTest.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.controller.netconf.it;
9
10 import io.netty.channel.EventLoopGroup;
11 import io.netty.channel.nio.NioEventLoopGroup;
12 import io.netty.util.HashedWheelTimer;
13 import org.junit.After;
14 import org.junit.Before;
15 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
16 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
17 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
18 import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
19 import org.opendaylight.controller.netconf.impl.SessionIdProvider;
20 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
21 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
22
23 public class AbstractNetconfConfigTest extends AbstractConfigTest {
24
25     protected EventLoopGroup nettyThreadgroup;
26     private HashedWheelTimer hashedWheelTimer;
27
28     @Before
29     public void setUpAbstractNetconfConfigTest() {
30         nettyThreadgroup = new NioEventLoopGroup();
31         hashedWheelTimer = new HashedWheelTimer();
32     }
33
34
35     protected NetconfServerDispatcher createDispatcher(
36             NetconfOperationServiceFactoryListenerImpl factoriesListener, SessionMonitoringService sessionMonitoringService,
37             DefaultCommitNotificationProducer commitNotifier) {
38         SessionIdProvider idProvider = new SessionIdProvider();
39
40         NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
41                 hashedWheelTimer, factoriesListener, idProvider, 5000, commitNotifier, sessionMonitoringService);
42
43         NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer(
44                 serverNegotiatorFactory);
45         return new NetconfServerDispatcher(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup);
46     }
47
48
49     @After
50     public void cleanUpTimer() {
51         hashedWheelTimer.stop();
52         nettyThreadgroup.shutdownGracefully();
53     }
54
55 }