Package org.osgi.service.component

Examples of org.osgi.service.component.ComponentContext


    return configAdminMock;
 

  private static ComponentContext createComponentContextMock(
      Dictionary properties) {
    final ComponentContext contextMock = EasyMock
        .createMock(ComponentContext.class);
    expect(contextMock.getProperties()).andReturn(properties).anyTimes();
    replay(contextMock);
    return contextMock;
  }
View Full Code Here


        }
        // load unprocessed jobs from repository
        if ( this.running ) {
            this.loadJobs();
        } else {
            final ComponentContext ctx = this.componentContext;
            // deactivate
            if ( ctx != null ) {
                logger.info("Deactivating component {} due to errors during startup.", ctx.getProperties().get(Constants.SERVICE_ID));
                final String name = (String) componentContext.getProperties().get(
                    ComponentConstants.COMPONENT_NAME);
                ctx.disableComponent(name);
            }
        }
        while ( this.running ) {
            // so let's wait/get the next job from the queue
            EventInfo info = null;
View Full Code Here

        // lets set up the component configuration
        final Dictionary<String, Object> componentConfig = this.getComponentConfig();

        // lets set up the compnent context
        final ComponentContext componentContext = this.getMockery().mock(ComponentContext.class);
        this.getMockery().checking(new Expectations() {{
            allowing(componentContext).getBundleContext();
            will(returnValue(bundleContext));
            allowing(componentContext).getProperties();
            will(returnValue(componentConfig));
View Full Code Here

        }
        rootNode.save();
        // lets set up the bundle context with the sling id
        final BundleContext bundleContext = this.getMockery().mock(BundleContext.class);

        final ComponentContext componentContext = this.getMockery().mock(ComponentContext.class);
        this.getMockery().checking(new Expectations() {{
            allowing(componentContext).getBundleContext();
            will(returnValue(bundleContext));
        }});
        this.handler.deactivate(componentContext);
View Full Code Here

        assertTrue("AdapterFactoryDescriptors must be empty", am.getFactories().isEmpty());
        assertNull("AdapterFactory cache must be null", am.getFactoryCache());
    }

    public void testInitialized() {
        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        assertNotNull("AdapterFactoryDescriptors must not be null", am.getFactories());
        assertTrue("AdapterFactoryDescriptors must be empty", am.getFactories().isEmpty());
        assertNull("AdapterFactory cache must be null", am.getFactoryCache());
View Full Code Here

        assertNotNull("AdapterFactoryDescriptors must not be null", am.getFactories());
        assertTrue("AdapterFactoryDescriptors must be empty", am.getFactories().isEmpty());
        assertNull("AdapterFactory cache must be null", am.getFactoryCache());

        // this should register the factory
        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        // expect the factory, but cache is empty
        assertNotNull("AdapterFactoryDescriptors must not be null", am.getFactories());
        assertEquals("AdapterFactoryDescriptors must contain one entry", 1, am.getFactories().size());
View Full Code Here

        assertEquals("AdapterFactoryDescriptors must contain one entry", 1, am.getFactories().size());
        assertNull("AdapterFactory cache must be null", am.getFactoryCache());
    }

    public void testBindAfterActivate() {
        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        // no cache and no factories yet
        assertNotNull("AdapterFactoryDescriptors must not be null", am.getFactories());
        assertTrue("AdapterFactoryDescriptors must be empty", am.getFactories().isEmpty());
View Full Code Here

        assertNull(f.get(TestSlingAdaptable2.class.getName()));
    }

    public void testAdaptBase() {

        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        TestSlingAdaptable data = new TestSlingAdaptable();
        assertNull("Expect no adapter", am.getAdapter(data, ITestAdapter.class));
View Full Code Here

        assertTrue(adapter instanceof ITestAdapter);
    }

    public void testAdaptExtended() {

        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        TestSlingAdaptable2 data = new TestSlingAdaptable2();
        assertNull("Expect no adapter", am.getAdapter(data, ITestAdapter.class));
View Full Code Here

        assertTrue(adapter instanceof ITestAdapter);
    }

    public void testAdaptBase2() {

        ComponentContext cc = new MockComponentContext();
        am.activate(cc);

        TestSlingAdaptable data = new TestSlingAdaptable();
        assertNull("Expect no adapter", am.getAdapter(data, ITestAdapter.class));
View Full Code Here

TOP

Related Classes of org.osgi.service.component.ComponentContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.