use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.
the class MavenComponentLibraryInfoSource method parse.
private ComponentLibraryInfo parse(InputStream inputStream) {
ComponentLibraryInfo info = null;
if (inputStream != null) {
Document document;
try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(inputStream);
} catch (Exception e) {
logger.warn("Exception while parsing pom.xml", e);
return null;
}
info = new ComponentLibraryInfo();
info.setGroupId(extractText(document, "(/project/groupId | /project/parent/groupId)[1]"));
info.setArtifactId(extractText(document, "/project/artifactId"));
info.setVersion(extractText(document, "/project/version"));
info.setName(extractText(document, "/project/name"));
info.setDescription(extractText(document, "/project/description"));
info.setDocumentationUrl(extractText(document, "/project/properties/documentationUrl"));
info.setHomepageUrl(extractText(document, "/project/properties/homepageUrl"));
info.setIssueTrackerUrl(extractText(document, "/project/issueManagement/url"));
info.setJavadocUrl(extractText(document, "/project/properties/javadocUrl"));
info.setSourceBrowseUrl(extractText(document, "/project/scm/url"));
info.setSourceRootUrl(extractText(document, "/project/properties/sourceRootUrl"));
info.setTapestryVersion(extractText(document, "(/project/dependencies/dependency[./groupId='org.apache.tapestry'][./artifactId='tapestry-core']/version | /project/properties/tapestryVersion)[1]"));
String tags = extractText(document, "/project/properties/tags");
if (tags != null && tags.length() > 0) {
info.setTags(Arrays.asList(tags.split(",")));
}
}
return info;
}
use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.
the class DocumentLinkerImpl method updateDocument.
/**
* Updates the supplied Document, possibly adding <head> or <body> elements.
*
* @param document
* to be updated
*/
public void updateDocument(Document document) {
Element root = document.getRootElement();
if (root == null) {
return;
}
// TAP5-2200: Generating XML from pages and templates is not possible anymore
// only add JavaScript and CSS if we're actually generating
final String mimeType = document.getMimeType();
if (mimeType != null && !HTML_MIME_TYPES.contains(mimeType)) {
return;
}
addStylesheetsToHead(root, includedStylesheets);
// only add the generator meta only to html documents
boolean isHtmlRoot = root.getName().equals("html");
if (!omitGeneratorMetaTag && isHtmlRoot) {
Element head = findOrCreateElement(root, "head", true);
Element existingMeta = head.find("meta");
addElementBefore(head, existingMeta, "meta", "name", "generator", "content", tapestryBanner);
}
addScriptElements(root);
}
use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.
the class TemplateInContextTest method template_in_web_context.
@Test
public void template_in_web_context() {
tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
Document doc = tester.renderPage("TestPageForTemplateInContext");
assertTrue(doc.toString().contains("How are you?"));
}
use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.
the class UnlessTest method render.
@Test
public void render() {
tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
Document doc = tester.renderPage("TestPageForUnless");
assertNotNull(doc.getElementById("2"));
assertNotNull(doc.getElementById("4"));
assertNotNull(doc.getElementById("6"));
assertNotNull(doc.getElementById("7"));
assertNull(doc.getElementById("1"));
assertNull(doc.getElementById("3"));
assertNull(doc.getElementById("5"));
assertNull(doc.getElementById("8"));
}
use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.
the class PageTesterTest method on_activate_chain_is_followed.
@Test(dataProvider = "testers")
public void on_activate_chain_is_followed(PageTester tester) {
Document launchDoc = tester.renderPage("Launch");
Map<String, String> parameters = Collections.emptyMap();
// Submit the form, which will then skip through Intermediate and
// arrive at Final.
Document finalDoc = tester.submitForm(launchDoc.getElementById("form"), parameters);
assertEquals(finalDoc.getElementById("page-name").getChildMarkup(), "Final");
}
Aggregations