X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-persister-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fpersist%2Fimpl%2Fosgi%2FConfigPersisterTest.java;h=b998b9eff0bee8d9e2224104a9bd0f09491f3701;hb=071a641d7c12c0e6112d5ce0afe806b54f116ed2;hp=7b79e41f380af45f8a41a1347b8816516fe8bc32;hpb=8e8516351a527f6bafb1598d679547cfbbe029f9;p=controller.git 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 7b79e41f38..b998b9eff0 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,7 +13,6 @@ 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; @@ -40,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()); } @@ -65,16 +67,13 @@ public class ConfigPersisterTest { public void testPersisterNotAllCapabilitiesProvided() throws Exception { setUpContextAndStartPersister("required-cap", getConflictingService()); Thread.sleep(2000); - handler.assertException(IllegalStateException.class, "Max wait for capabilities reached.Not enough capabilities " + - "for . Expected but not found: [required-cap]"); + handler.assertException(IllegalStateException.class, "Required yang models that are missing: [required-cap]"); } @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(); } @@ -131,12 +130,18 @@ public class ConfigPersisterTest { @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(); }