KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > freeform > TestBaseWeb


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.web.freeform;
21
22 import java.io.File JavaDoc;
23 import org.netbeans.api.project.Project;
24 import org.netbeans.api.project.ProjectManager;
25 import org.netbeans.junit.NbTestCase;
26 import org.netbeans.modules.ant.freeform.FreeformProject;
27 import org.openide.filesystems.FileObject;
28 import org.openide.filesystems.FileUtil;
29 import org.openide.modules.ModuleInfo;
30 import org.openide.util.Lookup;
31
32
33 /**
34  * Base class for web module project tests.
35  * @author Pavel Buzek
36  */

37 abstract class TestBaseWeb extends NbTestCase {
38
39     static {
40         TestBaseWeb.class.getClassLoader().setDefaultAssertionStatus(true);
41     }
42     
43     protected TestBaseWeb (String JavaDoc name) {
44         super(name);
45     }
46     
47     protected File JavaDoc egdir;
48     protected FileObject buildProperties;
49     protected FreeformProject jakarta;
50     protected FileObject helloWorldServlet;
51     protected FileObject helloWorldJsp;
52     protected FileObject jakartaIndex;
53     
54     protected void setUp() throws Exception JavaDoc {
55         Lookup.getDefault().lookup(ModuleInfo.class);
56         super.setUp();
57         egdir = FileUtil.normalizeFile(new File JavaDoc(getDataDir(), "example-projects"));
58         assertTrue("example dir " + egdir + " exists", egdir.exists());
59         FileObject jakartaDir = FileUtil.toFileObject(egdir).getFileObject("web_jakarta");
60         assertNotNull("found projdir", jakartaDir);
61         Project _jakarta = ProjectManager.getDefault().findProject(jakartaDir);
62         assertNotNull("have a project", _jakarta);
63         jakarta = (FreeformProject)_jakarta;
64         helloWorldServlet = jakartaDir.getFileObject("src/mypackage/HelloWorld.java");
65         assertNotNull("found HelloWorld.java", helloWorldServlet);
66         helloWorldJsp = jakartaDir.getFileObject("web/hello.jsp");
67         assertNotNull("found hello.jsp", helloWorldJsp);
68         jakartaIndex = jakartaDir.getFileObject("web/index.html");
69         assertNotNull("found index.html", jakartaIndex);
70         buildProperties = jakartaDir.getFileObject("build.properties");
71         assertNotNull("found build.properties", buildProperties);
72         
73     }
74     
75 }
76
Popular Tags