Package com.alibaba.citrus.util.templatelite.Template

Examples of com.alibaba.citrus.util.templatelite.Template.Placeholder


    @Test
    public void test02_placeholder_template() throws Exception {
        loadTemplate("test02_placeholder_template.txt", 2, 2, 0);

        Placeholder placeholder = (Placeholder) template.nodes[0];

        assertPlaceholder(placeholder, "for", "Line 1 Column 1", new String[] { "#aaa", "#bbb.ccc", "ccc" },
                          "#aaa, #bbb.ccc, ccc");

        PlaceholderParameter param;
View Full Code Here


    @Test
    public void test02_placeholder_template_group() throws Exception {
        loadTemplate("test02_placeholder_template_group.txt", 1, 1, 1);

        Placeholder placeholder = (Placeholder) template.nodes[0];

        // 子模板的顺序和模板文件中的一致
        assertPlaceholder(placeholder, "for", "Line 3 Column 1", new String[] { "#aaa.d", "#aaa.c", "#aaa.b", "ccc" },
                          "#aaa.*, ccc");

View Full Code Here

    @Test
    public void test02_placeholder_template_group_2() throws Exception {
        loadTemplate("test02_placeholder_template_group_2.txt", 0, 1, 1);

        Placeholder placeholder = (Placeholder) template.getSubTemplate("aaa").nodes[0];

        // 子模板的顺序和模板文件中的一致
        assertPlaceholder(placeholder, "for", "Line 4 Column 3", new String[] { "#d", "#c", "#b", "ccc" }, "#*, ccc");

        PlaceholderParameter param;
View Full Code Here

    private void assertPlaceholder(Node node, String name, String location) {
        assertPlaceholder(node, name, location, new String[0], null);
    }

    private void assertPlaceholder(Node node, String name, String location, String[] params, String paramsString) {
        Placeholder placeholder = (Placeholder) node;

        assertEquals(name, placeholder.name);
        assertEquals(paramsString, placeholder.paramsString);
        assertLocation(placeholder.location, location);

        if (isEmptyArray(params)) {
            assertEquals(0, placeholder.params.length);
        } else {
            assertEquals(params.length, placeholder.params.length);

            for (int i = 0; i < params.length; i++) {
                assertEquals(params[i], placeholder.params[i].getValue());
            }
        }

        String str = placeholder.toString();

        if (paramsString == null) {
            assertThat(str, startsWith("${" + name + "}"));
        } else {
            assertThat(str, startsWith("${" + name + ":" + paramsString + "}"));
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.util.templatelite.Template.Placeholder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.