本文整理汇总了Java中com.jcabi.matchers.JaxbConverter类的典型用法代码示例。如果您正苦于以下问题:Java JaxbConverter类的具体用法?Java JaxbConverter怎么用?Java JaxbConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JaxbConverter类属于com.jcabi.matchers包,在下文中一共展示了JaxbConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxHuman can be converted to XML.
* @throws Exception If fails
*/
@Test
public void convertsToXml() throws Exception {
final JxHuman Human = new JxHuman(new MkHuman());
MatcherAssert.assertThat(
JaxbConverter.the(Human),
XhtmlMatchers.hasXPaths(
"/human[name='Jeff Lebowski']",
"/human[urn='urn:test:1']",
"/human[age=30]",
"/human[locale='en']",
"/human[sex='M']",
"/human/links/link[@rel='photo']/@href"
)
);
}
开发者ID:aintshy,项目名称:hub,代码行数:20,代码来源:JxHumanTest.java
示例2: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxRole can be converted to XML.
* @throws Exception If fails
*/
@Test
public void convertsToXml() throws Exception {
final JxRole talker = new JxRole(
new Role(new MkTalk(), new MkHuman())
);
MatcherAssert.assertThat(
JaxbConverter.the(talker),
XhtmlMatchers.hasXPaths(
"/role[name='Jeff Lebowski']",
"/role[age=30]",
"/role[sex='M']",
"/role/links/link[@rel='photo']",
"/role[asking='false']"
)
);
}
开发者ID:aintshy,项目名称:hub,代码行数:21,代码来源:JxRoleTest.java
示例3: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxStory can be converted to XML.
* @throws Exception If fails
*/
@Test
public void convertsToXml() throws Exception {
final BaseRs base = new ResourceMocker().mock(BaseRs.class);
final JxStory story = new JxStory(
new MkTalk(), new MkHuman(), base
);
MatcherAssert.assertThat(
JaxbConverter.the(story),
XhtmlMatchers.hasXPaths(
"/story/role[name='Jeff Lebowski']",
"/story/role[age=30]",
"/story/role[sex='M']",
"/story/role/links/link[@rel='photo']",
"/story/messages",
"/story/question",
"/story/number"
)
);
}
开发者ID:aintshy,项目名称:hub,代码行数:24,代码来源:JxStoryTest.java
示例4: rendersFrontPage
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* IndexRs can render front page.
* @throws Exception If some problem inside
*/
@Test
public void rendersFrontPage() throws Exception {
final IndexRs res = new IndexRs();
res.setUriInfo(new UriInfoMocker().mock());
res.setHttpHeaders(new HttpHeadersMocker().mock());
final SecurityContext sec = Mockito.mock(SecurityContext.class);
res.setSecurityContext(sec);
final Response response = res.index();
MatcherAssert.assertThat(
JaxbConverter.the(response.getEntity()),
XhtmlMatchers.hasXPaths(
"/page/millis",
"/page/version/name"
)
);
}
开发者ID:yegor256,项目名称:requs,代码行数:21,代码来源:IndexRsTest.java
示例5: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxQuote can be converted to XML.
* @throws Exception If some problem inside
*/
@Test
public void convertsToXml() throws Exception {
final Quote quote = new MkQuote();
MatcherAssert.assertThat(
JaxbConverter.the(
new JxQuote(quote, new ResourceMocker().mock(BaseRs.class))
),
XhtmlMatchers.hasXPaths(
String.format("/quote[@id='%d']", quote.number()),
String.format("/quote[text='%s']", quote.text()),
String.format("/quote/book[name='%s']", quote.book().name()),
"/quote/links/link[@rel='open' and @href]",
"/quote/tags/tag[user='jeff' and name='works-fine']"
)
);
}
开发者ID:yegor256,项目名称:bibrarian,代码行数:21,代码来源:JxQuoteTest.java
示例6: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* Link can be converted to XML.
* @throws Exception If there is some problem inside
*/
@Test
public void convertsToXml() throws Exception {
final Link link = new Link(
"foo",
UriBuilder.fromUri("http://bar").build(),
MediaType.TEXT_XML
);
link.with(new JaxbBundle("label", "some label"));
MatcherAssert.assertThat(
JaxbConverter.the(link),
XhtmlMatchers.hasXPaths(
"/link[@rel='foo']",
"/link[@href='http://bar']",
"/link[@type='text/xml']",
"/link[label='some label']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:23,代码来源:LinkTest.java
示例7: convertsToXmlWithoutLinks
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* BasePage can be converted to XML without links.
* @throws Exception If there is some problem inside
*/
@Test
public void convertsToXmlWithoutLinks() throws Exception {
final BaseResource res = new BasePageTest.EmptyRs();
res.setUriInfo(new UriInfoMocker().mock());
res.setHttpHeaders(new HttpHeadersMocker().mock());
res.setSecurityContext(Mockito.mock(SecurityContext.class));
final BasePageTest.FooPage page = new BasePageTest.FooPage().init(res);
MatcherAssert.assertThat(
JaxbConverter.the(page.render().build().getEntity()),
XhtmlMatchers.hasXPaths(
"/page[count(links) = 0]",
"/page[@ip and @ssl]"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:20,代码来源:BasePageTest.java
示例8: readsCookieAndAddsHttpHeader
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* AuthInset can read cookie and add a cleaning header.
* @throws Exception If there is some problem inside
*/
@Test
public void readsCookieAndAddsHttpHeader() throws Exception {
final String key = "74^54\u20ac";
final URN urn = new URN("urn:test:7362423");
final String name = "John \u20ac Smith";
final String cookie = AuthInset.encrypt(
new IdentityMocker()
.withURN(urn)
.withName(name)
.mock(),
key
);
final Resource resource = this.resource(cookie);
final Inset inset = new AuthInset(resource, key);
final BasePage<?, ?> page = new BasePageMocker().init(resource);
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
XhtmlMatchers.hasXPaths(
String.format("/*/identity[name='%s']", name),
String.format("/*/identity[urn='%s']", urn),
"/*/identity/token"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:30,代码来源:AuthInsetTest.java
示例9: convertsItselfToXmlThroughJaxb
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JaxbBundle can be converted to XML through JAXB.
* @throws Exception If there is some problem inside
*/
@Test
public void convertsItselfToXmlThroughJaxb() throws Exception {
final JaxbBundle bundle = new JaxbBundle("alef")
.add("beta-1")
.attr("full-name", "Joe")
.up()
.link(new Link("add", "#add"))
.add("beta-2")
.add("gamma", "works fine, isn't it?")
.up()
.up();
final BasePageMocker page = new BasePageMocker()
.init(new ResourceMocker().mock());
page.append(bundle.element());
MatcherAssert.assertThat(
JaxbConverter.the(page),
XhtmlMatchers.hasXPaths(
"/foo/alef/beta-1[@full-name = 'Joe']",
"/foo/alef/beta-2/gamma[contains(.,'it')]",
"/foo/alef/links/link[@rel='add' and @href='#add']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:28,代码来源:JaxbBundleTest.java
示例10: rendersPageToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* VersionInset can render itself to the page.
* @throws Exception If there is some problem inside
*/
@Test
public void rendersPageToXml() throws Exception {
final Inset inset = new VersionInset("1.09", "8af9e43", "10-Jan-2013");
final BasePage<?, ?> page = new BasePageMocker()
.init(new ResourceMocker().mock());
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
XhtmlMatchers.hasXPaths(
"/*/version[name='1.09']",
"/*/version[revision='8af9e43']",
"/*/version[date='10-Jan-2013']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:20,代码来源:VersionInsetTest.java
示例11: rendersPageToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* LinksInset can render itself to the page.
* @throws Exception If there is some problem inside
*/
@Test
public void rendersPageToXml() throws Exception {
final Resource resource = new ResourceMocker().withUriInfo(
new UriInfoMocker().withRequestUri(
new URI("http://localhost:80/test")
).mock()
).mock();
final Inset inset = new LinksInset(resource);
final BasePage<?, ?> page = new BasePageMocker().init(resource);
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
XhtmlMatchers.hasXPaths(
"/*/links/link[@rel='home']",
"//link[@rel='self' and @href='http://localhost:80/test']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:23,代码来源:LinksInsetTest.java
示例12: rendersCookieAndAddsHttpHeader
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* FlashInset can render cookie and add a cleaning header.
* @throws Exception If there is some problem inside
*/
@Test
public void rendersCookieAndAddsHttpHeader() throws Exception {
final Resource resource = new ResourceMocker().withHttpHeaders(
new HttpHeadersMocker().withHeader(
HttpHeaders.COOKIE,
"Rexsl-Flash=SU5GTzo0NTY6aGVsbG8sIOKCrCE;path=/"
).mock()
).mock();
final Inset inset = new FlashInset(resource);
final BasePage<?, ?> page = new BasePageMocker().init(resource);
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
XhtmlMatchers.hasXPaths(
"/*/flash[message = 'hello, \u20ac!']",
"/*/flash[level = 'INFO']",
"/*/flash[msec = '456']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:25,代码来源:FlashInsetTest.java
示例13: convertsItselfToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JaxbGroup can be converted to XML text.
* @throws Exception If there is some problem inside
*/
@Test
public void convertsItselfToXml() throws Exception {
final Object group = JaxbGroup.build(
Arrays.asList(
new JaxbGroupTest.Dummy("e1"),
new JaxbGroupTest.Dummy("e2")
),
"group"
);
MatcherAssert.assertThat(
JaxbConverter.the(group),
XhtmlMatchers.hasXPaths(
"/group[count(dummy) = 2]",
"/group/dummy[text='e1']",
"/group/dummy[text='e2']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:23,代码来源:JaxbGroupTest.java
示例14: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxTalk can be converted to XML.
* @throws Exception If fails
*/
@Test
public void convertsToXml() throws Exception {
final JxTalk talk = new JxTalk(new MkTalk());
MatcherAssert.assertThat(
JaxbConverter.the(talk),
XhtmlMatchers.hasXPaths(
"/talk/question",
"/talk/number"
)
);
}
开发者ID:aintshy,项目名称:hub,代码行数:16,代码来源:JxTalkTest.java
示例15: rendersXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* QuoteRs can render an XML.
* @throws Exception If some problem inside
*/
@Test
public void rendersXml() throws Exception {
final Base base = Mockito.mock(Base.class);
final Quotes quotes = Mockito.mock(Quotes.class);
Mockito.doReturn(quotes).when(base).quotes();
final Quote quote = new MkQuote();
Mockito.doReturn(quote).when(quotes).get(1L);
final QuoteRs home = new ResourceMocker().mock(QuoteRs.class);
home.setServletContext(
new MkServletContext().withAttr(Base.class.getName(), base)
);
home.setNumber(1L);
MatcherAssert.assertThat(
JaxbConverter.the(home.index().getEntity()),
XhtmlMatchers.hasXPaths(
String.format("/page/quote[pages='%s']", quote.pages()),
String.format("/page/quote[text='%s']", quote.text()),
"/page/quote/book/cite",
"/page/quote/book/name",
"/page/quote/book/links/link[@rel='open']",
"/page/links/link[@rel='share-facebook']",
"/page/links/link[@rel='share-twitter']",
"/page/links/link[@rel='share-google']",
"/page/links/link[@rel='share-linkedin']"
)
);
}
开发者ID:yegor256,项目名称:bibrarian,代码行数:32,代码来源:QuoteRsTest.java
示例16: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* JxBook can be converted to XML.
* @throws Exception If some problem inside
*/
@Test
public void convertsToXml() throws Exception {
final Book book = new MkBook();
MatcherAssert.assertThat(
JaxbConverter.the(
new JxBook(book, new ResourceMocker().mock(BaseRs.class))
),
XhtmlMatchers.hasXPaths(
String.format("/book[name='%s']", book.name()),
"/book/links/link[@rel='open']"
)
);
}
开发者ID:yegor256,项目名称:bibrarian,代码行数:18,代码来源:JxBookTest.java
示例17: rendersXmlContents
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* Renders XML content.
* @throws Exception
*/
@Test
public void rendersXmlContents() throws Exception {
final Home home = new Home();
Assert.assertThat(
JaxbConverter.the(home),
XhtmlMatchers.hasXPath("/page/text[contains(.,'Hello')]")
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:13,代码来源:HomeTest.java
示例18: convertsToXml
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* BasePage can be converted to XML.
* @throws Exception If there is some problem inside
*/
@Test
public void convertsToXml() throws Exception {
final BasePageTest.ConcreteRs res = new BasePageTest.ConcreteRs();
res.setUriInfo(new UriInfoMocker().mock());
res.setHttpHeaders(new HttpHeadersMocker().mock());
res.setSecurityContext(Mockito.mock(SecurityContext.class));
final BasePageTest.FooPage page = new BasePageTest.FooPage()
.init(res)
.append(new JaxbBundle("single").add("x").up())
.append(new JaxbBundle("title", "hello, world!"))
.link(new Link("test", "/foo"));
MatcherAssert.assertThat(
JaxbConverter.the(page.render().build().getEntity()),
XhtmlMatchers.hasXPaths(
"/page/@date",
"/page/@ip",
"/page/@ssl",
"/page[number(@sla) > 0]",
"/page/millis",
"/page/single/x",
"/page/title[. = 'hello, world!']",
"/page/links/link[@rel = 'home']",
"/page/links/link[@rel = 'self']",
"/page/links/link[@rel = 'test']"
)
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:32,代码来源:BasePageTest.java
示例19: doestRenderWhenCookieIsAbsent
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* AuthInset can be quiet when cookie is absent.
* @throws Exception If there is some problem inside
*/
@Test
public void doestRenderWhenCookieIsAbsent() throws Exception {
final Resource resource = new ResourceMocker().mock();
final Inset inset = new AuthInset(resource, "");
final BasePage<?, ?> page = new BasePageMocker().init(resource);
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
Matchers.not(XhtmlMatchers.hasXPath("/*/identity"))
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:16,代码来源:AuthInsetTest.java
示例20: doestRenderWhenCookieIsAbsent
import com.jcabi.matchers.JaxbConverter; //导入依赖的package包/类
/**
* FlashInset can be quiet when cookie is absent.
* @throws Exception If there is some problem inside
*/
@Test
public void doestRenderWhenCookieIsAbsent() throws Exception {
final Resource resource = new ResourceMocker().mock();
final Inset inset = new FlashInset(resource);
final BasePage<?, ?> page = new BasePageMocker().init(resource);
inset.render(page, Response.ok());
MatcherAssert.assertThat(
JaxbConverter.the(page),
Matchers.not(XhtmlMatchers.hasXPath("/*/flash"))
);
}
开发者ID:yegor256,项目名称:rexsl,代码行数:16,代码来源:FlashInsetTest.java
注:本文中的com.jcabi.matchers.JaxbConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论