2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.dom.spi;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
16 import java.util.concurrent.locks.Lock;
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
21 public class RegistrationTreeSnapshotTest {
23 public void basicTest() throws Exception {
24 final Lock lock = mock(Lock.class);
25 final NodeIdentifier pathArgument = new NodeIdentifier(QName.create("", "pathArgument"));
26 final RegistrationTreeNode<?> registrationTreeNode = new RegistrationTreeNode<>(null, pathArgument);
27 final RegistrationTreeSnapshot<?> registrationTreeSnapshot =
28 new RegistrationTreeSnapshot<>(lock, registrationTreeNode);
30 assertNotNull(registrationTreeSnapshot.getRootNode());
31 assertEquals(registrationTreeNode, registrationTreeSnapshot.getRootNode());
33 doNothing().when(lock).unlock();
34 registrationTreeSnapshot.close();
35 verify(lock).unlock();