当前位置: 首页>>代码示例>>Java>>正文


Java Xembler类代码示例

本文整理汇总了Java中org.xembly.Xembler的典型用法代码示例。如果您正苦于以下问题:Java Xembler类的具体用法?Java Xembler怎么用?Java Xembler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Xembler类属于org.xembly包,在下文中一共展示了Xembler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: acceptsAndRenders

import org.xembly.Xembler; //导入依赖的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")
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:MistakesTest.java

示例2: acceptsAndRenders

import org.xembly.Xembler; //导入依赖的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")
    );
}
 
开发者ID:yegor256,项目名称:jpeek,代码行数:19,代码来源:ResultsTest.java

示例3: text

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * Render text via XPath.
 * @param pattern Pattern to use
 * @return Plain text
 */
public String text(final CharSequence pattern) {
    final XML xml = new XMLDocument(
        new Xembler(this.dirs).domQuietly()
    );
    final Pattern ptn = Pattern.compile("\\{([^}]+)}");
    final Matcher mtr = ptn.matcher(pattern);
    final StringBuffer out = new StringBuffer(pattern.length());
    while (mtr.find()) {
        mtr.appendReplacement(
            out, xml.xpath(mtr.group(1)).get(0).replace("$", "\\$")
        );
    }
    mtr.appendTail(out);
    return out.toString();
}
 
开发者ID:yegor256,项目名称:wring,代码行数:21,代码来源:XePrint.java

示例4: addsAndRemovePipes

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyPipes can add and remove pipes.
 * @throws Exception If some problem inside
 */
@Test
public void addsAndRemovePipes() throws Exception {
    final User user = new DyUser(new Dynamo(), "jeffrey");
    final Pipes pipes = user.pipes();
    pipes.add("{\"name\": \"hello\"}");
    final Pipe pipe = pipes.iterate().iterator().next();
    MatcherAssert.assertThat(
        new Xembler(pipe.asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/pipe/json",
            "/pipe/id"
        )
    );
    pipe.delete();
}
 
开发者ID:yegor256,项目名称:wring,代码行数:20,代码来源:DyPipesITCase.java

示例5: appendsToExistingEvents

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyEvents can append text to.
 * @throws Exception If some problem inside
 */
