use of org.xml.sax.Attributes in project acs-aem-commons by Adobe-Consulting-Services.
the class VersionedClientlibsTransformerFactoryTest method testCSSClientLibraryWithSameDomainedPath.
@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));
}
use of org.xml.sax.Attributes in project acs-aem-commons by Adobe-Consulting-Services.
the class VersionedClientlibsTransformerFactoryTest method testMinifiedCSSClientLibraryWithEnforceMd5.
@Test
public void testMinifiedCSSClientLibraryWithEnforceMd5() 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 + ".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.ACSHASH" + FAKE_STREAM_CHECKSUM + ".css", attributesCaptor.getValue().getValue(0));
}
use of org.xml.sax.Attributes in project acs-aem-commons by Adobe-Consulting-Services.
the class ContentHandlerAdapterTest method test_adapted_methods.
@Test
public void test_adapted_methods() throws Exception {
final Attributes attrs = new AttributesImpl();
final char[] characters = new char[0];
final char[] whitespace = new char[0];
DefaultHandler adapter = new ContentHandlerAdapter(handler);
adapter.setDocumentLocator(locator);
adapter.startDocument();
adapter.startPrefixMapping("prefix", "uri");
adapter.endPrefixMapping("prefix");
adapter.startElement("uri", "localName", "qName", attrs);
adapter.endElement("uri", "localName", "qName");
adapter.characters(characters, 1, 2);
adapter.ignorableWhitespace(whitespace, 3, 4);
adapter.processingInstruction("target", "data");
adapter.skippedEntity("name");
adapter.endDocument();
verify(handler).setDocumentLocator(locator);
verify(handler).startDocument();
verify(handler).startPrefixMapping("prefix", "uri");
verify(handler).endPrefixMapping("prefix");
verify(handler).startElement("uri", "localName", "qName", attrs);
verify(handler).endElement("uri", "localName", "qName");
verify(handler).characters(characters, 1, 2);
verify(handler).ignorableWhitespace(whitespace, 3, 4);
verify(handler).processingInstruction("target", "data");
verify(handler).skippedEntity("name");
verify(handler).endDocument();
verifyNoMoreInteractions(handler);
}
use of org.xml.sax.Attributes in project ant-ivy by apache.
the class ResolveTest method testResolveConflict.
@Test
public void testResolveConflict() throws Exception {
// mod4.1 v 4.1 depends on
// - mod1.1 v 1.0 which depends on mod1.2 v 2.0
// - mod3.1 v 1.1 which depends on mod1.2 v 2.1
ResolveReport report = ivy.resolve(new File("test/repositories/2/mod4.1/ivy-4.1.xml"), getResolveOptions(new String[] { "*" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org4", "mod4.1", "4.1");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// dependencies
ConfigurationResolveReport crr = report.getConfigurationReport("default");
assertNotNull(crr);
assertEquals(0, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")).length);
assertEquals(1, crr.getDownloadReports(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).length);
File r = getConfigurationResolveReportInCache(ResolveOptions.getDefaultResolveId(md), "default");
assertTrue(r.exists());
final boolean[] found = new boolean[] { false };
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(r, new DefaultHandler() {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
if ("revision".equals(qName) && "2.0".equals(attributes.getValue("name"))) {
found[0] = true;
}
}
});
// the report should contain the evicted revision
assertTrue(found[0]);
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "1.0")).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", "jar", "jar").exists());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org3", "mod3.1", "1.1")).exists());
assertTrue(getArchiveFileInCache("org3", "mod3.1", "1.1", "mod3.1", "jar", "jar").exists());
assertFalse(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").exists());
assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.1")).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.1", "mod1.2", "jar", "jar").exists());
}
use of org.xml.sax.Attributes in project ant-ivy by apache.
the class ResolveTest method testLatest.
@Test
public void testLatest() throws Exception {
// mod1.4 depends on latest mod1.2
ResolveReport report = ivy.resolve(new File("test/repositories/1/org1/mod1.4/ivys/ivy-1.0.1.xml"), getResolveOptions(new String[] { "default" }));
assertNotNull(report);
ModuleDescriptor md = report.getModuleDescriptor();
assertNotNull(md);
ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.1");
assertEquals(mrid, md.getModuleRevisionId());
assertTrue(getResolvedIvyFileInCache(mrid).exists());
// dependencies
ModuleRevisionId depId = ModuleRevisionId.newInstance("org1", "mod1.2", "2.2");
ConfigurationResolveReport crr = report.getConfigurationReport("default");
assertNotNull(crr);
assertEquals(1, crr.getDownloadReports(depId).length);
File r = getConfigurationResolveReportInCache(ResolveOptions.getDefaultResolveId(mrid.getModuleId()), "default");
assertTrue(r.exists());
final boolean[] found = new boolean[] { false };
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(r, new DefaultHandler() {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
if ("artifact".equals(qName) && "mod1.2".equals(attributes.getValue("name"))) {
found[0] = true;
}
}
});
assertTrue(found[0]);
assertTrue(getIvyFileInCache(depId).exists());
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());
}
Aggregations