本文整理汇总了Java中com.jcabi.matchers.XhtmlMatchers类的典型用法代码示例。如果您正苦于以下问题:Java XhtmlMatchers类的具体用法?Java XhtmlMatchers怎么用?Java XhtmlMatchers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XhtmlMatchers类属于com.jcabi.matchers包,在下文中一共展示了XhtmlMatchers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rendersHomePage
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
/**
* App can render front page.
* @throws Exception If some problem inside
*/
@Test
public void rendersHomePage() throws Exception {
final Take take = new TkApp(new FakeBase());
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='self']"
)
);
}
示例2: rendersHomePage
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void rendersHomePage() throws Exception {
final Take take = new TkApp(new FkBase());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
take.act(
new RqWithHeaders(
new RqFake("GET", "/"),
"Accept: text/xml"
)
)
).printBody()
),
XhtmlMatchers.hasXPaths(
"/page/@date",
"/page/@sla",
"/page/millis",
"/page/links/link[@rel='self']"
)
);
}
示例3: createsXml
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void createsXml() throws IOException {
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new Skeleton(
new FakeBase("OverloadMethods", "Bar")
).xml().toString()
),
XhtmlMatchers.hasXPaths(
"/skeleton/app/package[count(class)=2]",
"//class[@id='Bar']/methods[count(method)=5]",
"//class[@id='OverloadMethods']/methods[count(method)=5]",
"//method[@name='<init>' and @ctor='true']",
"//class[@id='Bar']//method[@name='<init>']/ops[count(op)=3]"
)
);
}
示例4: acceptsAndRenders
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
new App(input, output).analyze();
final Mistakes mistakes = new Mistakes();
mistakes.add(output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new Xembler(
new Directives().add("metrics").append(
new Joined<Directive>(mistakes.worst())
)
).xmlQuietly()
),
XhtmlMatchers.hasXPath("/metrics/metric[@id='LCOM']/avg")
);
}
示例5: acceptsAndRenders
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void acceptsAndRenders() throws Exception {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
new App(input, output).analyze();
final Results results = new Results();
results.add("org.takes:takes", output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new Xembler(
new Directives().add("repos").append(
new Joined<Directive>(results.recent())
)
).xmlQuietly()
),
XhtmlMatchers.hasXPath("/repos")
);
}
示例6: rendersMistakesPageInXml
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void rendersMistakesPageInXml() throws IOException {
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
new TkMistakes().act(
new RqWithHeaders(
new RqFake(),
"Accept: application/vnd.jpeek+xml"
)
)
).printBody()
),
XhtmlMatchers.hasXPath("/page/worst")
);
}
示例7: rendersOneReport
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void rendersOneReport() throws Exception {
final ExecutorService service = Executors.newSingleThreadExecutor();
final BiFunc<String, String, Func<String, Response>> bifunc =
new AsyncReports(
new SolidBiFunc<>(
(first, second) -> service.submit(
() -> input -> {
TimeUnit.DAYS.sleep(1L);
return new RsText("done!");
}
)
)
);
final Response response =
bifunc.apply("org.jpeek", "jpeek").apply("index.html");
MatcherAssert.assertThat(
response,
new HmRsStatus(HttpURLConnection.HTTP_OK)
);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(new RsPrint(response).printBody()),
XhtmlMatchers.hasXPath("//xhtml:body")
);
service.shutdownNow();
}
示例8: createsXmlReportWithXpaths
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void createsXmlReportWithXpaths() throws IOException {
final Path output = Files.createTempDirectory("");
new Report(
new Skeleton(
new FakeBase(
"NoMethods", "Bar", "OverloadMethods",
"OnlyOneMethodWithParams", "WithoutAttributes"
)
).xml(),
"LCOM"
).save(output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new TextOf(output.resolve("LCOM.xml")).asString()
),
XhtmlMatchers.hasXPaths(
"/metric/app/package/class/vars",
"/metric/statistics/mean",
"/metric/bars/bar[@x='0' and .='0' and @color='yellow']"
)
);
}
示例9: testsTarget
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void testsTarget() throws IOException {
final Path output = Files.createTempDirectory("");
new Report(
new Skeleton(new FakeBase(this.target)).xml(),
this.metric
).save(output);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new TextOf(
output.resolve(String.format("%s.xml", this.metric))
).asString()
),
XhtmlMatchers.hasXPaths(
String.format(
"//class[@id='%s' and number(@value)=%.4f]",
this.target, this.value
)
)
);
}
示例10: createsXmlReports
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void createsXmlReports() throws IOException {
final Path output = Files.createTempDirectory("").resolve("x1");
final Path input = Paths.get(".");
new App(input, output).analyze();
MatcherAssert.assertThat(
Files.exists(output.resolve("LCOM.xml")),
Matchers.equalTo(true)
);
MatcherAssert.assertThat(
XSLDocument
.make(this.getClass().getResourceAsStream("xsl/metric.xsl"))
.with(new ClasspathSources())
.applyTo(new XMLDocument(output.resolve("LCOM.xml").toFile())),
XhtmlMatchers.hasXPath("//xhtml:body")
);
}
示例11: createsIndexXml
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void createsIndexXml() throws IOException {
final Path output = Files.createTempDirectory("").resolve("x7");
final Path input = Paths.get(".");
new App(input, output).analyze();
MatcherAssert.assertThat(
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]"
)
);
}
示例12: createsXml
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
@Test
public void createsXml() {
final XML xml = new ReportWithStatistics(
new XMLDocument("<metric/>")
);
final int threads = 10;
final ExecutorService service = Executors.newFixedThreadPool(threads);
final CountDownLatch latch = new CountDownLatch(1);
for (int thread = 0; thread < threads; ++thread) {
service.submit(
() -> {
latch.await();
xml.toString();
return null;
}
);
}
latch.countDown();
service.shutdown();
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
xml.toString()
),
XhtmlMatchers.hasXPaths("/metric/statistics[total='0']")
);
}
示例13: rendersHomePageInHtml
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
/**
* 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"
)
);
}
示例14: rendersHomePage
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
/**
* 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']"
)
);
}
示例15: rendersHomePage
import com.jcabi.matchers.XhtmlMatchers; //导入依赖的package包/类
/**
* TkHome can render home page.
* @throws Exception If some problem inside
*/
@Test
public void rendersHomePage() throws Exception {
final Take take = new TkIndex(new FkBase());
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(
new RsPrint(
take.act(
new RqWithHeader(
new RqFake("GET", "/"),
"Accept",
"text/xml"
)
)
).printBody()
),
XhtmlMatchers.hasXPaths(
"/page/millis",
"/page/links/link[@rel='takes:github']",
"/page/total"
)
);
}