Search in sources :

Example 11 with SpecExample

use of com.vladsch.flexmark.spec.SpecExample in project flexmark-java by vsch.

the class ComboPegdownExtensionCompatibilitySpecTest method data.

@Parameterized.Parameters(name = "{0}")
public static List<Object[]> data() {
    List<SpecExample> examples = SpecReader.readExamples(SPEC_RESOURCE);
    List<Object[]> data = new ArrayList<Object[]>();
    // NULL example runs full spec test
    data.add(new Object[] { SpecExample.NULL });
    for (SpecExample example : examples) {
        data.add(new Object[] { example });
    }
    return data;
}
Also used : SpecExample(com.vladsch.flexmark.spec.SpecExample) ArrayList(java.util.ArrayList)

Example 12 with SpecExample

use of com.vladsch.flexmark.spec.SpecExample in project flexmark-java by vsch.

the class FileSpecTestCase method dataFromSeparateFiles.

public static List<Object[]> dataFromSeparateFiles(String[] fileNames, String prefix, boolean dumpHtml, boolean dumpAst) {
    ArrayList<SpecExample> examples = new ArrayList<SpecExample>();
    for (String name : fileNames) {
        String source = readResource(prefix + name + ".md");
        String html = null;
        String ast = null;
        try {
            html = readResource(name + ".html");
        } catch (RuntimeException ignored) {
            html = dumpHtml ? "" : null;
        }
        try {
            ast = readResource(name + ".ast");
        } catch (RuntimeException ignored) {
            ast = dumpAst ? "" : null;
        }
        if (ast != null) {
            examples.add(new SpecExample("", name, 0, source, html, ast));
        } else {
            examples.add(new SpecExample("", name, 0, source, html));
        }
    }
    List<Object[]> data = new ArrayList<Object[]>();
    // NULL example runs full spec test
    data.add(new Object[] { SpecExample.NULL });
    for (SpecExample example : examples) {
        data.add(new Object[] { example });
    }
    return data;
}
Also used : SpecExample(com.vladsch.flexmark.spec.SpecExample) ArrayList(java.util.ArrayList)

Example 13 with SpecExample

use of com.vladsch.flexmark.spec.SpecExample in project flexmark-java by vsch.

the class ComboYouTrackConverterSpecTest method data.

@Parameterized.Parameters(name = "{0}")
public static List<Object[]> data() {
    List<SpecExample> examples = SpecReader.readExamples(SPEC_RESOURCE);
    List<Object[]> data = new ArrayList<Object[]>();
    // NULL example runs full spec test
    data.add(new Object[] { SpecExample.NULL });
    for (SpecExample example : examples) {
        data.add(new Object[] { example });
    }
    return data;
}
Also used : SpecExample(com.vladsch.flexmark.spec.SpecExample)

Example 14 with SpecExample

use of com.vladsch.flexmark.spec.SpecExample in project flexmark-java by vsch.

the class ComboDocxConverterSpecTest method testCase.

@Override
protected void testCase(final Node node, final DataHolder options) {
    if (!DUMP_TEST_CASE_FILES)
        return;
    final SpecExample specExample = example();
    if (!specExample.isFullSpecExample() && !specExample.getSection().isEmpty()) {
        // write it out to file, hard-coded for now                    IGNORE
        File file = new File(String.format("%s%s%s_%d.docx", PROJECT_ROOT_DIRECTORY, FILE_TEST_CASE_DUMP_LOCATION, specExample.getSection(), specExample.getExampleNumber()));
        File file2 = new File(String.format("%s%s%s_%d.xml", PROJECT_ROOT_DIRECTORY, FILE_TEST_CASE_DUMP_LOCATION, specExample.getSection(), specExample.getExampleNumber()));
        WordprocessingMLPackage mlPackage = DocxRenderer.getDefaultTemplate();
        RENDERER.withOptions(options).render(node, mlPackage);
        try {
            mlPackage.save(file, Docx4J.FLAG_SAVE_ZIP_FILE);
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            try {
                mlPackage.save(outputStream, Docx4J.FLAG_SAVE_FLAT_XML);
                final String xml = outputStream.toString("UTF-8");
                final String s = XmlDocxSorter.sortDocumentParts(xml);
                FileWriter fileWriter = new FileWriter(file2);
                fileWriter.append(s);
                fileWriter.append('\n');
                fileWriter.close();
            } catch (Docx4JException e) {
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (Docx4JException e) {
            e.printStackTrace();
        }
    }
}
Also used : SpecExample(com.vladsch.flexmark.spec.SpecExample) WordprocessingMLPackage(org.docx4j.openpackaging.packages.WordprocessingMLPackage) Docx4JException(org.docx4j.openpackaging.exceptions.Docx4JException)

Example 15 with SpecExample

use of com.vladsch.flexmark.spec.SpecExample in project flexmark-java by vsch.

the class ComboExtAttributesSpecTest method data.

@Parameterized.Parameters(name = "{0}")
public static List<Object[]> data() {
    List<SpecExample> examples = SpecReader.readExamples(SPEC_RESOURCE);
    List<Object[]> data = new ArrayList<Object[]>();
    // NULL example runs full spec test
    data.add(new Object[] { SpecExample.NULL });
    for (SpecExample example : examples) {
        data.add(new Object[] { example });
    }
    return data;
}
Also used : SpecExample(com.vladsch.flexmark.spec.SpecExample)

Aggregations

SpecExample (com.vladsch.flexmark.spec.SpecExample)83 ArrayList (java.util.ArrayList)30 Docx4JException (org.docx4j.openpackaging.exceptions.Docx4JException)3 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)3 Parameters (org.junit.runners.Parameterized.Parameters)1