KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > earproject > ProjectEarTest


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;
21
22 import java.io.File JavaDoc;
23 import org.netbeans.api.project.ProjectManager;
24 import org.netbeans.junit.NbTestCase;
25 import org.netbeans.modules.j2ee.api.ejbjar.Ear;
26 import org.netbeans.modules.j2ee.dd.api.application.Application;
27 import org.netbeans.modules.j2ee.dd.api.application.DDProvider;
28 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
29 import org.netbeans.modules.j2ee.earproject.test.TestUtil;
30 import org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIteratorTest;
31 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject;
32 import org.openide.filesystems.FileObject;
33 import org.openide.filesystems.FileUtil;
34
35 /**
36  * @author Martin Krauskopf
37  */

38 public class ProjectEarTest extends NbTestCase {
39     
40     private String JavaDoc serverID;
41     
42     public ProjectEarTest(String JavaDoc testName) {
43         super(testName);
44     }
45     
46     protected void setUp() throws Exception JavaDoc {
47         super.setUp();
48         TestUtil.makeScratchDir(this);
49         serverID = TestUtil.registerSunAppServer(this);
50     }
51     
52     public void testModuleAddition() throws Exception JavaDoc {
53         // testing project
54
File JavaDoc earDirF = new File JavaDoc(getWorkDir(), "testEA");
55         String JavaDoc name = "Test EnterpriseApplication";
56         String JavaDoc j2eeLevel = J2eeModule.JAVA_EE_5;
57         String JavaDoc ejbName = "testEA-ejb";
58         NewEarProjectWizardIteratorTest.generateEARProject(earDirF, name, j2eeLevel,
59                 serverID, null, ejbName, null, null, null, null);
60         FileObject earDirFO = FileUtil.toFileObject(earDirF);
61         FileObject ejbProjectFO = earDirFO.getFileObject("testEA-ejb");
62         assertNotNull(ejbProjectFO);
63         
64         File JavaDoc earDirAnotherF = new File JavaDoc(getWorkDir(), "testEA-another");
65         NewEarProjectWizardIteratorTest.generateEARProject(earDirAnotherF, name, j2eeLevel,
66                 serverID, null, null, null, null, null, null);
67         FileObject earDirAnotherFO = FileUtil.toFileObject(earDirAnotherF);
68         EjbJarProject createdEjbJarProject = (EjbJarProject) ProjectManager.getDefault().findProject(ejbProjectFO);
69         assertNotNull("ejb project found", createdEjbJarProject);
70         Ear ear = Ear.getEar(earDirAnotherFO);
71         assertNotNull("have Ear instance", ear);
72         if (ear != null) {
73             ear.addEjbJarModule(createdEjbJarProject.getAPIEjbJar());
74         }
75         
76         EarProject earProject = (EarProject) ProjectManager.getDefault().findProject(earDirAnotherFO);
77         Application app = DDProvider.getDefault().getDDRoot(
78                 earProject.getAppModule().getDeploymentDescriptor());
79         assertSame("ejb added modules", 1, app.getModule().length);
80         
81     }
82     
83 }
84
Popular Tags