001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.projectimport.eclipse;
043:
044: import java.io.File;
045: import java.util.Collection;
046:
047: /**
048: * Tests importing of single project (that is without workspace provided).
049: *
050: * <p>
051: * This is first level check if importer is working correctly - i.e. it is able
052: * to parse project without <code>ProjectImporterException<code> and similar to
053: * be thrown.
054: * </p>
055: *
056: * @author mkrauskopf
057: */
058: public final class SingleProjectAnalysisTest extends
059: ProjectImporterTestCase {
060:
061: public SingleProjectAnalysisTest(String name) {
062: super (name);
063: }
064:
065: public void testSimpleAloneProjectForLatestMilestone()
066: throws Exception {
067: File projectDir = extractToWorkDir("simpleAlone-3.1M6.zip");
068: EclipseProject project = ProjectFactory.getInstance().load(
069: projectDir);
070: assertNotNull(project);
071: doBasicProjectTest(project);
072: Collection projects = project.getProjectsEntries();
073: assertTrue("There are no required projects for the project.",
074: projects.isEmpty());
075: printCollection("projects", projects);
076: }
077:
078: public void testEmptyWithoutConAndSrc58033() throws Exception {
079: File projectDir = extractToWorkDir("emptyWithoutConAndSrc-3.0.2.zip");
080: EclipseProject project = ProjectFactory.getInstance().load(
081: projectDir);
082: assertNotNull(project);
083: }
084:
085: static void doBasicProjectTest(EclipseProject project) {
086: /* usage (see printOtherProjects to see how to use them) */
087: String name = project.getName();
088: assertTrue("Name cannot be null or empty",
089: (name != null && !name.equals("")));
090:
091: File directory = project.getDirectory();
092: assertNotNull(directory);
093:
094: String jdkDir = project.getJDKDirectory();
095: // assertNotNull("Cannot resolve JDK directory \"" + jdkDir + "\"", jdkDir);
096:
097: Collection srcRoots = project.getSourceRoots();
098: assertFalse("Tere should be at least on source root", srcRoots
099: .isEmpty());
100:
101: Collection extSrcRoots = project.getExternalSourceRoots();
102: assertTrue(
103: "There shouldn't be any external source roots for the project",
104: extSrcRoots.isEmpty());
105:
106: Collection libs = project.getLibraries();
107: assertTrue("There are no libraries for the project.", libs
108: .isEmpty());
109:
110: Collection extLibs = project.getExternalLibraries();
111: assertTrue("There are no external libraries for the project",
112: extLibs.isEmpty());
113:
114: Collection variables = project.getVariables();
115: assertTrue("There are no variables for the project.", variables
116: .isEmpty());
117:
118: /* print data (if verbose is true) */
119: printMessage("\n\n\nGathered info:");
120: printMessage(" name: " + name);
121: printMessage(" dir: " + directory);
122: printMessage(" jdkDir: " + jdkDir);
123: printCollection("sourceRoots", srcRoots);
124: printCollection("externalSourceRoots", extSrcRoots);
125: printCollection("libraries", libs);
126: printCollection("external libraries", extLibs);
127: printCollection("variables", variables);
128: }
129: }
|