@Test
public void appendsToExistingEvents() throws Exception {
    final User user = new DyUser(new Dynamo(), "peter");
    final Events events = user.events();
    final String title = "a simple title";
    events.post(title, "\n\tfirst body");
    events.post(title, "\n\u0000\u00fdin between");
    events.post(title, "second body\n\n");
    MatcherAssert.assertThat(
        new Xembler(events.iterate().iterator().next().asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/event/text[contains(.,'first')]",
            "/event/text[contains(.,'second body')]",
            "/event/text[not(contains(.,'first body\n'))]"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:22,代码来源:DyEventsITCase.java

示例6: upvotes

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * DyEvent can up-vote.
 * @throws Exception If some problem inside
 */
@Test
public void upvotes() throws Exception {
    final User user = new DyUser(new Dynamo(), "nick");
    final Events events = user.events();
    events.post("hey you", "some text [test](http://a.com/$t)!");
    final Event event = events.iterate().iterator().next();
    event.vote(Tv.FIFTEEN);
    MatcherAssert.assertThat(
        new Xembler(events.iterate().iterator().next().asXembly()).xml(),
        XhtmlMatchers.hasXPaths(
            "/event[title='hey you']",
            "/event[rank=16]"
        )
    );
}
 
开发者ID:yegor256,项目名称:wring,代码行数:20,代码来源:DyEventITCase.java

示例7: render

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * Render source as XML.
 * @param dom DOM node to build upon
 * @param src Source
 * @return XML
 * @throws IOException If fails
 */
private static InputStream render(final Node dom,
    final XeSource src) throws IOException {
    final Node copy = cloneNode(dom);
    final ByteArrayOutputStream baos =
        new ByteArrayOutputStream();
    final Node node = new Xembler(src.toXembly()).applyQuietly(copy);
    try {
        TransformerFactory.newInstance().newTransformer().transform(
            new DOMSource(node),
            new StreamResult(
                new Utf8OutputStreamWriter(baos)
            )
        );
    } catch (final TransformerException ex) {
        throw new IllegalStateException(ex);
    }
    return new ByteArrayInputStream(baos.toByteArray());
}
 
开发者ID:yegor256,项目名称:takes,代码行数:26,代码来源:RsXembly.java

示例8: exec

import org.xembly.Xembler; //导入依赖的package包/类
@Override
public void exec(final Agent agent) throws IOException {
    final XML before = new StrictXML(
        Deck.UPGRADE.transform(
            new XMLDocument(new File(this.path))
        ),
        Deck.SCHEMA
    );
    final XML after = new XMLDocument(
        new Xembler(agent.exec(before)).applyQuietly(before.node())
    );
    FileUtils.write(
        new File(this.path),
        new StrictXML(
            after,
            Deck.SCHEMA
        ).toString(),
        CharEncoding.UTF_8
    );
    Logger.info(
        this, "deck saved to %s (%d bytes):\n%s", this.path,
        new File(this.path).length(), after
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:25,代码来源:FkDeck.java

示例9: checksState

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * CheckState can check state.
 * @throws IOException If fails
 */
@Test
public void checksState() throws IOException {
    final Agent agent = new CheckState(
        new Script.Fake("\n\n hey\nALIVE")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck><containers><container state='unknown'>",
            "<name>abcd1234</name><host>127.0.0.1</host>",
            "<http>80</http>",
            "</container></containers></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths(
            "/deck/containers/container[@state='alive']"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:CheckStateTest.java

示例10: buildsImage

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * BuildImage can build image.
 * @throws IOException If fails
 */
@Test
public void buildsImage() throws IOException {
    final Agent agent = new BuildImage(
        new Script.Fake("\n\n hey\nALIVE")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'>",
            "<repo><name>abcd1234</name><uri>http://</uri>",
            "</repo></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths(
            "/deck[not(repo)]",
            "/deck/images/image[@type='blue']"
        )
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:BuildImageTest.java

示例11: updatesNginx

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * UpdateNginx can update nginx.
 * @throws IOException If fails
 */
@Test
public void updatesNginx() throws IOException {
    final Agent agent = new UpdateNginx(
        new Script.Fake("")
    );
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'><containers>",
            " <container type='green' state='alive'><http>80</http>",
            "  <host>localhost</host><name>aaaaaaaa</name>",
            "  <image>ffffffff</image>",
            " </container></containers>",
            "<domains><domain>test.thindeck.com</domain></domains></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths("/deck")
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:27,代码来源:UpdateNginxTest.java

示例12: wipesRepo

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * WipeRepo can wire a repo.
 * @throws IOException If fails
 */
@Test
public void wipesRepo() throws IOException {
    final Agent agent = new WipeRepo();
    final XML deck = new XMLDocument(
        Joiner.on(' ').join(
            "<deck name='test/test'><repo added='2013-01-01T12:59:59'>",
            "<name>abcdef59</name><uri>#</uri></repo></deck>"
        )
    );
    MatcherAssert.assertThat(
        new XMLDocument(
            new Xembler(agent.exec(deck)).applyQuietly(deck.node())
        ),
        XhtmlMatchers.hasXPaths("/deck[not(repo)]")
    );
}
 
开发者ID:yegor256,项目名称:thindeck,代码行数:21,代码来源:WipeRepoTest.java

示例13: manipulatesWithTypesAndUseCases

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeOntology can do manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithTypesAndUseCases() throws Exception {
    final XeOntology onto = new XeOntology();
    final Type type = onto.type("First");
    type.explain("first text");
    type.parent("Root");
    type.slot("one").assign("Emp");
    onto.type("Second").explain("second text");
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(onto).xml()),
        XhtmlMatchers.hasXPaths(
            "/spec",
            "/spec/types/type[name='First']",
            "/spec/types/type[name='Second']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:22,代码来源:XeOntologyTest.java

示例14: manipulatesWithType

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeType can do type manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithType() throws Exception {
    final Directives dirs = new Directives().add("t");
    final Type type = new XeType(dirs, "/t");
    type.explain("first text");
    type.explain("second text");
    type.parent("Root");
    type.slot("'one").assign("Emp");
    type.mention(2);
    type.mention(1);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/t/info",
            "/t/info[informal='first text']",
            "/t/info[informal='second text']",
            "/t/parents[type='Root']",
            "/t/mentioned[where='2']",
            "/t/mentioned[where='1']",
            "/t/slots/slot[type='Emp']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:28,代码来源:XeTypeTest.java

示例15: manipulatesWithProperty

import org.xembly.Xembler; //导入依赖的package包/类
/**
 * XeSlot can do slot manipulations.
 * @throws Exception When necessary
 */
@Test
public void manipulatesWithProperty() throws Exception {
    final Directives dirs = new Directives().add("p");
    final Slot slot = new XeSlot(dirs, "/p");
    slot.explain("first text");
    slot.explain("second text");
    slot.assign("Employee");
    slot.mention(2);
    slot.mention(1);
    MatcherAssert.assertThat(
        XhtmlMatchers.xhtml(new Xembler(dirs).xml()),
        XhtmlMatchers.hasXPaths(
            "/p/info",
            "/p/info[informal='first text']",
            "/p/info[informal='second text']",
            "/p[type='Employee']",
            "/p/mentioned[where='2']",
            "/p/mentioned[where='1']"
        )
    );
}
 
开发者ID:yegor256,项目名称:requs,代码行数:26,代码来源:XeSlotTest.java


注:本文中的org.xembly.Xembler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。