com.jcabi.matchers.XhtmlMatchers Java Examples
The following examples show how to use
com.jcabi.matchers.XhtmlMatchers.
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: MetricsTest.java From jpeek with MIT License | 7 votes |
@ParameterizedTest @CsvFileSource(resources = "/org/jpeek/metricstest-params.csv") public void testsTarget(final String target, final String metric, final double value, @TempDir final Path output) throws Exception { new XslReport( new Skeleton(new FakeBase(target)).xml(), new XslCalculus(), new ReportData(metric) ).save(output); final String xpath; if (Double.isNaN(value)) { xpath = "//class[@id='%s' and @value='NaN']"; } else { xpath = "//class[@id='%s' and number(@value)=%.4f]"; } new Assertion<>( new FormattedText( "Must exists with target '%s' and value '%s'", target, value ).asString(), XhtmlMatchers.xhtml( new TextOf( output.resolve(String.format("%s.xml", metric)) ).asString() ), XhtmlMatchers.hasXPaths( String.format( xpath, target, value ) ) ).affirm(); }
Example #2
Source File: XeSlaTest.java From takes with MIT License | 6 votes |
/** * XeSLA can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeSla() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root[@sla]" ) ); }
Example #3
Source File: ResultsTest.java From jpeek with MIT License | 6 votes |
@Test @Disabled public void acceptsAndRenders(@TempDir final Path output) throws Exception { final Path input = Paths.get("."); new App(input, output).analyze(); final Results results = new Results(); results.add("org.takes:takes", output); new Assertion<>( "Must exists repos tag", XhtmlMatchers.xhtml( new Xembler( new Directives().add("repos").append( new Joined<>(results.recent()) ) ).xmlQuietly() ), XhtmlMatchers.hasXPath("/repos") ).affirm(); }
Example #4
Source File: XslReportTest.java From jpeek with MIT License | 6 votes |
@Test public void setsCorrectSchemaLocation(@TempDir final Path output) throws IOException { new XslReport( new Skeleton(new FakeBase()).xml(), new XslCalculus(), new ReportData("LCOM") ).save(output); new Assertion<>( "Must have correct schema location", XhtmlMatchers.xhtml( new TextOf(output.resolve("LCOM.xml")).asString() ), XhtmlMatchers.hasXPaths( // @checkstyle LineLength (1 line) "/metric[@xsi:noNamespaceSchemaLocation = 'xsd/metric.xsd']" ) ).affirm(); }
Example #5
Source File: AppTest.java From jpeek with MIT License | 6 votes |
@Test public void canIncludePrivateMethods(@TempDir final Path output) throws IOException { final Path input = Paths.get("."); final Map<String, Object> args = new HashMap<>(); args.put("include-private-methods", 1); new App(input, output, args).analyze(); new Assertion<>( "Must contain private method", XhtmlMatchers.xhtml( new TextOf(output.resolve("skeleton.xml")).asString() ), XhtmlMatchers.hasXPaths( "//method[@visibility='private']" ) ).affirm(); }
Example #6
Source File: AppTest.java From jpeek with MIT License | 6 votes |
@Test public void createsIndexXml(@TempDir final Path output) throws IOException { final Path input = Paths.get("."); new App(input, output).analyze(); new Assertion<>( "Must have some metrics", XhtmlMatchers.xhtml( new TextOf(output.resolve("index.xml")).asString() ), XhtmlMatchers.hasXPaths( "/index[@score!='0.0000']", "/index[@score!='NaN']", "/index[@diff!='NaN']", "/index[count(metric)>0]" ) ).affirm(); }
Example #7
Source File: TkIndexTest.java From jare with MIT License | 6 votes |
/** * TkIndex can render home page in HTML. * @throws Exception If some problem inside */ @Test public void rendersHomePageInHtml() throws Exception { final Take take = new TkAppAuth(new TkIndex(new FkBase())); MatcherAssert.assertThat( XhtmlMatchers.xhtml( new RsPrint( take.act(new RqFake("GET", "/")) ).printBody() ), XhtmlMatchers.hasXPaths( "/xhtml:html", "/xhtml:html/xhtml:body" ) ); }
Example #8
Source File: TkAppTest.java From jare with MIT License | 6 votes |
/** * App can render front page. * @throws Exception If some problem inside */ @Test public void rendersHomePage() throws Exception { final Take take = new TkApp(new FkBase()); MatcherAssert.assertThat( XhtmlMatchers.xhtml( new RsPrint( take.act( new RqWithHeader( new RqFake("GET", "/"), // @checkstyle MultipleStringLiteralsCheck (1 line) "Accept", "text/xml" ) ) ).printBody() ), XhtmlMatchers.hasXPaths( "/page/@date", "/page/@sla", "/page/millis", "/page/links/link[@rel='takes:logout']" ) ); }
Example #9
Source File: XmlAttributeTest.java From eo with MIT License | 6 votes |
@Test public void compileToXml() throws Exception { MatcherAssert.assertThat( XhtmlMatchers.xhtml( new Xembler( new XmlAttribute( "count", "Number" ) ).xml() ), XhtmlMatchers.hasXPath( "/attribute[@name = 'count']/type[@name = 'Number']" ) ); }
Example #10
Source File: XeLogoutLinkTest.java From takes with MIT License | 6 votes |
/** * XeLogoutLink can create a correct link. * @throws IOException If some problem inside */ @Test public void generatesCorrectLink() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLogoutLink(new RqFake()) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='takes:logout']" ) ); }
Example #11
Source File: XeIdentityTest.java From takes with MIT License | 6 votes |
/** * XeIdentity can create a correct link. * @throws IOException If some problem inside */ @Test public void generatesIdentityInXml() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeIdentity( new RqWithHeader( new RqFake(), TkAuth.class.getSimpleName(), "urn:test:1;name=Jeff" ) ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/identity[urn='urn:test:1']", "/root/identity[name='Jeff']" ) ); }
Example #12
Source File: XeGoogleLinkTest.java From takes with MIT License | 6 votes |
/** * XeGoogleLink can create a correct link. * @throws IOException If some problem inside */ @Test public void generatesCorrectLink() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeGoogleLink(new RqFake(), "abcdef") ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='takes:google']" ) ); }
Example #13
Source File: XeGithubLinkTest.java From takes with MIT License | 6 votes |
/** * XeGithubLink can create a correct link. * @throws IOException If some problem inside */ @Test public void generatesCorrectLink() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeGithubLink(new RqFake(), "abcdef") ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='takes:github']" ) ); }
Example #14
Source File: XeFacebookLinkTest.java From takes with MIT License | 6 votes |
/** * XeFacebookLink can create a correct link. * @throws IOException If some problem inside */ @Test public void generatesCorrectLink() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeFacebookLink(new RqFake(), "abcdef") ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='takes:facebook']" ) ); }
Example #15
Source File: XeDateTest.java From takes with MIT License | 6 votes |
/** * XeDate can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeDate() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root[@date]" ) ); }
Example #16
Source File: AppTest.java From jpeek with MIT License | 6 votes |
@Test public void createsXmlReports(@TempDir final Path output) throws IOException { final Path input = Paths.get("."); new App(input, output).analyze(); new Assertion<>( "Must LCOM.xml file exists", Files.exists(output.resolve("LCOM.xml")), new IsTrue() ).affirm(); new Assertion<>( "Must create LCOM report", XSLDocument .make( AppTest.class.getResourceAsStream("xsl/metric.xsl") ) .with(new ClasspathSources()) .applyTo(new XMLDocument(output.resolve("LCOM.xml").toFile())), XhtmlMatchers.hasXPath("//xhtml:body") ).affirm(); }
Example #17
Source File: XeSlaTest.java From takes with MIT License | 6 votes |
/** * XeSLA can build HTML response with default XSL template. * @throws IOException If some problem inside */ @Test public void buildsHtmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXslt( new RsXembly( new XeStylesheet("/org/takes/rs/xe/test_sla.xsl"), new XeAppend( "page", new XeSla() ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/xhtml:html/xhtml:span" ) ); }
Example #18
Source File: XeLocalhostTest.java From takes with MIT License | 6 votes |
/** * XeLocalhost can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLocalhost() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root[@ip]" ) ); }
Example #19
Source File: XeWhenTest.java From takes with MIT License | 6 votes |
/** * XeWhen can build XML response. * * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "test", new XeWhen( true, new XeDate() ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/test[@date]" ) ); }
Example #20
Source File: XeWhenTest.java From takes with MIT License | 6 votes |
/** * XeWhen can build XML response with positive condition. * * @throws IOException If some problem inside */ @Test public void buildsXmlResponseFromPositiveCondition() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "positive", new XeWhen( true, new XeDate(), new XeMemory() ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/positive[@date]" ) ); }
Example #21
Source File: XeLinkTest.java From takes with MIT License | 6 votes |
/** * XeLink can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLink("hey", "#a") ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='hey' and @href='#a']" ) ); }
Example #22
Source File: XeAppendTest.java From takes with MIT License | 6 votes |
/** * XeAppend can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "test", new XeDate(), new XeLocalhost() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/test[@date and @ip]" ) ); }
Example #23
Source File: XeMillisTest.java From takes with MIT License | 6 votes |
/** * XeMillis can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeMillis(false), new XeMillis(true) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/millis" ) ); }
Example #24
Source File: XeMillisTest.java From takes with MIT License | 6 votes |
/** * XeMillis can build HTML response with default XSL template. * @throws IOException If some problem inside */ @Test public void buildsHtmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXslt( new RsXembly( new XeStylesheet("/org/takes/rs/xe/test_millis.xsl"), new XeAppend( "page", new XeMillis(false), new XeMillis(true) ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/xhtml:html/xhtml:span" ) ); }
Example #25
Source File: XeLinkHomeTest.java From takes with MIT License | 6 votes |
/** * XeHomeLink can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLinkHome(new RqFake()) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='home']" ) ); }
Example #26
Source File: XeMemoryTest.java From takes with MIT License | 6 votes |
/** * XeMemory can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeMemory() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/memory[@total and @max and @free]" ) ); }
Example #27
Source File: XeMemoryTest.java From takes with MIT License | 6 votes |
/** * XeMillis can build HTML response with default XSL template. * @throws IOException If some problem inside */ @Test public void buildsHtmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXslt( new RsXembly( new XeStylesheet("/org/takes/rs/xe/test_memory.xsl"), new XeAppend( "page", new XeMemory() ) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/xhtml:html/xhtml:span" ) ); }
Example #28
Source File: XeLinkSelfTest.java From takes with MIT License | 6 votes |
/** * XeHomeSelf can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLinkSelf(new RqFake()) ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root/links/link[@rel='self']" ) ); }
Example #29
Source File: XeLifetimeTest.java From takes with MIT License | 6 votes |
/** * XeLifetime can build XML response. * @throws IOException If some problem inside */ @Test public void buildsXmlResponse() throws IOException { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( new XeAppend( "root", new XeLifetime() ) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPaths( "/root[@lifetime]" ) ); }
Example #30
Source File: RsXsltTest.java From takes with MIT License | 6 votes |
/** * RsXSLT can load XSL stylesheets from the web. * @throws IOException If some problem inside */ @Test public void loadsExternalImports() throws IOException { final Text xml = new Joined( " ", "<?xml-stylesheet ", " href='/org/takes/rs/stylesheet-with-include.xsl'", " type='text/xsl'?><page sla='0.324'/>" ); MatcherAssert.assertThat( IOUtils.toString( new RsXslt( new RsText(new InputStreamOf(xml)) ).body(), StandardCharsets.UTF_8 ), XhtmlMatchers.hasXPath( "/xhtml:html/xhtml:span[starts-with(@class, 'sla ')]" ) ); }