KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
24 import java.util.Arrays JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 /**
29  * Tests importing of complex project (still without workspace provided). This
30  * test should check all features if project analyzer.
31  *
32  * @author mkrauskopf
33  */

34 public class WorkspaceAnalysisTest extends ProjectImporterTestCase {
35
36     public WorkspaceAnalysisTest(String JavaDoc name) {
37         super(name);
38     }
39
40     public void testComplexAloneProjectFor_3_1_M6() throws Exception JavaDoc {
41         File JavaDoc workspaceDir = extractToWorkDir("workspace-test-3.1M6.zip");
42         Workspace workspace = WorkspaceFactory.getInstance().load(workspaceDir);
43         assertNotNull("Unable to load workspace", workspace);
44         printMessage("Checking " + workspace.getDirectory());
45         assertFalse("Workspace shouldn't be emtpy", workspace.getProjects().isEmpty());
46         printMessage("Project in the workspace: " + workspace.getProjects());
47         
48         // Below information are just known. Get familiar with tested zips
49
// (which could be created by the helper script createWorkspace.sh)
50
String JavaDoc[] ws31M6ProjectNames = {"p1", "p2", "p3"};
51         String JavaDoc[] p1RequiredProjects = {"/p2", "/p3"};
52         
53         boolean p1Tested = false;
54         Collection JavaDoc/*<String>*/ p1ReqProjectsNames =
55                 new ArrayList JavaDoc(Arrays.asList(p1RequiredProjects));
56         Collection JavaDoc/*<String>*/ wsProjectNames =
57                 new ArrayList JavaDoc(Arrays.asList(ws31M6ProjectNames));
58         Collection JavaDoc/*<EclipseProject>*/ gainedP1ReqProjects = null;
59         
60         for (Iterator JavaDoc it = workspace.getProjects().iterator(); it.hasNext(); ) {
61             EclipseProject project = (EclipseProject) it.next();
62             /* Test p1 project and its dependencies. */
63             if ("p1".equals(project.getName())) {
64                 SingleProjectAnalysisTest.doBasicProjectTest(project); // for p1
65
gainedP1ReqProjects = project.getProjectsEntries();
66                 assertEquals("Incorrect project count for p1",
67                         p1RequiredProjects.length, gainedP1ReqProjects.size());
68                 printCollection("projects", gainedP1ReqProjects);
69                 p1Tested = true;
70             }
71             wsProjectNames.remove(project.getName());
72         }
73         assertTrue("\"p1\" project wasn't found in the workspace.", p1Tested);
74         assertTrue("All project should be processed.", wsProjectNames.isEmpty());
75         for (Iterator JavaDoc it = gainedP1ReqProjects.iterator(); it.hasNext(); ) {
76             p1ReqProjectsNames.remove(((ClassPathEntry)it.next()).getRawPath());
77         }
78         assertTrue("\"p1\" project depends on unknown projects: " + p1ReqProjectsNames,
79                 p1ReqProjectsNames.isEmpty());
80     }
81     
82     public void test_73542() throws Exception JavaDoc {
83         File JavaDoc workspaceDir = extractToWorkDir("workspace_73542-3.1.2.zip");
84         Workspace workspace = WorkspaceFactory.getInstance().load(workspaceDir);
85         assertNotNull("Unable to load workspace", workspace);
86     }
87     
88 }
89
Popular Tags