1 19 20 package org.netbeans.modules.java.project; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 import org.openide.filesystems.FileObject; 25 import org.openide.filesystems.FileUtil; 26 27 31 public class JavaTargetChooserPanelTest extends NbTestCase { 32 FileObject root = null; 33 34 public JavaTargetChooserPanelTest (String testName) { 35 super (testName); 36 } 37 38 protected void setUp () throws Exception { 39 super.setUp (); 40 clearWorkDir (); 41 } 42 43 public void testCanUseFileName () throws Exception { 45 File rootFile = getWorkDir (); 46 assertNotNull ("WorkDir exists.", rootFile); 47 root = FileUtil.toFileObject (rootFile); 48 if (!root.canWrite ()) { 49 fail ("Cannot create test folder."); 50 } 51 52 root = root.createFolder ("testCanUseFileName"); 53 54 assertNotNull (root + " exists.", FileUtil.toFile (root)); 55 assertTrue ("Package aaa.bbb.ccc can be created.", JavaTargetChooserPanel.canUseFileName (root, "", "aaa.bbb.ccc", "") == null); 56 57 assertNotNull ("Package aaa.bbb.ccc was created.", root.createFolder ("aaa").createFolder ("bbb").createFolder ("ccc")); 58 assertTrue ("Package aaa cannot be created.", JavaTargetChooserPanel.canUseFileName (root, "", "aaa", "") != null); 59 assertTrue ("Package aaa.bbb cannot be created.", JavaTargetChooserPanel.canUseFileName (root, "", "aaa.bbb", "") != null); 60 assertTrue ("Package aaa.bbb.ccc cannot be created.", JavaTargetChooserPanel.canUseFileName (root, "", "aaa.bbb.ccc", "") != null); 61 assertTrue ("Package ddd can be created.", JavaTargetChooserPanel.canUseFileName (root, "", "ddd", "") == null); 62 } 63 64 } 65 | Popular Tags |