visualweb.project.jsfloader/test/unit/src/org/netbeans/modules/visualweb/project/jsfloader/JsfJspDataObjectTest.java
Really making tests compilable.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
6 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7 * Other names may be trademarks of their respective owners.
9 * The contents of this file are subject to the terms of either the GNU
10 * General Public License Version 2 only ("GPL") or the Common
11 * Development and Distribution License("CDDL") (collectively, the
12 * "License"). You may not use this file except in compliance with the
13 * License. You can obtain a copy of the License at
14 * http://www.netbeans.org/cddl-gplv2.html
15 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16 * specific language governing permissions and limitations under the
17 * License. When distributing the software, include this License Header
18 * Notice in each file and include the License file at
19 * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
20 * particular file as subject to the "Classpath" exception as provided
21 * by Oracle in the GPL Version 2 section of the License file that
22 * accompanied this code. If applicable, add the following below the
23 * License Header, with the fields enclosed by brackets [] replaced by
24 * your own identifying information:
25 * "Portions Copyrighted [year] [name of copyright owner]"
27 * If you wish your version of this file to be governed by only the CDDL
28 * or only the GPL Version 2, indicate your decision by adding
29 * "[Contributor] elects to include this software in this distribution
30 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31 * single choice of license, a recipient has the option to distribute
32 * your version of this file under either the CDDL, the GPL Version 2 or
33 * to extend the choice of license to its licensees as provided above.
34 * However, if you add GPL Version 2 code and therefore, elected the GPL
35 * Version 2 license, then the option applies only if the new code is
36 * made subject to such option by the copyright holder.
40 * Portions Copyrighted 2007 Sun Microsystems, Inc.
43 package org.netbeans.modules.visualweb.project.jsfloader;
45 import org.netbeans.api.project.Project;
46 import org.netbeans.junit.NbTestCase;
47 import org.netbeans.modules.visualweb.project.jsfloader.test.SetupUtils;
48 import org.netbeans.modules.web.core.jsploader.api.TagLibParseCookie;
49 import org.openide.cookies.EditCookie;
50 import org.openide.cookies.EditorCookie;
51 import org.openide.cookies.OpenCookie;
52 import org.openide.filesystems.FileObject;
53 import org.openide.filesystems.FileUtil;
54 import org.openide.loaders.DataObject;
55 import org.openide.util.Lookup;
61 public class JsfJspDataObjectTest extends NbTestCase {
62 private Project project;
63 private FileObject projectRoot;
65 public JsfJspDataObjectTest(String testName) {
70 protected void setUp() throws Exception {
73 project = SetupUtils.setup(getWorkDir());
74 projectRoot = FileUtil.toFileObject(getWorkDir()).getFileObject("VWJavaEE5");
76 assertNotNull("Project should not be null", project);
77 assertNotNull("Project root folder should not be null", projectRoot);
81 protected void tearDown() throws Exception {
87 public void testFindPrimaryFile() throws Exception {
88 System.out.println("JsfJspDataLoader.findPrimaryFile");
89 FileObject webFolder = projectRoot.getFileObject("web");
90 FileObject pageBean = projectRoot.getFileObject("web/Page1.jsp");
91 FileObject plainJsp = projectRoot.getFileObject("web/index.jsp");
93 assertNotNull("webFolder FileObject should not be null", webFolder);
94 assertNotNull("pageBean FileObject should not be null", pageBean);
95 assertNotNull("plainJsp FileObject should not be null", plainJsp);
97 JsfJspDataLoader loader = SetupUtils.getJspLoader();
99 FileObject result1 = loader.findPrimaryFile(pageBean);
100 assertEquals("findPrimaryFile() on web/Page1.jsp did not work", result1, pageBean);
102 FileObject result2 = loader.findPrimaryFile(webFolder);
103 assertNull("findPrimaryFile() should not accept folder objects", result2);
105 FileObject result3 = loader.findPrimaryFile(plainJsp);
106 assertNull("FindPrimaryFile() should not accept non-visual web JSP files", result3);
110 * Test of getLookup method, of class JsfJspDataObject.
112 public void testGetLookup() throws Exception {
113 System.out.println("getLookup");
114 FileObject jspPage = projectRoot.getFileObject("web/Page1.jsp");
115 JsfJspDataObject instance = (JsfJspDataObject)DataObject.find(jspPage);
117 // test validity of lookup results
118 Lookup result = instance.getLookup();
119 JsfJspEditorSupport support = result.lookup(JsfJspEditorSupport.class);
120 OpenCookie openCookie = result.lookup(OpenCookie.class);
121 EditCookie editCookie = result.lookup(EditCookie.class);
122 EditorCookie editorCookie = result.lookup(EditorCookie.class);
123 TagLibParseCookie tagLibParseCookie = result.lookup(TagLibParseCookie.class);
125 assertNotNull("OpenCookie is null", openCookie);
126 assertNotNull("EditCookie is null", editCookie);
127 assertNotNull("EditorCookie is null", editorCookie);
128 assertNotNull("TagLibParseCookie is null", tagLibParseCookie);
129 assertNotNull("JsfJspEditorSupport is null", support);
131 assertEquals("getLookup and getCookie should return the same OpenCookie",
132 openCookie, instance.getCookie(OpenCookie.class));
133 assertEquals("getLookup and getCookie should return the same EditCookie",
134 editCookie, instance.getCookie(EditCookie.class));
135 assertEquals("getLookup and getCookie should return the same EditorCookie",
136 editorCookie, instance.getCookie(EditorCookie.class));
137 assertEquals("getLookup and getCookie should return the same TagLibParseCookie",
138 tagLibParseCookie, instance.getCookie(TagLibParseCookie.class));
139 assertEquals("getLookup and getCookie should return the same JsfJspEditorSupport",
140 support, instance.getCookie(JsfJspEditorSupport.class));
143 public void testGetCookie() throws Exception {
144 System.out.println("getCookie");
145 FileObject jspPage = projectRoot.getFileObject("web/Page1.jsp");
146 JsfJspDataObject instance = (JsfJspDataObject)DataObject.find(jspPage);
149 EditorCookie editorCookie = instance.getCookie(EditorCookie.class);
150 OpenCookie openCookie = instance.getCookie(OpenCookie.class);
151 EditCookie editCookie = instance.getCookie(EditCookie.class);
153 assertNotNull("OpenCookie is null", openCookie);
154 assertNotNull("EditCookie is null", editCookie);
155 assertNotNull("EditorCookie is null", editorCookie);
157 Lookup lookup = instance.getLookup();
159 assertEquals("getLookup and getCookie should return the same OpenCookie",
160 openCookie, lookup.lookup(OpenCookie.class));
161 assertEquals("getLookup and getCookie should return the same EditCookie",
162 editCookie, lookup.lookup(EditCookie.class));
163 assertEquals("getLookup and getCookie should return the same EditorCookie",
164 editorCookie, lookup.lookup(EditorCookie.class));
168 public void testCorrespondingJsfJava() throws Exception {
169 System.out.println("correspondingJsfJavaFile");
170 FileObject jspPage = projectRoot.getFileObject("web/Page1.jsp");
171 JsfJspDataObject instance = (JsfJspDataObject)DataObject.find(jspPage);
172 FileObject javaSrc = Utils.findJavaForJsp(instance.getPrimaryFile());
173 DataObject dobj = DataObject.find(javaSrc);
174 assertTrue("Corresponding java file needs to be JSF", dobj instanceof JsfJavaDataObject);
178 // * Test of createNodeDelegate method, of class JsfJspDataObject.
180 // public void testCreateNodeDelegate() {
181 // System.out.println("createNodeDelegate");
182 // JsfJspDataObject instance = null;
183 // Node expResult = null;
184 // Node result = instance.createNodeDelegate();
185 // assertEquals(expResult, result);
186 // // TODO review the generated test code and remove the default call to fail.
187 // fail("The test case is a prototype.");
191 // * Test of getHelpCtx method, of class JsfJspDataObject.
193 // public void testGetHelpCtx() {
194 // System.out.println("getHelpCtx");
195 // JsfJspDataObject instance = null;
196 // HelpCtx expResult = null;
197 // HelpCtx result = instance.getHelpCtx();
198 // assertEquals(expResult, result);
199 // // TODO review the generated test code and remove the default call to fail.
200 // fail("The test case is a prototype.");
204 // * Test of createCookie method, of class JsfJspDataObject.
206 // public void testCreateCookie() {
207 // System.out.println("createCookie");
208 // Class klass = null;
209 // JsfJspDataObject instance = null;
210 // Cookie expResult = null;
211 // Cookie result = instance.createCookie(klass);
212 // assertEquals(expResult, result);
213 // // TODO review the generated test code and remove the default call to fail.
214 // fail("The test case is a prototype.");
218 // * Test of getCookieSet0 method, of class JsfJspDataObject.
220 // public void testGetCookieSet0() {
221 // System.out.println("getCookieSet0");
222 // JsfJspDataObject instance = null;
223 // CookieSet expResult = null;
224 // CookieSet result = instance.getCookieSet0();
225 // assertEquals(expResult, result);
226 // // TODO review the generated test code and remove the default call to fail.
227 // fail("The test case is a prototype.");
232 // * Test of getPureCookie method, of class JsfJspDataObject.
234 // public void testGetPureCookie() {
235 // System.out.println("getPureCookie");
236 // Class clazz = null;
237 // JsfJspDataObject instance = null;
238 // Cookie expResult = null;
239 // Cookie result = instance.getPureCookie(clazz);
240 // assertEquals(expResult, result);
241 // // TODO review the generated test code and remove the default call to fail.
242 // fail("The test case is a prototype.");
246 // * Test of getCookie method, of class JsfJspDataObject.
248 // public void testGetCookie() {
249 // System.out.println("getCookie");
250 // Class clazz = null;
251 // JsfJspDataObject instance = null;
252 // Cookie expResult = null;
253 // Cookie result = instance.getCookie(clazz);
254 // assertEquals(expResult, result);
255 // // TODO review the generated test code and remove the default call to fail.
256 // fail("The test case is a prototype.");
260 // * Test of getFileEncoding method, of class JsfJspDataObject.
262 // public void testGetFileEncoding() {
263 // System.out.println("getFileEncoding");
264 // JsfJspDataObject instance = null;
265 // String expResult = "";
266 // String result = instance.getFileEncoding();
267 // assertEquals(expResult, result);
268 // // TODO review the generated test code and remove the default call to fail.
269 // fail("The test case is a prototype.");
273 // * Test of updateFileEncoding method, of class JsfJspDataObject.
275 // public void testUpdateFileEncoding() {
276 // System.out.println("updateFileEncoding");
277 // boolean fromEditor = false;
278 // JsfJspDataObject instance = null;
279 // instance.updateFileEncoding(fromEditor);
280 // // TODO review the generated test code and remove the default call to fail.
281 // fail("The test case is a prototype.");
285 // * Test of pureCopy method, of class JsfJspDataObject.
287 // public void testPureCopy() throws Exception {
288 // System.out.println("pureCopy");
289 // DataFolder folder = null;
290 // JsfJspDataObject instance = null;
291 // instance.pureCopy(folder);
292 // // TODO review the generated test code and remove the default call to fail.
293 // fail("The test case is a prototype.");
298 // * Test of handleDelete method, of class JsfJspDataObject.
300 // public void testHandleDelete() throws Exception {
301 // System.out.println("handleDelete");
302 // JsfJspDataObject instance = null;
303 // instance.handleDelete();
304 // // TODO review the generated test code and remove the default call to fail.
305 // fail("The test case is a prototype.");
309 // * Test of handleCreateFromTemplate method, of class JsfJspDataObject.
311 // public void testHandleCreateFromTemplate() throws Exception {
312 // System.out.println("handleCreateFromTemplate");
313 // DataFolder df = null;
315 // JsfJspDataObject instance = null;
316 // DataObject expResult = null;
317 // DataObject result = instance.handleCreateFromTemplate(df, name);
318 // assertEquals(expResult, result);
319 // // TODO review the generated test code and remove the default call to fail.
320 // fail("The test case is a prototype.");
324 // * Test of handleRename method, of class JsfJspDataObject.
326 // public void testHandleRename() throws Exception {
327 // System.out.println("handleRename");
329 // JsfJspDataObject instance = null;
330 // FileObject expResult = null;
331 // FileObject result = instance.handleRename(name);
332 // assertEquals(expResult, result);
333 // // TODO review the generated test code and remove the default call to fail.
334 // fail("The test case is a prototype.");