List of usage examples for org.xml.sax.helpers AttributesImpl addAttribute
public void addAttribute(String uri, String localName, String qName, String type, String value)
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testJavaScriptClientLibraryWithSameSchemePath() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.JS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "src", "", "CDATA", "//example.com/same/scheme/script.js"); in.addAttribute("", "type", "", "CDATA", "text/javascript"); transformer.startElement(null, "script", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("script"), isNull(String.class), attributesCaptor.capture()); assertEquals("//example.com/same/scheme/script.js", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testJavaScriptClientLibraryWithDomainedPath() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.JS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "src", "", "CDATA", "http://www.example.com/same/scheme/script.js"); in.addAttribute("", "type", "", "CDATA", "text/javascript"); transformer.startElement(null, "script", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("script"), isNull(String.class), attributesCaptor.capture()); assertEquals("http://www.example.com/same/scheme/script.js", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibrary() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", PATH + ".css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals(PATH + "." + FAKE_STREAM_CHECKSUM + ".css", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testMinifiedCssClientLibrary() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", PATH + ".min.css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals(PATH + ".min." + FAKE_STREAM_CHECKSUM + ".css", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testProxiedJavaScriptClientLibrary() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.JS), eq(PROXIED_PATH))).thenReturn(proxiedHtmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "src", "", "CDATA", PROXY_PATH + ".js"); in.addAttribute("", "type", "", "CDATA", "text/javascript"); transformer.startElement(null, "script", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("script"), isNull(String.class), attributesCaptor.capture()); assertEquals(PROXY_PATH + "." + PROXIED_FAKE_STREAM_CHECKSUM + ".js", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibraryWithInvalidExtension() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", PATH + ".styles"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals(PATH + ".styles", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibraryWithRelAttributeValueDiffersFromStylesheet() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", PATH + ".css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "preload"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals(PATH + "." + FAKE_STREAM_CHECKSUM + ".css", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibraryWithSameSchemePath() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", "//example.com/same/scheme/styles.css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals("//example.com/same/scheme/styles.css", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibraryWithSameDomainedPath() throws Exception { when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", "https://example.com/same/scheme/styles.css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals("https://example.com/same/scheme/styles.css", attributesCaptor.getValue().getValue(0)); }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactoryTest.java
@Test public void testCssClientLibraryWithMd5Enforce() throws Exception { PrivateAccessor.setField(factory, "enforceMd5", true); when(htmlLibraryManager.getLibrary(eq(LibraryType.CSS), eq(PATH))).thenReturn(htmlLibrary); final AttributesImpl in = new AttributesImpl(); in.addAttribute("", "href", "", "CDATA", PATH + ".css"); in.addAttribute("", "type", "", "CDATA", "text/css"); in.addAttribute("", "rel", "", "CDATA", "stylesheet"); transformer.startElement(null, "link", null, in); ArgumentCaptor<Attributes> attributesCaptor = ArgumentCaptor.forClass(Attributes.class); verify(handler, only()).startElement(isNull(String.class), eq("link"), isNull(String.class), attributesCaptor.capture()); assertEquals(PATH + ".ACSHASH" + FAKE_STREAM_CHECKSUM + ".css", attributesCaptor.getValue().getValue(0)); }