X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2Fosgi%2FConfigPersisterTest.java;fp=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2Fosgi%2FConfigPersisterTest.java;h=1f5d2c1d0f34dec1ada1bb45ab7fbbfb17954880;hp=3be6ca95350062bf679b7be3e68177c351071d3c;hb=89c5571e29995b24e3364ab0c82a7351a3379d18;hpb=b76162c1bf82cc368dbb78cbebca3d50e30eb5b8 diff --git a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java index 3be6ca9535..1f5d2c1d0f 100644 --- a/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java +++ b/opendaylight/netconf/config-persister-impl/src/test/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterTest.java @@ -13,12 +13,10 @@ 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 com.google.common.collect.Sets; import java.io.IOException; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.netconf.api.Capability; @@ -41,12 +39,15 @@ public class ConfigPersisterTest { private ConfigPersisterActivator configPersisterActivator; private TestingExceptionHandler handler; - - private void setUpContextAndStartPersister(String requiredCapability, final NetconfOperationService conflictingService) throws Exception { + private void setUpContext(String requiredCapability) throws Exception { DummyAdapterWithInitialSnapshot.expectedCapability = requiredCapability; ctx = new MockedBundleContext(1000, 1000); - doReturn(getConflictingService()).when(ctx.serviceFactory).createService(anyString()); configPersisterActivator = new ConfigPersisterActivator(); + } + + private void setUpContextAndStartPersister(String requiredCapability, final NetconfOperationService conflictingService) throws Exception { + setUpContext(requiredCapability); + doReturn(conflictingService).when(ctx.serviceFactory).createService(anyString()); configPersisterActivator.start(ctx.getBundleContext()); } @@ -73,9 +74,7 @@ public class ConfigPersisterTest { @Test public void testPersisterSuccessfulPush() throws Exception { - setUpContextAndStartPersister("cap1", getConflictingService()); - NetconfOperationService service = getWorkingService(getOKDocument()); - doReturn(service).when(ctx.serviceFactory).createService(anyString()); + setUpContextAndStartPersister("cap1", getWorkingService(getOKDocument())); Thread.sleep(2000); assertCannotRegisterAsJMXListener_pushWasSuccessful(); } @@ -130,15 +129,20 @@ public class ConfigPersisterTest { } } - @Ignore("this test needs to be redesigned. Remove bundle bundle context and concurrency to make it more stable") @Test public void testSuccessConflictingVersionException() throws Exception { - setUpContextAndStartPersister("cap1", getConflictingService()); - doReturn(getConflictingService()).when(ctx.serviceFactory).createService(anyString()); - Thread.sleep(500); - // working service: - LOG.info("Switching to working service **"); - doReturn(getWorkingService(getOKDocument())).when(ctx.serviceFactory).createService(anyString()); + LOG.info("testSuccessConflictingVersionException starting"); + + setUpContext("cap1"); + + NetconfOperationService conflictingService = getConflictingService(); + NetconfOperationService workingService = getWorkingService(getOKDocument()); + + doReturn(conflictingService).doReturn(conflictingService).doReturn(conflictingService). + doReturn(workingService).when(ctx.serviceFactory).createService(anyString()); + + configPersisterActivator.start(ctx.getBundleContext()); + Thread.sleep(1000); assertCannotRegisterAsJMXListener_pushWasSuccessful(); }