KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > project > JavaTargetChooserPanelTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.java.project;
21
22 import java.io.File JavaDoc;
23 import org.netbeans.junit.NbTestCase;
24 import org.openide.filesystems.FileObject;
25 import org.openide.filesystems.FileUtil;
26
27 /**
28  *
29  * @author Jiri Rechtacek
30  */

31 public class JavaTargetChooserPanelTest extends NbTestCase {
32     FileObject root = null;
33
34     public JavaTargetChooserPanelTest (String JavaDoc testName) {
35         super (testName);
36     }
37
38     protected void setUp () throws Exception JavaDoc {
39         super.setUp ();
40         clearWorkDir ();
41     }
42
43     // tests #51135: checked existence of multiple dotted package name
44
public void testCanUseFileName () throws Exception JavaDoc {
45         File JavaDoc 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