--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.dom.broker;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
+
+public class AbstractDOMForwardedCompositeTransactionTest {
+
+ private static final DOMStoreTransaction FAIL_TX1 = mock(DOMStoreTransaction.class);
+ private static final DOMStoreTransaction FAIL_TX2 = mock(DOMStoreTransaction.class);
+
+ @Test(expected = IllegalStateException.class)
+ public void closeSubtransactionsTest() throws Exception {
+ doThrow(UnsupportedOperationException.class).when(FAIL_TX1).close();
+ doThrow(UnsupportedOperationException.class).when(FAIL_TX2).close();
+
+ final AbstractDOMForwardedCompositeTransaction domForwardedCompositeTransaction =
+ new DOMForwardedCompositeTransactionTestImpl("testIdent",
+ ImmutableMap.of("testKey1", FAIL_TX1, "testKey2", FAIL_TX2));
+
+ domForwardedCompositeTransaction.closeSubtransactions();
+ }
+
+ private class DOMForwardedCompositeTransactionTestImpl
+ extends AbstractDOMForwardedCompositeTransaction<String, DOMStoreTransaction> {
+
+ private DOMForwardedCompositeTransactionTestImpl(Object identifier,
+ Map<String, DOMStoreTransaction> backingTxs) {
+ super(identifier, backingTxs);
+ }
+ }
+}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
doNothing().when(autoCloseable).close();
inMemoryDOMDataStore.setCloseable(autoCloseable);
inMemoryDOMDataStore.close();
- verify(autoCloseable).close();
+ doThrow(UnsupportedOperationException.class).when(autoCloseable).close();
+ inMemoryDOMDataStore.close();
+ verify(autoCloseable, atLeast(2)).close();
}
}
\ No newline at end of file