use of org.osgi.service.component.ComponentContext in project jackrabbit-oak by apache.
the class OsgiUtilTest method testFallbackLookupWithNoValue.
@Test
public void testFallbackLookupWithNoValue() {
Dictionary dictionary = mock(Dictionary.class);
doReturn(null).when(dictionary).get("cname");
BundleContext bundleContext = mock(BundleContext.class);
doReturn(null).when(bundleContext).getProperty("fname");
ComponentContext componentContext = mock(ComponentContext.class);
doReturn(dictionary).when(componentContext).getProperties();
doReturn(bundleContext).when(componentContext).getBundleContext();
assertNull(lookupConfigurationThenFramework(componentContext, "cname", "fname"));
assertNull(lookupFrameworkThenConfiguration(componentContext, "cname", "fname"));
}
use of org.osgi.service.component.ComponentContext in project jackrabbit-oak by apache.
the class OsgiUtilTest method testComponentLookupWithNonStringValue.
@Test
public void testComponentLookupWithNonStringValue() {
Dictionary properties = mock(Dictionary.class);
doReturn(42).when(properties).get("name");
ComponentContext context = mock(ComponentContext.class);
doReturn(properties).when(context).getProperties();
assertEquals("42", lookup(context, "name"));
}
use of org.osgi.service.component.ComponentContext in project jackrabbit-oak by apache.
the class OsgiUtilTest method testComponentLookupWithNonTrimmedString.
@Test
public void testComponentLookupWithNonTrimmedString() {
Dictionary properties = mock(Dictionary.class);
doReturn(" ").when(properties).get("name");
ComponentContext context = mock(ComponentContext.class);
doReturn(properties).when(context).getProperties();
assertNull(lookup(context, "name"));
}
use of org.osgi.service.component.ComponentContext in project jackrabbit-oak by apache.
the class OsgiUtilTest method testComponentLookupWithStringValue.
@Test
public void testComponentLookupWithStringValue() {
Dictionary properties = mock(Dictionary.class);
doReturn(" value ").when(properties).get("name");
ComponentContext context = mock(ComponentContext.class);
doReturn(properties).when(context).getProperties();
assertEquals("value", lookup(context, "name"));
}
use of org.osgi.service.component.ComponentContext in project jackrabbit-oak by apache.
the class OsgiUtilTest method testFallbackLookupWithValueInComponent.
@Test
public void testFallbackLookupWithValueInComponent() {
Dictionary dictionary = mock(Dictionary.class);
doReturn("value").when(dictionary).get("cname");
BundleContext bundleContext = mock(BundleContext.class);
doReturn(null).when(bundleContext).getProperty("fname");
ComponentContext componentContext = mock(ComponentContext.class);
doReturn(dictionary).when(componentContext).getProperties();
doReturn(bundleContext).when(componentContext).getBundleContext();
assertEquals("value", lookupConfigurationThenFramework(componentContext, "cname", "fname"));
assertEquals("value", lookupFrameworkThenConfiguration(componentContext, "cname", "fname"));
}
Aggregations