X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FBlankTransactionServiceTrackerTest.java;h=47b6d100c975de02bd5583e5f6b47aa99556bcad;hp=471c98a6769fdde5dffe3f9ddccd454ae9317bfa;hb=c164056dbd60d7df05285ed098b74e85994071d5;hpb=9228eee6e438894b091f7bee8a4ba7b53286ef8f diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java index 471c98a676..47b6d100c9 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTrackerTest.java @@ -1,14 +1,19 @@ +/* + * Copyright (c) 2014, 2015 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.controller.config.manager.impl.osgi; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertSame; -import static junit.framework.Assert.fail; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - +import com.google.common.util.concurrent.MoreExecutors; import java.util.Collections; import javax.management.ObjectName; import org.junit.Before; @@ -23,7 +28,6 @@ import org.opendaylight.controller.config.spi.ModuleFactory; import org.osgi.framework.ServiceReference; public class BlankTransactionServiceTrackerTest { - @Mock private BlankTransactionServiceTracker.BlankTransaction blankTx; private BlankTransactionServiceTracker tracker; @@ -31,8 +35,9 @@ public class BlankTransactionServiceTrackerTest { @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - doReturn(new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList())).when(blankTx).hit(); - tracker = new BlankTransactionServiceTracker(blankTx); + doReturn(new CommitStatus(Collections.emptyList(), Collections.emptyList(), + Collections.emptyList())).when(blankTx).hit(); + tracker = new BlankTransactionServiceTracker(blankTx, 10, MoreExecutors.newDirectExecutorService()); } @Test @@ -48,33 +53,21 @@ public class BlankTransactionServiceTrackerTest { IllegalArgumentException argumentException = new IllegalArgumentException(); ValidationException validationException = ValidationException.createForSingleException(new ModuleIdentifier("m", "i"), argumentException); doThrow(validationException).when(blankTx).hit(); - try { - tracker.addingService(getMockServiceReference()); - } catch (Exception e) { - verify(blankTx, times(1)).hit(); - assertNotNull(e.getCause()); - assertSame(validationException, e.getCause()); - return; - } - fail("Exception should have occurred for validation exception"); + tracker.addingService(getMockServiceReference()); + verify(blankTx, times(10)).hit(); } @Test public void testConflictingException() throws Exception { int maxAttempts = 2; - tracker = new BlankTransactionServiceTracker(blankTx, maxAttempts); + tracker = new BlankTransactionServiceTracker(blankTx, maxAttempts, MoreExecutors.newDirectExecutorService()); final ConflictingVersionException ex = new ConflictingVersionException(); doThrow(ex).when(blankTx).hit(); - try { - tracker.addingService(getMockServiceReference()); - } catch (Exception e) { - verify(blankTx, times(maxAttempts)).hit(); - return; - } - fail("Exception should have occurred for conflicting exception"); + tracker.addingService(getMockServiceReference()); + verify(blankTx, times(maxAttempts)).hit(); } private ServiceReference getMockServiceReference() {