KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > projectimport > eclipse > SingleProjectAnalysisTest


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.projectimport.eclipse;
21
22 import java.io.File JavaDoc;
23 import java.util.Collection JavaDoc;
24
25 /**
26  * Tests importing of single project (that is without workspace provided).
27  *
28  * <p>
29  * This is first level check if importer is working correctly - i.e. it is able
30  * to parse project without <code>ProjectImporterException<code> and similar to
31  * be thrown.
32  * </p>
33  *
34  * @author mkrauskopf
35  */

36 public final class SingleProjectAnalysisTest extends ProjectImporterTestCase {
37
38     public SingleProjectAnalysisTest(String JavaDoc name) {
39         super(name);
40     }
41     
42     public void testSimpleAloneProjectForLatestMilestone() throws Exception JavaDoc {
43         File JavaDoc projectDir = extractToWorkDir("simpleAlone-3.1M6.zip");
44         EclipseProject project = ProjectFactory.getInstance().load(projectDir);
45         assertNotNull(project);
46         doBasicProjectTest(project);
47         Collection JavaDoc projects = project.getProjectsEntries();
48         assertTrue("There are no required projects for the project.", projects.isEmpty());
49         printCollection("projects", projects);
50     }
51     
52     public void testEmptyWithoutConAndSrc58033() throws Exception JavaDoc {
53         File JavaDoc projectDir = extractToWorkDir("emptyWithoutConAndSrc-3.0.2.zip");
54         EclipseProject project = ProjectFactory.getInstance().load(projectDir);
55         assertNotNull(project);
56     }
57     
58     static void doBasicProjectTest(EclipseProject project) {
59         /* usage (see printOtherProjects to see how to use them) */
60         String JavaDoc name = project.getName();
61         assertTrue("Name cannot be null or empty", (name != null && !name.equals("")));
62         
63         File JavaDoc directory = project.getDirectory();
64         assertNotNull(directory);
65         
66         String JavaDoc jdkDir = project.getJDKDirectory();
67         // assertNotNull("Cannot resolve JDK directory \"" + jdkDir + "\"", jdkDir);
68

69         Collection JavaDoc srcRoots = project.getSourceRoots();
70         assertFalse("Tere should be at least on source root",
71                 srcRoots.isEmpty());
72         
73         Collection JavaDoc extSrcRoots = project.getExternalSourceRoots();
74         assertTrue("There shouldn't be any external source roots for the project",
75                 extSrcRoots.isEmpty());
76         
77         Collection JavaDoc libs = project.getLibraries();
78         assertTrue("There are no libraries for the project.", libs.isEmpty());
79         
80         Collection JavaDoc extLibs = project.getExternalLibraries();
81         assertTrue("There are no external libraries for the project",
82                 extLibs.isEmpty());
83         
84         Collection JavaDoc variables = project.getVariables();
85         assertTrue("There are no variables for the project.", variables.isEmpty());
86         
87         /* print data (if verbose is true) */
88         printMessage("\n\n\nGathered info:");
89         printMessage(" name: " + name);
90         printMessage(" dir: " + directory);
91         printMessage(" jdkDir: " + jdkDir);
92         printCollection("sourceRoots", srcRoots);
93         printCollection("externalSourceRoots", extSrcRoots);
94         printCollection("libraries", libs);
95         printCollection("external libraries", extLibs);
96         printCollection("variables", variables);
97     }
98 }
99
Popular Tags