@@ -0,0 +1,3671 @@
+/*%0A * Copyright (c) 2015 NEC Corporation%0A * All rights reserved.%0A *%0A * This program and the accompanying materials are made available under the%0A * terms of the Eclipse Public License v1.0 which accompanies this%0A * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html%0A */%0Apackage org.opendaylight.vtn.manager.internal.util.tx;%0A%0Aimport org.junit.Test;%0A%0Aimport org.mockito.Mockito;%0A%0Aimport org.opendaylight.vtn.manager.internal.TestBase;%0Aimport org.opendaylight.vtn.manager.internal.VTNManagerProvider;%0Aimport org.opendaylight.controller.md.sal.binding.api.DataBroker;%0Aimport org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;%0A%0A%0A/**%0A * Unit Test for ReadTxContext.%0A */%0Apublic class ReadTxContextTest extends TestBase %7B%0A%0A    /**%0A     * Creates ReadTxContext with VTNManager object and ReadOnlyTransaction.%0A     */%0A    private ReadTxContext getReadTxContext() %7B%0A        ReadOnlyTransaction tx = null;%0A        VTNManagerProvider vtnProvider = Mockito.mock(VTNManagerProvider.class);%0A        DataBroker dataBroker = Mockito.mock(DataBroker.class);%0A        ReadOnlyTransaction transaction = Mockito.mock(ReadOnlyTransaction.class);%0A%0A        Mockito.when(vtnProvider.getDataBroker()).thenReturn(dataBroker);%0A        Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(transaction);%0A%0A        return new ReadTxContext(vtnProvider);%0A    %7D%0A%0A    /**%0A     * Test Case for getProvider() and getReadWriteTransaction().%0A     */%0A    @Test%0A    public void testReadTxContext()  %7B%0A        // Validating VTNProvider with null%0A        VTNManagerProvider  vtnProvider = null;%0A        ReadTxContext rtc = new ReadTxContext(vtnProvider);%0A        assertEquals(rtc.getProvider(), vtnProvider);%0A%0A        // getReadWriteTransaction%0A        try %7B%0A            rtc.getReadWriteTransaction();%0A        %7D catch (IllegalStateException illegalStateException) %7B%0A            assertEquals(illegalStateException.getMessage(), %22Read-only transaction.%22);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Test Case for getTransaction.%0A     */%0A    @Test%0A    public void testGetTransaction()  %7B%0A        // Validating with valid VTNManagerProvider and with empty Transaction in ReadTxContext%0A        ReadTxContext rtc = getReadTxContext();%0A        assertNotNull(rtc.getTransaction());%0A%0A        // Validating with valid VTNManagerProvider and with non empty Transaction in ReadTxContext%0A        assertNotNull(rtc.getTransaction());%0A    %7D%0A%0A    /**%0A     * Test Case for getInventoryReader.%0A     */%0A    @Test%0A    public void testGetInventoryReader() %7B%0A        // Validating with valid VTNManagerProvider and with empty InventoryReader in ReadTxContext%0A        ReadTxContext rtc = getReadTxContext();%0A        assertNotNull(rtc.getInventoryReader());%0A%0A        // Validating with valid VTNManagerProvider and with non empty InventoryReader in ReadTxContext%0A        assertNotNull(rtc.getInventoryReader());%0A    %7D%0A%0A    /**%0A     * Test Case for getFlowCondReader.%0A     */%0A    @Test%0A    public void testGetFlowCondReader() %7B%0A        // Validating with valid VTNManagerProvider and with empty FlowCondReader in ReadTxContext%0A        ReadTxContext rtc = getReadTxContext();%0A        assertNotNull(rtc.getFlowCondReader());%0A%0A        // Validating with valid VTNManagerProvider and with non empty FlowCondReader in ReadTxContext%0A        assertNotNull(rtc.getFlowCondReader());%0A    %7D%0A%0A    /**%0A     * Test Case for cancelTransaction.%0A     */%0A    @Test%0A    public void testCancelTransaction() %7B%0A        // Without Transaction%0A        ReadTxContext rtc = getReadTxContext();%0A        rtc.cancelTransaction();%0A%0A        // With Transaction%0A        rtc.getTransaction();%0A        rtc.cancelTransaction();%0A    %7D%0A%7D%0A

Test Case For ReadTxContext.