KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > earproject > ui > J2eeArchiveLogicalViewProviderTest


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.j2ee.earproject.ui;
21
22 import java.io.File JavaDoc;
23 import java.util.Arrays JavaDoc;
24 import java.util.HashSet JavaDoc;
25 import java.util.Set JavaDoc;
26 import org.netbeans.api.project.Project;
27 import org.netbeans.api.project.ProjectManager;
28 import org.netbeans.junit.NbTestCase;
29 import org.netbeans.modules.j2ee.earproject.EarProject;
30 import org.netbeans.modules.j2ee.earproject.EarProjectTest;
31 import org.netbeans.modules.j2ee.earproject.test.TestUtil;
32 import org.netbeans.modules.j2ee.earproject.ui.J2eeArchiveLogicalViewProvider.ArchiveLogicalViewRootNode;
33 import org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIteratorTest;
34 import org.openide.filesystems.FileObject;
35 import org.openide.filesystems.FileUtil;
36
37 /**
38  * Test functionality of {@link J2eeArchiveLogicalViewProvider}.
39  *
40  * @author Martin Krauskopf
41  */

42 public class J2eeArchiveLogicalViewProviderTest extends NbTestCase {
43     
44     private String JavaDoc serverInstanceID;
45     
46     public J2eeArchiveLogicalViewProviderTest(String JavaDoc testName) {
47         super(testName);
48     }
49     
50     protected void setUp() throws Exception JavaDoc {
51         clearWorkDir();
52         serverInstanceID = TestUtil.registerSunAppServer(this);
53     }
54     
55     public void testProjectFiles() throws Exception JavaDoc {
56         File JavaDoc prjDirF = new File JavaDoc(getWorkDir(), "testEA");
57         String JavaDoc name = "Test EnterpriseApplication";
58         String JavaDoc j2eeLevel = "1.4";
59         String JavaDoc jarName = "testEA-ejb";
60         
61         // creates a project we will use for the import
62
NewEarProjectWizardIteratorTest.generateEARProject(prjDirF, name, j2eeLevel,
63                 serverInstanceID, null, null, jarName, null, null, null);
64         Project earProject = ProjectManager.getDefault().findProject(FileUtil.toFileObject(prjDirF));
65         EarProjectTest.openProject((EarProject) earProject);
66         J2eeArchiveLogicalViewProvider.ArchiveLogicalViewRootNode rootNode = (ArchiveLogicalViewRootNode)
67                 ((LogicalViewProvider) earProject.getLookup().lookup(LogicalViewProvider.class)).createLogicalView();
68         Set JavaDoc<FileObject> expected = new HashSet JavaDoc<FileObject>(Arrays.asList(
69                 new FileObject[] {
70             earProject.getProjectDirectory().getFileObject("nbproject"),
71             earProject.getProjectDirectory().getFileObject("build.xml"),
72             earProject.getProjectDirectory().getFileObject("src")
73         }
74         ));
75         assertEquals("right project files", expected, rootNode.getProjectFiles());
76     }
77     
78 }
79
Popular Tags