1 19 20 package org.netbeans.modules.form.layoutdesign; 21 22 import java.io.File ; 23 import java.io.FileWriter ; 24 import java.io.IOException ; 25 import java.net.URL ; 26 import junit.framework.TestCase; 27 28 33 34 public class GFGenerator extends TestCase { 35 36 public GFGenerator(String name) { 37 super(name); 38 } 39 40 43 public void testGenerate() throws IOException { 44 File file = createFile(); 45 46 LayoutModel layoutModel = new LayoutModel(); 47 LayoutModelTest.fillModelToDump(layoutModel); 48 49 writeFile(file, layoutModel.dump(null)); 50 } 51 52 private File createFile() throws IOException { 53 URL url = getClass().getClassLoader().getResource(""); 54 File file = new File (url.getFile() + "../../../../test/unit/data/goldenfiles") 57 .getCanonicalFile(); 58 if (!file.exists()) { 59 file.mkdirs(); 60 } 61 file = new File (file, "layoutModelDump.pass"); 62 if (file.exists()) { 63 file.delete(); 64 } 65 file.createNewFile(); 66 return file; 67 } 68 69 private void writeFile(File f, String dump) throws IOException { 70 FileWriter fw = null; 71 try { 72 fw = new FileWriter (f); 73 fw.write(dump); 74 } 75 finally { 76 if (fw != null) { 77 fw.close(); 78 } 79 } 80 } 81 } 82 | Popular Tags |