Search in sources :

Example 1 with HealthCheckTestsProvider

use of org.apache.sling.hc.junitbridge.HealthCheckTestsProvider in project sling by apache.

the class HealthCheckTestsProviderTest method setup.

@Before
public void setup() throws InvalidSyntaxException {
    setupTimestamp = System.currentTimeMillis();
    final ComponentContext ctx = Mockito.mock(ComponentContext.class);
    // context properties
    final Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(HealthCheckTestsProvider.PROP_TAG_GROUPS, TAG_GROUPS);
    props.put(Constants.SERVICE_PID, getClass().getName());
    Mockito.when(ctx.getProperties()).thenReturn(props);
    // bundle context
    final BundleContext bc = Mockito.mock(BundleContext.class);
    Mockito.when(ctx.getBundleContext()).thenReturn(bc);
    // HealthCheck ServiceReferences mocks
    Mockito.when(bc.getServiceReferences(Mockito.anyString(), Mockito.anyString())).thenAnswer(new Answer<ServiceReference[]>() {

        @Override
        public ServiceReference[] answer(InvocationOnMock invocation) throws Throwable {
            return getMockReferences(bc, (String) invocation.getArguments()[1]);
        }
    });
    provider = new HealthCheckTestsProvider() {

        {
            activate(ctx);
        }
    };
}
Also used : ComponentContext(org.osgi.service.component.ComponentContext) Hashtable(java.util.Hashtable) InvocationOnMock(org.mockito.invocation.InvocationOnMock) HealthCheckTestsProvider(org.apache.sling.hc.junitbridge.HealthCheckTestsProvider) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

Hashtable (java.util.Hashtable)1 HealthCheckTestsProvider (org.apache.sling.hc.junitbridge.HealthCheckTestsProvider)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 BundleContext (org.osgi.framework.BundleContext)1 ComponentContext (org.osgi.service.component.ComponentContext)1