X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-store-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fstore%2Fimpl%2FExtenderYangTrackerCustomizerTest.java;h=c4c523992f271391b33f6220b9f49fc28a4fc4ca;hp=427da1f634cd6c3ac657bf71b6ef4926f3b5b023;hb=4b66c069b5bd80e18c3c038186d44c52bb689a7b;hpb=4e6f0838e508e0dce5dfa62faa29b43e979f5ef8 diff --git a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java b/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java index 427da1f634..c4c523992f 100644 --- a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java +++ b/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.config.yang.store.impl; +import com.google.common.base.Optional; import com.google.common.collect.Lists; import org.junit.Before; import org.junit.Test; @@ -15,14 +16,19 @@ import org.mockito.MockitoAnnotations; import org.opendaylight.controller.config.yang.store.api.YangStoreException; import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleListener; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.Collections; import java.util.Enumeration; import java.util.List; +import java.util.regex.Pattern; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyCollectionOf; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -34,22 +40,26 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; public class ExtenderYangTrackerCustomizerTest { - private ExtenderYangTrackerCustomizer tested; + private ExtenderYangTracker tested; @Mock private MbeParser parser; @Mock - private YangStoreSnapshot yangStoreSnapshot; + private YangStoreSnapshotImpl yangStoreSnapshot; + @Mock + private BundleContext bundleContext; @Before public void setUp() throws YangStoreException { MockitoAnnotations.initMocks(this); - - tested = new ExtenderYangTrackerCustomizer(parser); + doNothing().when(bundleContext).addBundleListener(any(BundleListener.class)); + doReturn(new Bundle[0]).when(bundleContext).getBundles(); + tested = new ExtenderYangTracker(parser, Optional.absent(), bundleContext); doReturn(yangStoreSnapshot).when(parser).parseYangFiles( anyCollectionOf(InputStream.class)); doReturn(22).when(yangStoreSnapshot).countModuleMXBeanEntries(); doReturn("mock yang store").when(yangStoreSnapshot).toString(); doNothing().when(yangStoreSnapshot).close(); + doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getModuleMap(); } @Test @@ -73,17 +83,15 @@ public class ExtenderYangTrackerCustomizerTest { bundle = getMockedBundle(10, false); tested.addingBundle(bundle, null); - for(int i = 0; i< 10; i++){ + for(int i = 0; i< 20; i++){ tested.getYangStoreSnapshot(); } - verify(parser, times(5)).parseYangFiles( - anyCollectionOf(InputStream.class)); + verify(parser, times(7)).parseYangFiles(anyCollectionOf(InputStream.class)); returnedStore = tested.getYangStoreSnapshot(); verifyNoMoreInteractions(parser); - assertEquals(yangStoreSnapshot, returnedStore); } int bundleCounter = 1; @@ -106,6 +114,7 @@ public class ExtenderYangTrackerCustomizerTest { doReturn(1L).when(mock).getBundleId(); doReturn("mockedBundle").when(mock).toString(); + doReturn("mockedBundle").when(mock).getSymbolicName(); return mock; }