[xwiki-dev] Let JUnit test work with files

Christian Gmeiner christian.gmeiner at gmail.com
Thu Mar 29 14:29:45 CEST 2007


Hi all...

At the moment I working to get a high quality html 2 xwiki converter
ready. And here is testing
a very important point. The current situation is that I have the whole
html and xwiki code directly
in the java file. And I want to change it because its easier to
writteand maintain tests.
I have tried the following:

    public void testInlineStyle2() {

        String html = readTextFile("inlineStyle_1.html");
        String xwiki = readTextFile("inlineStyle_1.xwiki");

        String result = Converter.convertHtml2XWiki(html);
        assertEquals(xwiki, result);
    }

    private static String readTextFile(String fullPathFilename) {

        StringBuffer sb = new StringBuffer(1024);
        try {
            BufferedReader reader = null;reader = new
BufferedReader(new FileReader(fullPathFilename));
            char[] chars = new char[1024];
            int numRead = 0;
            while ((numRead = reader.read(chars)) > -1) {
                sb.append(String.valueOf(chars));
            }
            reader.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return sb.toString();
    }


inlineStyle_1.html and inlineStyle_1.xwiki are in the same dir/package
as the ConverterTest, but I get a FileNotFoundException. Maybe
somebody has an idea how to fix it. If you want you
can check in the fix in the wysiwyg new architecture branch.

Oh.. in the next days I will post here the proposal of the new
architecture to get as much as possible feedback.

thanks,
Christian




More information about the devs mailing list