nu.xom.Nodes Java Examples
The following examples show how to use
nu.xom.Nodes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreemarkerTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testVersionIndex() throws IOException, TemplateException, URISyntaxException, ParsingException { Path output = DashboardMain.generateVersionIndex( "com.google.cloud", "libraries-bom", ImmutableList.of("1.0.0", "2.0.0", "2.1.0-SNAPSHOT")); Assert.assertTrue( output.endsWith(Paths.get("target", "com.google.cloud", "libraries-bom", "index.html"))); Assert.assertTrue(Files.isRegularFile(output)); Document document = builder.build(output.toFile()); Nodes links = document.query("//a/@href"); Assert.assertEquals(3, links.size()); Node snapshotLink = links.get(2); // 2.1.0-SNAPSHOT has directory 'snapshot' Assert.assertEquals("snapshot/index.html", snapshotLink.getValue()); }
Example #2
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testDashboard_recommendedCoordinates() { Nodes recommendedListItem = dashboard.query("//ul[@id='recommended']/li"); Assert.assertTrue(recommendedListItem.size() > 100); // fails if these are not valid Maven coordinates for (Node node : recommendedListItem) { new DefaultArtifact(node.getValue()); } ImmutableList<String> coordinateList = Streams.stream(recommendedListItem).map(Node::getValue).collect(toImmutableList()); ArrayList<String> sorted = new ArrayList<>(coordinateList); Comparator<String> comparator = new SortWithoutVersion(); Collections.sort(sorted, comparator); for (int i = 0; i < sorted.size(); i++) { Assert.assertEquals( "Coordinates are not sorted: ", sorted.get(i), coordinateList.get(i)); } }
Example #3
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testComponent_linkageCheckResult() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes reports = document.query("//p[@class='jar-linkage-report']"); Assert.assertEquals(1, reports.size()); Truth.assertThat(trimAndCollapseWhiteSpace(reports.get(0).getValue())) .isEqualTo("91 target classes causing linkage errors referenced from 501 source classes."); Nodes causes = document.query("//p[@class='jar-linkage-report-cause']"); Truth.assertWithMessage( "google-http-client-appengine should show linkage errors for RpcStubDescriptor") .that(causes) .comparingElementsUsing(NODE_VALUES) .contains( "Class com.google.net.rpc3.client.RpcStubDescriptor is not found," + " referenced from 21 classes ▶"); // '▶' is the toggle button }
Example #4
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testGlobalUpperBoundUpgradeMessage() throws IOException, ParsingException { // Case 1: BOM needs to be updated Document document = parseOutputFile("com.google.protobuf_protobuf-java-util_3.6.1.html"); Nodes globalUpperBoundBomUpgradeNodes = document.query("//li[@class='global-upper-bound-bom-upgrade']"); Truth.assertThat(globalUpperBoundBomUpgradeNodes.size()).isEqualTo(1); String bomUpgradeMessage = globalUpperBoundBomUpgradeNodes.get(0).getValue(); Truth.assertThat(bomUpgradeMessage).contains( "Upgrade com.google.protobuf:protobuf-java-util:jar:3.6.1 in the BOM to version \"3.7.1\""); // Case 2: Dependency needs to be updated Nodes globalUpperBoundDependencyUpgradeNodes = document.query("//li[@class='global-upper-bound-dependency-upgrade']"); // The artifact report should contain the following 6 global upper bound dependency upgrades: // Upgrade com.google.guava:guava:jar:19.0 to version "27.1-android" // Upgrade com.google.protobuf:protobuf-java:jar:3.6.1 to version "3.7.1" Truth.assertThat(globalUpperBoundDependencyUpgradeNodes.size()).isEqualTo(2); String dependencyUpgradeMessage = globalUpperBoundDependencyUpgradeNodes.get(0).getValue(); Truth.assertThat(dependencyUpgradeMessage).contains( "Upgrade com.google.guava:guava:jar:19.0 to version \"27.1-android\""); }
Example #5
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testComponent_failure() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.api.grpc_grpc-google-common-protos_1.14.0.html"); // com.google.api.grpc:grpc-google-common-protos:1.14.0 has no green section Nodes greens = document.query("//h3[@style='color: green']"); Assert.assertEquals(0, greens.size()); // "Global Upper Bounds Fixes", "Upper Bounds Fixes", and "Suggested Dependency Updates" are red Nodes reds = document.query("//h3[@style='color: red']"); Assert.assertEquals(3, reds.size()); Nodes presDependencyMediation = document.query("//pre[@class='suggested-dependency-mediation']"); Assert.assertTrue( "For failed component, suggested dependency should be shown", presDependencyMediation.size() >= 1); Nodes dependencyTree = document.query("//p[@class='dependency-tree-node']"); Assert.assertTrue( "Dependency Tree should be shown in dashboard even when FAILED", dependencyTree.size() > 0); }
Example #6
Source File: FreemarkerTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testCountFailures() throws IOException, TemplateException, ParsingException { Configuration configuration = DashboardMain.configureFreemarker(); Artifact artifact1 = new DefaultArtifact("io.grpc:grpc-context:1.15.0"); ArtifactResults results1 = new ArtifactResults(artifact1); results1.addResult("Linkage Errors", 56); Artifact artifact2 = new DefaultArtifact("grpc:grpc:1.15.0"); ArtifactResults results2 = new ArtifactResults(artifact2); results2.addResult("Linkage Errors", 0); List<ArtifactResults> table = ImmutableList.of(results1, results2); List<DependencyGraph> globalDependencies = ImmutableList.of(); DashboardMain.generateDashboard( configuration, outputDirectory, table, globalDependencies, symbolProblemTable, new ClassPathResult(LinkedListMultimap.create(), ImmutableList.of()), new Bom("mock:artifact:1.6.7", null)); Path dashboardHtml = outputDirectory.resolve("index.html"); Assert.assertTrue(Files.isRegularFile(dashboardHtml)); Document document = builder.build(dashboardHtml.toFile()); // xom's query cannot specify partial class field, e.g., 'statistic-item' Nodes counts = document.query("//div[@class='container']/div/h2"); Assert.assertTrue(counts.size() > 0); for (int i = 0; i < counts.size(); i++) { Integer.parseInt(counts.get(i).getValue().trim()); } // Linkage Errors Truth.assertThat(counts.get(1).getValue().trim()).isEqualTo("1"); }
Example #7
Source File: XOMTreeBuilder.java From caja with Apache License 2.0 | 5 votes |
@Override protected void appendChildrenToNewParent(Element oldParent, Element newParent) throws SAXException { try { Nodes children = oldParent.removeChildren(); for (int i = 0; i < children.size(); i++) { newParent.appendChild(children.get(i)); } } catch (XMLException e) { fatal(e); } }
Example #8
Source File: XmlEntity.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Use the CacheXmlGenerator to create XML from the entity associated with * the current cache. * * @param element Name of the XML element to search for. * @param attributes * Attributes of the element that should match, for example "name" or * "id" and the value they should equal. * * @return XML string representation of the entity. */ private final String loadXmlDefinition(final String element, final Map<String, String> attributes) { final Cache cache = CacheFactory.getAnyInstance(); Document document = null; try { final StringWriter stringWriter = new StringWriter(); final PrintWriter printWriter = new PrintWriter(stringWriter); CacheXmlGenerator.generate(cache, printWriter, false, false, false); printWriter.close(); // Remove the DOCTYPE line when getting the string to prevent // errors when trying to locate the DTD. String xml = stringWriter.toString().replaceFirst("<!DOCTYPE.*>", ""); document = new Builder(false).build(xml, null); } catch (ValidityException vex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", vex); } catch (ParsingException pex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", pex); } catch (IOException ioex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", ioex); } Nodes nodes = document.query(createQueryString(element, attributes)); if (nodes.size() != 0) { return nodes.get(0).toXML(); } cache.getLogger().warning("No XML definition could be found with name=" + element + " and attributes=" + attributes); return null; }
Example #9
Source File: XmlUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static Node getNode(Document doc, String entityType, String entityName) { String query = createQueryStringByName(entityType, entityName); Nodes nodes = doc.query(query); if (nodes != null && nodes.size() > 0) { return nodes.get(0); } return null; }
Example #10
Source File: XmlEntity.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Use the CacheXmlGenerator to create XML from the entity associated with * the current cache. * * @param element Name of the XML element to search for. * @param attributes * Attributes of the element that should match, for example "name" or * "id" and the value they should equal. * * @return XML string representation of the entity. */ private final String loadXmlDefinition(final String element, final Map<String, String> attributes) { final Cache cache = CacheFactory.getAnyInstance(); Document document = null; try { final StringWriter stringWriter = new StringWriter(); final PrintWriter printWriter = new PrintWriter(stringWriter); CacheXmlGenerator.generate(cache, printWriter, false, false, false); printWriter.close(); // Remove the DOCTYPE line when getting the string to prevent // errors when trying to locate the DTD. String xml = stringWriter.toString().replaceFirst("<!DOCTYPE.*>", ""); document = new Builder(false).build(xml, null); } catch (ValidityException vex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", vex); } catch (ParsingException pex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", pex); } catch (IOException ioex) { cache.getLogger().error("Could not parse XML when creating XMLEntity", ioex); } Nodes nodes = document.query(createQueryString(element, attributes)); if (nodes.size() != 0) { return nodes.get(0).toXML(); } cache.getLogger().warning("No XML definition could be found with name=" + element + " and attributes=" + attributes); return null; }
Example #11
Source File: XmlUtils.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static Node getNode(Document doc, String entityType, String entityName) { String query = createQueryStringByName(entityType, entityName); Nodes nodes = doc.query(query); if (nodes != null && nodes.size() > 0) { return nodes.get(0); } return null; }
Example #12
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testDependencyTrees() throws IOException, ParsingException { Document document = parseOutputFile("dependency_trees.html"); Nodes dependencyTreeParagraph = document.query("//p[@class='dependency-tree-node']"); Assert.assertEquals(53144, dependencyTreeParagraph.size()); Assert.assertEquals( "com.google.protobuf:protobuf-java:jar:3.6.1", dependencyTreeParagraph.get(0).getValue()); }
Example #13
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInUnstableArtifacts() throws IOException, ParsingException { Document document = parseOutputFile("unstable_artifacts.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #14
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInArtifactDetails() throws IOException, ParsingException { Document document = parseOutputFile("artifact_details.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #15
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testBomCoordinatesInComponent() throws IOException, ParsingException { Document document = parseOutputFile("com.google.protobuf_protobuf-java-util_3.6.1.html"); Nodes bomCoordinatesNodes = document.query("//p[@class='bom-coordinates']"); Assert.assertEquals(1, bomCoordinatesNodes.size()); Assert.assertEquals( "BOM: com.google.cloud:libraries-bom:1.0.0", bomCoordinatesNodes.get(0).getValue()); }
Example #16
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testZeroLinkageErrorShowsZero() throws IOException, ParsingException { // grpc-auth does not have a linkage error, and it should show zero in the section Document document = parseOutputFile("io.grpc_grpc-auth_1.20.0.html"); Nodes linkageErrorsTotal = document.query("//p[@id='linkage-errors-total']"); Truth.assertThat(linkageErrorsTotal.size()).isEqualTo(1); Truth.assertThat(linkageErrorsTotal.get(0).getValue()) .contains("0 linkage error(s)"); }
Example #17
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testLinkageErrors_ensureNoDuplicateSymbols() throws IOException, ParsingException { Document document = parseOutputFile("com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes linkageCheckMessages = document.query("//p[@class='jar-linkage-report-cause']"); Truth.assertThat(linkageCheckMessages.size()).isGreaterThan(0); List<String> messages = new ArrayList<>(); for (int i = 0; i < linkageCheckMessages.size(); ++i) { messages.add(linkageCheckMessages.get(i).getValue()); } // When uniqueness of SymbolProblem and Symbol classes are incorrect, dashboard has duplicates. Truth.assertThat(messages).containsNoDuplicates(); }
Example #18
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testLinkageErrorsInProvidedDependency() throws IOException, ParsingException { // google-http-client-appengine has provided dependency to (problematic) appengine-api-1.0-sdk Document document = parseOutputFile( "com.google.http-client_google-http-client-appengine_1.29.1.html"); Nodes linkageCheckMessages = document.query("//ul[@class='jar-linkage-report-cause']/li"); Truth.assertThat(linkageCheckMessages.size()).isGreaterThan(0); Truth.assertThat(linkageCheckMessages.get(0).getValue()) .contains("com.google.appengine.api.appidentity.AppIdentityServicePb"); }
Example #19
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testComponent_success() throws IOException, ParsingException { Document document = parseOutputFile( "com.google.api.grpc_proto-google-common-protos_1.14.0.html"); Nodes greens = document.query("//h3[@style='color: green']"); Assert.assertTrue(greens.size() >= 2); Nodes presDependencyMediation = document.query("//pre[@class='suggested-dependency-mediation']"); // There's a pre tag for dependency Assert.assertEquals(1, presDependencyMediation.size()); Nodes presDependencyTree = document.query("//p[@class='dependency-tree-node']"); Assert.assertTrue( "Dependency Tree should be shown in dashboard", presDependencyTree.size() > 0); }
Example #20
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testDashboard_unstableDependencies() { // Pre 1.0 version section Nodes li = unstable.query("//ul[@id='unstable']/li"); Assert.assertTrue(li.size() > 1); for (int i = 0; i < li.size(); i++) { String value = li.get(i).getValue(); Assert.assertTrue(value, value.contains(":0")); } // This element appears only when every dependency becomes stable Nodes stable = dashboard.query("//p[@id='stable-notice']"); Assert.assertEquals(0, stable.size()); }
Example #21
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testLinkageReports() { Nodes reports = details.query("//p[@class='jar-linkage-report']"); // appengine-api-sdk, shown as first item in linkage errors, has these errors Truth.assertThat(trimAndCollapseWhiteSpace(reports.get(0).getValue())) .isEqualTo( "91 target classes causing linkage errors referenced from 501 source classes."); Nodes dependencyPaths = details.query("//p[@class='linkage-check-dependency-paths']"); Node dependencyPathMessageOnProblem = dependencyPaths.get(dependencyPaths.size() - 4); Assert.assertEquals( "The following paths contain com.google.guava:guava-jdk5:13.0:", trimAndCollapseWhiteSpace(dependencyPathMessageOnProblem.getValue())); Node dependencyPathMessageOnSource = dependencyPaths.get(dependencyPaths.size() - 3); Assert.assertEquals( "The following paths contain com.google.guava:guava:27.1-android:", trimAndCollapseWhiteSpace(dependencyPathMessageOnSource.getValue())); Nodes nodesWithPathsSummary = details.query("//p[@class='linkage-check-dependency-paths']"); Truth.assertWithMessage("The dashboard should not show repetitive dependency paths") .that(nodesWithPathsSummary) .comparingElementsUsing( Correspondence.<Node, String>transforming( node -> trimAndCollapseWhiteSpace(node.getValue()), "has text")) .contains( "Dependency path 'commons-logging:commons-logging > javax.servlet:servlet-api' exists" + " in all 1337 dependency paths. Example path:" + " com.google.http-client:google-http-client:1.29.1 (compile) /" + " org.apache.httpcomponents:httpclient:4.5.5 (compile) /" + " commons-logging:commons-logging:1.2 (compile) / javax.servlet:servlet-api:2.3" + " (provided, optional)"); }
Example #22
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testDashboard_statisticBox() { Nodes artifactCount = dashboard.query("//div[@class='statistic-item statistic-item-green']/h2"); Assert.assertTrue(artifactCount.size() > 0); for (Node artifactCountElement : artifactCount) { String value = artifactCountElement.getValue().trim(); Assert.assertTrue(value, Integer.parseInt(value) > 0); } }
Example #23
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testArtifactDetails() throws IOException, ArtifactDescriptorException { List<Artifact> artifacts = Bom.readBom("com.google.cloud:libraries-bom:1.0.0") .getManagedDependencies(); Assert.assertTrue("Not enough artifacts found", artifacts.size() > 1); Assert.assertEquals("en-US", dashboard.getRootElement().getAttribute("lang").getValue()); Nodes tr = details.query("//tr"); Assert.assertEquals(artifacts.size() + 1, tr.size()); // header row adds 1 for (int i = 1; i < tr.size(); i++) { // start at 1 to skip header row Nodes td = tr.get(i).query("td"); Assert.assertEquals(Artifacts.toCoordinates(artifacts.get(i - 1)), td.get(0).getValue()); for (int j = 1; j < 5; ++j) { // start at 1 to skip the leftmost artifact coordinates column assertValidCellValue((Element) td.get(j)); } } Nodes href = details.query("//tr/td[@class='artifact-name']/a/@href"); for (int i = 0; i < href.size(); i++) { String fileName = href.get(i).getValue(); Artifact artifact = artifacts.get(i); Assert.assertEquals( Artifacts.toCoordinates(artifact).replace(':', '_') + ".html", URLDecoder.decode(fileName, "UTF-8")); Path componentReport = outputDirectory.resolve(fileName); Assert.assertTrue(fileName + " is missing", Files.isRegularFile(componentReport)); try { Document report = builder.build(componentReport.toFile()); Assert.assertEquals("en-US", report.getRootElement().getAttribute("lang").getValue()); } catch (ParsingException ex) { byte[] data = Files.readAllBytes(componentReport); String message = "Could not parse " + componentReport + " at line " + ex.getLineNumber() + ", column " + ex.getColumnNumber() + "\r\n"; message += ex.getMessage() + "\r\n"; message += new String(data, StandardCharsets.UTF_8); Assert.fail(message); } } }
Example #24
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testHeader() { Nodes h1 = dashboard.query("//h1"); Assert.assertEquals(1, h1.size()); Assert.assertEquals("com.google.cloud:libraries-bom:1.0.0 Dependency Status", h1.get(0).getValue()); }
Example #25
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test // https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/617 public void testPlural() { Nodes statisticItems = dashboard.query("//section[@class='statistics']/div/div"); for (Node node : statisticItems) { Node h2 = node.query("h2").get(0); Node span = node.query("span").get(0); int errorCount = Integer.parseInt(h2.getValue()); if (errorCount == 1) { String message = span.getValue(); Assert.assertEquals("Has Linkage Errors", message); } } Assert.assertFalse(dashboard.toXML().contains("1 HAVE")); }
Example #26
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
@Test public void testDashboard_lastUpdatedField() { Nodes updated = dashboard.query("//p[@id='updated']"); Assert.assertEquals( "Could not find updated field: " + dashboard.toXML(), 1, updated.size()); }
Example #27
Source File: DashboardTest.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
@Test public void testSvg() { XPathContext context = new XPathContext("svg", "http://www.w3.org/2000/svg"); Nodes svg = dashboard.query("//svg:svg", context); Assert.assertEquals(4, svg.size()); }
Example #28
Source File: DashboardUnavailableArtifactTest.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
@Test public void testDashboardWithRepositoryException() throws IOException, TemplateException, ParsingException { Configuration configuration = DashboardMain.configureFreemarker(); Artifact validArtifact = new DefaultArtifact("io.grpc:grpc-context:1.15.0"); ArtifactResults validArtifactResult = new ArtifactResults(validArtifact); validArtifactResult.addResult(DashboardMain.TEST_NAME_UPPER_BOUND, 0); validArtifactResult.addResult(DashboardMain.TEST_NAME_DEPENDENCY_CONVERGENCE, 0); validArtifactResult.addResult(DashboardMain.TEST_NAME_GLOBAL_UPPER_BOUND, 0); Artifact invalidArtifact = new DefaultArtifact("io.grpc:nonexistent:jar:1.15.0"); ArtifactResults errorArtifactResult = new ArtifactResults(invalidArtifact); errorArtifactResult.setExceptionMessage( "Could not find artifact io.grpc:nonexistent:jar:1.15.0 in central" + " (https://repo1.maven.org/maven2/)"); List<ArtifactResults> table = new ArrayList<>(); table.add(validArtifactResult); table.add(errorArtifactResult); DashboardMain.generateDashboard( configuration, outputDirectory, table, ImmutableList.of(), ImmutableMap.of(), new ClassPathResult(LinkedListMultimap.create(), ImmutableList.of()), bom); Path generatedHtml = outputDirectory.resolve("artifact_details.html"); Assert.assertTrue(Files.isRegularFile(generatedHtml)); Document document = builder.build(generatedHtml.toFile()); Assert.assertEquals("en-US", document.getRootElement().getAttribute("lang").getValue()); Nodes tr = document.query("//tr"); Assert.assertEquals( "The size of rows in table should match the number of artifacts + 1 (header)", tr.size(),table.size() + 1); Nodes tdForValidArtifact = tr.get(1).query("td"); Assert.assertEquals( Artifacts.toCoordinates(validArtifact), tdForValidArtifact.get(0).getValue()); Element firstResult = (Element) (tdForValidArtifact.get(2)); Truth.assertThat(firstResult.getValue().trim()).isEqualTo("PASS"); Truth.assertThat(firstResult.getAttributeValue("class")).isEqualTo("pass"); Nodes tdForErrorArtifact = tr.get(2).query("td"); Assert.assertEquals( Artifacts.toCoordinates(invalidArtifact), tdForErrorArtifact.get(0).getValue()); Element secondResult = (Element) (tdForErrorArtifact.get(2)); Truth.assertThat(secondResult.getValue().trim()).isEqualTo("UNAVAILABLE"); Truth.assertThat(secondResult.getAttributeValue("class")).isEqualTo("unavailable"); }
Example #29
Source File: XOMTreeBuilder.java From caja with Apache License 2.0 | 4 votes |
Nodes getDocumentFragment() { Element rootElt = document.getRootElement(); Nodes rv = rootElt.removeChildren(); document = null; return rv; }
Example #30
Source File: HtmlBuilder.java From caja with Apache License 2.0 | 3 votes |
/** * Parse a fragment from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @param context the name of the context element * @return the fragment * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Nodes buildFragment(InputSource is, String context) throws IOException, ParsingException { xomTreeBuilder.setFragmentContext(context.intern()); tokenize(is); return xomTreeBuilder.getDocumentFragment(); }