1 19 20 package jemmyI18NWizard; 21 22 import java.io.PrintWriter ; 23 import java.io.File ; 24 import java.io.IOException ; 25 import org.netbeans.jemmy.util.PNGEncoder; 26 import org.netbeans.test.oo.gui.jelly.JellyProperties; 27 import org.netbeans.test.oo.gui.jam.JamUtilities; 28 29 import jemmyI18NWizard.wizardSupport.*; 30 import org.netbeans.jemmy.operators.JListOperator; 31 32 import org.netbeans.junit.NbTestCase; 33 import org.netbeans.junit.NbTestSuite; 34 import org.netbeans.test.oo.gui.jam.Jemmy; 35 36 37 43 public class BasicTest extends NbTestCase { 44 45 46 public BasicTest(String testName) { 47 super(testName); 48 } 49 50 51 public void setUp() { 52 JellyProperties.setJemmyOutput(new PrintWriter (getLog(), true), new PrintWriter (getLog(), true)); 54 JellyProperties.setDefaults(); 55 } 56 57 public void test() { 58 try { 59 log("###### Opening wizard."); 60 Page0 page0 = new Page0(); 61 log("###### Wizard opened."); 62 log("###### Removing selected sources."); 63 for(int i=0; i<page0.getItemCount(); i++) { 64 page0.selectItem(i); 65 page0.removeSource(); 66 } 67 assertEquals("Selected sources list must be empty.", page0.getItemCount(), 0); 68 log("###### Clicking 'Add Source(s)' button."); 69 page0.addSource(); 70 71 log("###### Opening 'Select Sources' dialog."); 72 SelectSourcesDialog selSour = new SelectSourcesDialog("Select Sources"); 73 log("###### 'Select Sources' dialog opened."); 74 75 log("###### Selecting testing filesystem."); 76 assertTrue("Filesystem '" + Utilities.getFilesystemPath() +"' not selected.", selSour.selectFilesystem(Utilities.getFilesystemPath())); 77 78 log("###### Selecting source files in tree."); 79 selSour.selectPath(new String [] {"jemmyI18NWizard", "data", "SimpleMainClass"}); 80 81 log("###### Clicking 'OK' button."); 82 selSour.ok(); 83 84 JamUtilities.waitEventQueueEmpty(500); 85 assertEquals("Source file SimpleMainClass.java not present in list", page0.getItemCount(), 1); 86 page0.selectItem(0); 87 Object selected = new JListOperator(Jemmy.getOp(page0), 1).getSelectedValue(); 90 assertNotNull("getSelectedValue() returned null.", selected); 91 assertTrue("Source file SimpleMainClass.java not selected", selected.toString().endsWith("SimpleMainClass.java]")); 92 93 log("###### Clicking 'Next >' button."); 94 page0.next(); 95 96 log("###### Opening second window of wizard."); 97 Page1 page1 = new Page1(); 98 log("###### Window succesfully opened."); 99 100 log("###### Bundle should be selected - continuing to next window."); 101 log("###### Clicking 'Next >' button."); 102 page1.next(); 103 104 log("###### Opening third window."); 105 Page2 page2 = new Page2(); 106 log("###### Window succesfully opened."); 107 108 log("###### Finishing."); 109 log("###### Clicking 'Finish' button."); 110 page2.finish(); 111 112 log("###### Test finished."); 113 log("###### Saving source file."); 114 try { 115 Utilities.saveFile("jemmyI18NWizard/data/SimpleMainClass.java"); 116 } catch(Exception e) { 117 log("###### Error when saving source files."); 118 fail("Error saving source file."); 119 } 120 log("###### Source file saved succesfully."); 121 122 log("###### Saving bundle."); 123 try { 124 Utilities.saveFile("jemmyI18NWizard/data/Bundle.properties"); 125 } catch(Exception e) { 126 log("###### Error when saving bundle."); 127 fail("###### Error saving bundle."); 128 } 129 log("###### Bundle saved succesfully."); 130 131 log("###### Comparing sources."); 132 String sep = File.separator; 133 String dataPath = Utilities.getFilesystemPath()+sep+"jemmyI18NWizard"+sep+"data"; 134 assertFile("Generated changes in SimpleMainClass differ.", dataPath+sep+"SimpleMainClass.java", dataPath+sep+"goldenfiles"+sep+"BasicTest"+sep+"SimpleMainClass.pass", getWorkDirPath()+sep+"SimpleMainClass.diff"); 135 136 log("###### Comparing bundles."); 137 138 if(!Utilities.compareBundles(Utilities.getFilesystemPath()+"/jemmyI18NWizard/data/Bundle.properties" 139 , Utilities.getFilesystemPath()+"/jemmyI18NWizard/data/goldenfiles/BasicTest/Bundle.properties")) { 140 log("###### Bundles compared succesfully."); 141 } else { 142 log("###### Error when comparing bundles."); 143 fail("Error comparing bundles."); 144 } 145 146 } catch (Exception e) { 147 try { 149 PNGEncoder.captureScreen(getWorkDirPath()+File.separator+"screen.png"); 150 } catch (IOException ioe) { 151 ioe.printStackTrace(); 152 } 153 e.printStackTrace(); 155 e.printStackTrace(getLog()); 156 fail(e.getMessage()); 157 } 158 } 159 } 160 | Popular Tags |