Package org.apache.sling.commons.testing.osgi

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


        // set resource resolver factory
        final Field resolverField = resolverClass.getDeclaredField("resourceResolverFactory");
        resolverField.setAccessible(true);
        resolverField.set(servletResolver, factory);

        MockBundle bundle = new MockBundle(1L);
        MockBundleContext bundleContext = new MockBundleContext(bundle) {
            @Override
            public ServiceRegistration registerService(String s, Object o, Dictionary dictionary) {
                return null;
            }
View Full Code Here


    @Captor
    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);
View Full Code Here

        assertEquals("/etc/clientlib/test.css", out.getValue(0));
    }

    @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();
View Full Code Here

        assertEquals("//static.host.com/etc/clientlib/test.css", out.getValue(0));
    }

    @Test
    public void test_with_nostatic_class() 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();
View Full Code Here

    }


    @Test
    public void test_with_non_matching_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();
View Full Code Here

        assertEquals("/content/clientlib/test.css", out.getValue(0));
    }

    @Test
    public void test_with_prefix_and_multiple_hosts() 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");
        ctx.setProperty("host.count", 2);
View Full Code Here

        assertEquals("//static2.host.com/etc/clientlib/testA.css", out.getValue(0));
    }

    @Test
    public void test_with_nonrewritten_attribute() 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");
        ctx.setProperty("host.count", 2);
View Full Code Here

        assertEquals("/etc/clientlib/testABC.css", out.getValue(0));
    }

    @Test
    public void test_with_nonrewritten_element() 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");
        ctx.setProperty("host.count", 2);
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        servlet = new MockSlingRequestHandlerServlet();
        servletResolver = new SlingServletResolver();
        MockBundle bundle = new MockBundle(1L);
        MockComponentContext mockComponentContext = new MockComponentContext(
            bundle, SlingServletResolverTest.this.servlet);
        MockServiceReference serviceReference = new MockServiceReference(bundle);
        serviceReference.setProperty(Constants.SERVICE_ID, 1L);
        serviceReference.setProperty(EngineConstants.SLING_SERLVET_NAME,
View Full Code Here

        servlet = new MockSlingRequestHandlerServlet();
        servletResolver = new SlingServletResolver();
        servletResolver.bindResourceResolverFactory(factory);

        MockBundle bundle = new MockBundle(1L);
        MockComponentContext mockComponentContext = new MockComponentContext(
            bundle, SlingServletResolverTest.this.servlet);
        MockServiceReference serviceReference = new MockServiceReference(bundle);
        serviceReference.setProperty(Constants.SERVICE_ID, 1L);
        serviceReference.setProperty(EngineConstants.SLING_SERLVET_NAME,
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.testing.osgi.MockBundle

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.