Hi Christian, Why do you have to work with files? If I were you I'd work with content in memory, not files. That's much better because: 1/ The test and the input data are in the same location making it easier to understand and maintain the test 2/ No IO thus less complex (your post proves it) 3/ Much faster WDYT? Thanks -Vincent On Mar 29, 2007, at 2:29 PM, Christian Gmeiner wrote:
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