Search in sources :

Example 1 with HttpServiceController

use of org.apache.felix.http.base.internal.HttpServiceController in project felix by apache.

the class JettyServiceTest method setUp.

@Before
public void setUp() throws Exception {
    // Setup Mocks
    mockBundleContext = mock(BundleContext.class);
    mockBundle = mock(Bundle.class);
    // Setup Behaviors
    when(mockBundleContext.getBundle()).thenReturn(mockBundle);
    final org.osgi.framework.Filter f = mock(org.osgi.framework.Filter.class);
    when(f.toString()).thenReturn("(prop=*)");
    when(mockBundleContext.createFilter(anyString())).thenReturn(f);
    when(mockBundle.getSymbolicName()).thenReturn("main");
    when(mockBundle.getVersion()).thenReturn(new Version("1.0.0"));
    when(mockBundle.getHeaders()).thenReturn(new Hashtable<String, String>());
    final ServiceReference ref = mock(ServiceReference.class);
    when(ref.getProperty(Constants.SERVICE_ID)).thenReturn(1L);
    final ServiceRegistration reg = mock(ServiceRegistration.class);
    when(reg.getReference()).thenReturn(ref);
    when(mockBundleContext.registerService((Class<ServletContextHelper>) Matchers.isNotNull(), (ServiceFactory<ServletContextHelper>) Matchers.any(ServiceFactory.class), Matchers.any(Dictionary.class))).thenReturn(reg);
    when(mockBundleContext.registerService(Matchers.<String[]>any(), Matchers.any(ServiceFactory.class), Matchers.any(Dictionary.class))).thenReturn(reg);
    when(mockBundleContext.registerService((Class<HttpServiceRuntime>) Matchers.isNotNull(), Matchers.any(HttpServiceRuntime.class), Matchers.any(Dictionary.class))).thenReturn(reg);
    httpServiceController = new HttpServiceController(mockBundleContext);
    jettyService = new JettyService(mockBundleContext, httpServiceController);
    jettyService.start();
}
Also used : Dictionary(java.util.Dictionary) ServiceFactory(org.osgi.framework.ServiceFactory) HttpServiceRuntime(org.osgi.service.http.runtime.HttpServiceRuntime) HttpServiceController(org.apache.felix.http.base.internal.HttpServiceController) Bundle(org.osgi.framework.Bundle) Matchers.anyString(org.mockito.Matchers.anyString) ServiceReference(org.osgi.framework.ServiceReference) ServletContextHelper(org.osgi.service.http.context.ServletContextHelper) Version(org.osgi.framework.Version) BundleContext(org.osgi.framework.BundleContext) ServiceRegistration(org.osgi.framework.ServiceRegistration) Before(org.junit.Before)

Aggregations

Dictionary (java.util.Dictionary)1 HttpServiceController (org.apache.felix.http.base.internal.HttpServiceController)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1 ServiceFactory (org.osgi.framework.ServiceFactory)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 Version (org.osgi.framework.Version)1 ServletContextHelper (org.osgi.service.http.context.ServletContextHelper)1 HttpServiceRuntime (org.osgi.service.http.runtime.HttpServiceRuntime)1