KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > suite > SuiteProjectGeneratorTest


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.apisupport.project.suite;
21
22 import java.io.File JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.netbeans.api.project.ProjectManager;
25 import org.netbeans.api.project.ProjectUtils;
26 import org.netbeans.modules.apisupport.project.TestBase;
27 import org.netbeans.modules.apisupport.project.universe.NbPlatform;
28 import org.openide.filesystems.FileObject;
29 import org.openide.filesystems.FileUtil;
30
31 /**
32  * SuiteProjectGenerator tests.
33  *
34  * @author Martin Krauskopf, Jesse Glick
35  */

36 public class SuiteProjectGeneratorTest extends TestBase {
37     // XXX also should test content of created files (XMLs, properties)
38

39     public SuiteProjectGeneratorTest(String JavaDoc testName) {
40         super(testName);
41     }
42     
43     private static final String JavaDoc[] SUITE_CREATED_FILES = {
44         "build.xml",
45         "nbproject/project.xml",
46         "nbproject/build-impl.xml",
47         "nbproject/platform.properties",
48         "nbproject/project.properties",
49     };
50     
51     public void testCreateSuiteProject() throws Exception JavaDoc {
52         File JavaDoc targetPrjDir = new File JavaDoc(getWorkDir(), "testSuite");
53         SuiteProjectGenerator.createSuiteProject(targetPrjDir, NbPlatform.PLATFORM_ID_DEFAULT);
54         FileObject fo = FileUtil.toFileObject(targetPrjDir);
55         // Make sure generated files are created too - simulate project opening.
56
Project p = ProjectManager.getDefault().findProject(fo);
57         assertNotNull("have a project in " + targetPrjDir, p);
58         SuiteProjectTest.openSuite(p);
59         // check generated module
60
for (int i=0; i < SUITE_CREATED_FILES.length; i++) {
61             assertNotNull(SUITE_CREATED_FILES[i]+" file/folder cannot be found",
62                     fo.getFileObject(SUITE_CREATED_FILES[i]));
63         }
64     }
65     
66     public void testSuiteProjectWithDotInName() throws Exception JavaDoc {
67         File JavaDoc targetPrjDir = new File JavaDoc(getWorkDir(), "testSuite 1.0");
68         SuiteProjectGenerator.createSuiteProject(targetPrjDir, NbPlatform.PLATFORM_ID_DEFAULT);
69         FileObject fo = FileUtil.toFileObject(targetPrjDir);
70         // Make sure generated files are created too - simulate project opening.
71
Project p = ProjectManager.getDefault().findProject(fo);
72         assertEquals("#66080: right display name", "testSuite 1.0", ProjectUtils.getInformation(p).getDisplayName());
73     }
74     
75 }
76
Popular Tags