Package org.apache.sling.rewriter

Examples of org.apache.sling.rewriter.Transformer


        MockComponentContext ctx = new MockComponentContext(bundle);

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "href", null, "CDATA", "/etc/clientlib/test.css");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("/etc/clientlib/test.css", out.getValue(0));
View Full Code Here


        ctx.setProperty("host.pattern", "static.host.com");

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "href", null, "CDATA", "/etc/clientlib/test.css");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("//static.host.com/etc/clientlib/test.css", out.getValue(0));
View Full Code Here

        ctx.setProperty("host.pattern", "static.host.com");

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "href", null, "CDATA", "/etc/clientlib/test.css");
        in.addAttribute(null, "class", null, "CDATA", "something nostatic");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("/etc/clientlib/test.css", out.getValue(0));
View Full Code Here

        ctx.setProperty("host.pattern", "static.host.com");

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "href", null, "CDATA", "/content/clientlib/test.css");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("/content/clientlib/test.css", out.getValue(0));
View Full Code Here

        ctx.setProperty("host.count", 2);

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "href", null, "CDATA", "/etc/clientlib/testA.css");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("//static2.host.com/etc/clientlib/testA.css", out.getValue(0));
View Full Code Here

        ctx.setProperty("host.count", 2);

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "src", null, "CDATA", "/etc/clientlib/testABC.css");
        transformer.startElement(null, "link", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("/etc/clientlib/testABC.css", out.getValue(0));
View Full Code Here

        ctx.setProperty("host.count", 2);

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

        Transformer transformer = factory.createTransformer();
        transformer.setContentHandler(handler);

        AttributesImpl in = new AttributesImpl();
        in.addAttribute(null, "src", null, "CDATA", "/etc/clientlib/testABC.css");
        transformer.startElement(null, "iframe", null, in);

        verify(handler, only()).startElement(isNull(String.class), eq("iframe"), isNull(String.class),
                attributesCaptor.capture());
        Attributes out = attributesCaptor.getValue();
        assertEquals("/etc/clientlib/testABC.css", out.getValue(0));
View Full Code Here

TOP

Related Classes of org.apache.sling.rewriter.Transformer

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.