1 19 20 package gui.propertyeditors; 21 22 import gui.propertyeditors.utilities.CoreSupport; 23 24 import org.netbeans.junit.NbTestSuite; 25 26 import org.netbeans.jellytools.properties.editors.ClasspathCustomEditorOperator; 27 import org.netbeans.jellytools.properties.editors.FileCustomEditorOperator; 28 29 34 public class PropertyType_NbClassPath extends PropertyEditorsTest { 35 36 public String propertyName_L; 37 public String propertyValue_L; 38 public String propertyValueExpectation_L; 39 40 public boolean waitDialog = false; 41 42 private final String ADDDIRECTORY = "Add Directory:"; 43 private final String ADDJAR = "Add JAR:"; 44 private final String REMOVE = "Remove:"; 45 private final String UP = "Up:"; 46 private final String DOWN = "Down:"; 47 48 private static String directoryPath; 49 private static String dataJarPath; 50 51 private static String delim; 52 53 54 public PropertyType_NbClassPath(String testName) { 55 super(testName); 56 directoryPath = CoreSupport.getSampleProjectPath(this); 57 dataJarPath = directoryPath + System.getProperty("file.separator") + "data.jar"; 58 59 log("======= Directory Path={"+directoryPath+"}"); 60 log("======= Data.jar Path={"+dataJarPath+"}"); 61 62 String os = System.getProperty("os.name"); 63 System.err.println("Os name = {"+os+"}"); 64 65 if(os.indexOf("Win")!=-1) 66 delim = ";"; 67 else 68 delim = ":"; 69 70 System.err.println("delim={"+delim+"}"); 71 72 propertyName_L = "NbClassPath"; 73 } 74 75 76 public static NbTestSuite suite() { 77 78 NbTestSuite suite = new NbTestSuite(); 79 suite.addTest(new PropertyType_NbClassPath("testByInPlace")); 80 suite.addTest(new PropertyType_NbClassPath("verifyCustomizer")); 81 suite.addTest(new PropertyType_NbClassPath("testCustomizerCancel")); 82 suite.addTest(new PropertyType_NbClassPath("testCustomizerAddDirectory")); 83 suite.addTest(new PropertyType_NbClassPath("testCustomizerRemove")); 84 suite.addTest(new PropertyType_NbClassPath("testCustomizerUp")); 85 suite.addTest(new PropertyType_NbClassPath("testCustomizerAddJar")); 86 87 return suite; 90 } 91 92 93 public void testCustomizerAddDirectory() { 94 propertyValue_L = ADDDIRECTORY + directoryPath; 95 propertyValueExpectation_L = "one.jar"+delim+"two.zip" + delim + directoryPath; 96 waitDialog = false; 97 setByCustomizerOk(propertyName_L, true); 98 } 99 100 public void testCustomizerAddJar() { 101 propertyValue_L = ADDJAR + dataJarPath; 102 propertyValueExpectation_L = "two.zip"+delim+"one.jar"+ delim + dataJarPath; 103 waitDialog = false; 104 setByCustomizerOk(propertyName_L, true); 105 } 106 107 public void testCustomizerRemove() { 108 propertyValue_L = REMOVE + directoryPath; 109 propertyValueExpectation_L = "one.jar"+delim+"two.zip"; 111 waitDialog = false; 112 setByCustomizerOk(propertyName_L, true); 113 } 114 115 public void testCustomizerUp() { 116 propertyValue_L = UP + "two.zip"; 117 propertyValueExpectation_L = "two.zip"+delim+"one.jar"; 119 waitDialog = false; 120 setByCustomizerOk(propertyName_L, true); 121 } 122 123 public void testCustomizerDown() { 124 propertyValue_L = DOWN + "one.jar"; 125 propertyValueExpectation_L = "two.zip" + delim + dataJarPath + delim + "one.jar" ; 126 waitDialog = false; 127 setByCustomizerOk(propertyName_L, true); 128 } 129 130 public void testCustomizerCancel(){ 131 propertyValue_L = REMOVE + "one.jar"; 132 propertyValueExpectation_L = propertyValue_L; 133 waitDialog = false; 134 setByCustomizerCancel(propertyName_L, false); 135 } 136 137 public void testByInPlace(){ 138 propertyValue_L = "one.jar"+delim+"two.zip"; 139 propertyValueExpectation_L = propertyValue_L; 140 waitDialog = false; 141 setByInPlace(propertyName_L, propertyValue_L, true); 142 } 143 144 public void verifyCustomizer() { 145 verifyCustomizer(propertyName_L); 146 } 147 148 public void setCustomizerValue() { 149 ClasspathCustomEditorOperator customizer = new ClasspathCustomEditorOperator(propertyCustomizer); 150 151 if(propertyValue_L.startsWith(ADDDIRECTORY)){ 152 err.println("========== ADDING DIRECTORY ======="); 153 customizer.addDirectory(getPath(propertyValue_L, ADDDIRECTORY)); 154 } 155 156 if(propertyValue_L.startsWith(ADDJAR)){ 157 err.println("========== ADDING JAR ======="); 158 FileCustomEditorOperator editor=customizer.addJARZIP(); 161 editor.fileChooser().chooseFile(getPath(propertyValue_L, ADDJAR)); 162 customizer.ok(); 163 } 164 165 if(propertyValue_L.startsWith(REMOVE)){ 166 err.println("========== REMOVE ======="); 167 customizer.remove(getPath(propertyValue_L,REMOVE)); 168 } 169 170 if(propertyValue_L.startsWith(UP)){ 171 err.println("========== UP ======="); 172 customizer.lstClasspath().selectItem(getPath(propertyValue_L,UP)); 173 customizer.moveUp(); 174 } 175 176 if(propertyValue_L.startsWith(DOWN)){ 177 err.println("========== DOWN ======="); 178 customizer.lstClasspath().selectItem(getPath(propertyValue_L,DOWN)); 179 customizer.moveDown(); 180 } 181 182 } 183 184 public void verifyPropertyValue(boolean expectation) { 185 verifyExpectationValue(propertyName_L,expectation, propertyValueExpectation_L, propertyValue_L, waitDialog); 186 } 187 188 189 private String getPath(String str, String delim) { 190 int index = str.indexOf(delim); 191 192 if(index > -1) 193 return str.substring(index + delim.length()); 194 195 return str; 196 } 197 198 public void verifyCustomizerLayout() { 199 ClasspathCustomEditorOperator customizer = new ClasspathCustomEditorOperator(propertyCustomizer); 200 customizer.verify(); 201 customizer.btOK(); 202 customizer.btCancel(); 203 } 204 205 208 public static void main(String [] args) { 209 junit.textui.TestRunner.run(suite()); 211 } 212 213 } 214 | Popular Tags |