39e8d74dcee8f8d42f8576891d94dde019d40afe
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedTransactionTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.cluster.databroker;
9
10 import org.junit.Test;
11 import org.mockito.Mockito;
12 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
13 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
15 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
16 import org.opendaylight.controller.cluster.access.concepts.MemberName;
17 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientHandle;
19
20 public abstract class ClientBackedTransactionTest<T extends ClientBackedTransaction<?>> {
21     private static FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(
22             MemberName.forName("member"), FrontendType.forName("frontend"));
23     protected static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0);
24
25     private static LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_ID, 0);
26     protected static final TransactionIdentifier TRANSACTION_ID = new TransactionIdentifier(HISTORY_ID, 0);
27
28     abstract T object();
29
30     @Test
31     public void testClose() {
32         final AbstractClientHandle<?> delegate = object().delegate();
33         object().close();
34         Mockito.verify(delegate).abort();
35     }
36 }