Examples of MockComponentContext


Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        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

Examples of org.apache.sling.adapter.mock.MockComponentContext

        assertTrue(adapter instanceof ITestAdapter);
    }

    public void testAdaptExtended2() {

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

        Bundle bundle = new MockBundle(1L);
        MockServiceReference ref = new MockServiceReference(bundle);
        ref.setProperty(Constants.SERVICE_ID, 1L);
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockComponentContext

            @Override
            public ServiceRegistration registerService(String[] strings, Object o, Dictionary dictionary) {
                return null;
            }
        };
        MockComponentContext mockComponentContext = new MockComponentContext(
            bundleContext, SlingServletResolverTest.this.servlet);
        MockServiceReference serviceReference = new MockServiceReference(bundle);
        serviceReference.setProperty(Constants.SERVICE_ID, 1L);
        serviceReference.setProperty(SLING_SERLVET_NAME,
            SERVLET_NAME);
        serviceReference.setProperty(
            ServletResolverConstants.SLING_SERVLET_PATHS, SERVLET_PATH);
        serviceReference.setProperty(
            ServletResolverConstants.SLING_SERVLET_EXTENSIONS,
            SERVLET_EXTENSION);
        mockComponentContext.locateService(SERVLET_NAME, serviceReference);

        configureComponentContext(mockComponentContext);

        servletResolver.bindServlet(serviceReference);
        servletResolver.activate(mockComponentContext);
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockComponentContext

    private ArgumentCaptor<Attributes> attributesCaptor;

    @Test
    public void test_without_config_is_noop() throws Exception {
        MockBundle bundle = new MockBundle(-1);
        MockComponentContext ctx = new MockComponentContext(bundle);

        StaticReferenceRewriteTransformerFactory factory = new StaticReferenceRewriteTransformerFactory();
        factory.activate(ctx);

        Transformer transformer = factory.createTransformer();
View Full Code Here

Examples of org.apache.sling.commons.testing.osgi.MockComponentContext

    }

    @Test
    public void test_with_prefix_and_single_host() throws Exception {
        MockBundle bundle = new MockBundle(-1);
        MockComponentContext ctx = new MockComponentContext(bundle);
        ctx.setProperty("prefixes", new String[] { "/etc/clientlib" });
        ctx.setProperty("host.pattern", "static.host.com");

        StaticReferenceRewriteTransformerFactory factory = new StaticReferenceRewriteTransformerFactory();
        factory.activate(ctx);

        Transformer transformer = factory.createTransformer();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.