001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: /*
042: * BeanInfoTest.java
043: * JUnit based test
044: *
045: * Created on September 1, 2006, 1:01 PM
046: */
047:
048: package org.netbeans.modules.visualweb.test;
049:
050: import java.beans.BeanInfo;
051: import java.beans.Introspector;
052: import java.beans.PropertyDescriptor;
053: import java.util.ArrayList;
054: import java.util.Arrays;
055: import java.util.HashMap;
056: import java.util.HashSet;
057: import java.util.List;
058: import java.util.Map;
059: import java.util.Set;
060: import javax.faces.component.html.*;
061: import junit.framework.*;
062:
063: /**
064: *
065: * @author gjmurphy
066: */
067: public class BeanInfoTest extends TestCase {
068:
069: Map beanMap = new HashMap();
070:
071: public BeanInfoTest(String testName) {
072: super (testName);
073: }
074:
075: protected void setUp() throws Exception {
076: beanMap.put(HtmlCommandButton.class, new String[] {
077: "accesskey", "action", "actionListener", "alt",
078: "attributes", "children", "childCount", "dir",
079: "disabled", "id", "family", "facets", "image",
080: "immediate", "lang", "onblur", "onchange", "onclick",
081: "ondblclick", "onfocus", "onkeydown", "onkeypress",
082: "onkeyup", "onmousedown", "onmousemove", "onmouseout",
083: "onmouseover", "onmouseup", "onselect", "parent",
084: "readonly", "rendered", "rendererType",
085: "rendersChildren", "style", "styleClass", "tabindex",
086: "title", "type", "value", });
087: beanMap.put(HtmlCommandLink.class, new String[] { "accesskey",
088: "action", "actionListener", "attributes", "charset",
089: "children", "childCount", "coords", "dir", "hreflang",
090: "id", "family", "facets", "immediate", "lang",
091: "onblur", "onclick", "ondblclick", "onfocus",
092: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
093: "onmousemove", "onmouseout", "onmouseover",
094: "onmouseup", "parent", "rel", "rendered",
095: "rendererType", "rendersChildren", "rev", "shape",
096: "style", "styleClass", "tabindex", "target", "title",
097: "type", "value", });
098: beanMap.put(HtmlDataTable.class, new String[] { "attributes",
099: "bgcolor", "border", "cellpadding", "cellspacing",
100: "children", "childCount", "columnClasses", "dir",
101: "first", "footerClass", "frame", "headerClass", "id",
102: "family", "facets", "lang", "onclick", "ondblclick",
103: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
104: "onmousemove", "onmouseout", "onmouseover",
105: "onmouseup", "parent", "rendered", "rendererType",
106: "rendersChildren", "rowAvailable", "rowClasses",
107: "rowCount", "rowData", "rowIndex", "rows", "rules",
108: "style", "styleClass", "summary", "title", "value",
109: "var", "width", });
110: beanMap.put(HtmlGraphicImage.class, new String[] { "alt",
111: "attributes", "children", "childCount", "dir",
112: "height", "id", "family", "facets", "ismap", "lang",
113: "longdesc", "onclick", "ondblclick", "onkeydown",
114: "onkeypress", "onkeyup", "onmousedown", "onmousemove",
115: "onmouseout", "onmouseover", "onmouseup", "parent",
116: "rendered", "rendererType", "rendersChildren", "style",
117: "styleClass", "title", "url", "usemap", "value",
118: "width", });
119: beanMap.put(HtmlInputHidden.class, new String[] { "attributes",
120: "children", "childCount", "converter", "id", "family",
121: "facets", "immediate", "localValue", "localValueSet",
122: "parent", "rendered", "rendererType",
123: "rendersChildren", "required", "submittedValue",
124: "validator", "value", "valueChangeListener", });
125: beanMap
126: .put(HtmlInputSecret.class, new String[] { "accesskey",
127: "alt", "attributes", "children", "childCount",
128: "converter", "dir", "disabled", "id", "family",
129: "facets", "immediate", "lang", "localValue",
130: "localValueSet", "maxlength", "onblur",
131: "onchange", "onclick", "ondblclick", "onfocus",
132: "onkeydown", "onkeypress", "onkeyup",
133: "onmousedown", "onmousemove", "onmouseout",
134: "onmouseover", "onmouseup", "onselect",
135: "parent", "readonly", "redisplay", "rendered",
136: "rendererType", "rendersChildren", "required",
137: "size", "style", "styleClass",
138: "submittedValue", "tabindex", "title",
139: "validator", "value", "valueChangeListener", });
140: beanMap.put(HtmlInputText.class, new String[] { "accesskey",
141: "alt", "attributes", "children", "childCount",
142: "converter", "dir", "disabled", "id", "family",
143: "facets", "immediate", "lang", "localValue",
144: "localValueSet", "maxlength", "onblur", "onchange",
145: "onclick", "ondblclick", "onfocus", "onkeydown",
146: "onkeypress", "onkeyup", "onmousedown", "onmousemove",
147: "onmouseout", "onmouseover", "onmouseup", "onselect",
148: "parent", "readonly", "rendered", "rendererType",
149: "rendersChildren", "required", "size", "style",
150: "styleClass", "submittedValue", "tabindex", "title",
151: "validator", "value", "valueChangeListener", });
152: beanMap.put(HtmlInputTextarea.class, new String[] {
153: "accesskey", "attributes", "children", "childCount",
154: "cols", "converter", "dir", "disabled", "id", "family",
155: "facets", "immediate", "lang", "localValue",
156: "localValueSet", "onblur", "onchange", "onclick",
157: "ondblclick", "onfocus", "onkeydown", "onkeypress",
158: "onkeyup", "onmousedown", "onmousemove", "onmouseout",
159: "onmouseover", "onmouseup", "onselect", "parent",
160: "readonly", "rendered", "rendererType",
161: "rendersChildren", "required", "rows", "style",
162: "styleClass", "submittedValue", "tabindex", "title",
163: "validator", "value", "valueChangeListener", });
164: beanMap.put(HtmlMessage.class, new String[] { "attributes",
165: "children", "childCount", "errorClass", "errorStyle",
166: "fatalClass", "fatalStyle", "for", "id", "family",
167: "facets", "infoClass", "infoStyle", "parent",
168: "rendered", "rendererType", "rendersChildren",
169: "showDetail", "showSummary", "style", "styleClass",
170: "title", "tooltip", "warnClass", "warnStyle", });
171: beanMap.put(HtmlMessages.class, new String[] { "attributes",
172: "children", "childCount", "errorClass", "errorStyle",
173: "fatalClass", "fatalStyle", "globalOnly", "id",
174: "family", "facets", "infoClass", "infoStyle", "layout",
175: "parent", "rendered", "rendererType",
176: "rendersChildren", "showDetail", "showSummary",
177: "style", "styleClass", "title", "tooltip", "warnClass",
178: "warnStyle", });
179: beanMap.put(HtmlOutputFormat.class, new String[] {
180: "attributes", "children", "childCount", "converter",
181: "escape", "id", "family", "facets", "localValue",
182: "parent", "rendered", "rendererType",
183: "rendersChildren", "style", "styleClass", "title",
184: "value", });
185: beanMap.put(HtmlOutputLabel.class, new String[] { "accesskey",
186: "attributes", "children", "childCount", "converter",
187: "dir", "for", "id", "family", "facets", "lang",
188: "localValue", "onblur", "onclick", "ondblclick",
189: "onfocus", "onkeydown", "onkeypress", "onkeyup",
190: "onmousedown", "onmousemove", "onmouseout",
191: "onmouseover", "onmouseup", "parent", "rendered",
192: "rendererType", "rendersChildren", "style",
193: "styleClass", "tabindex", "title", "value", });
194: beanMap.put(HtmlOutputLink.class, new String[] { "accesskey",
195: "attributes", "charset", "children", "childCount",
196: "converter", "coords", "dir", "hreflang", "id",
197: "family", "facets", "lang", "localValue", "onblur",
198: "onclick", "ondblclick", "onfocus", "onkeydown",
199: "onkeypress", "onkeyup", "onmousedown", "onmousemove",
200: "onmouseout", "onmouseover", "onmouseup", "parent",
201: "rel", "rendered", "rendererType", "rendersChildren",
202: "rev", "shape", "style", "styleClass", "tabindex",
203: "target", "title", "type", "value", });
204: beanMap.put(HtmlOutputText.class, new String[] { "attributes",
205: "children", "childCount", "converter", "escape", "id",
206: "family", "facets", "localValue", "parent", "rendered",
207: "rendererType", "rendersChildren", "style",
208: "styleClass", "title", "value", });
209: beanMap.put(HtmlSelectBooleanCheckbox.class, new String[] {
210: "accesskey", "attributes", "children", "childCount",
211: "converter", "dir", "disabled", "id", "family",
212: "facets", "immediate", "lang", "localValue",
213: "localValueSet", "onblur", "onchange", "onclick",
214: "ondblclick", "onfocus", "onkeydown", "onkeypress",
215: "onkeyup", "onmousedown", "onmousemove", "onmouseout",
216: "onmouseover", "onmouseup", "onselect", "parent",
217: "readonly", "rendered", "rendererType",
218: "rendersChildren", "required", "selected", "style",
219: "styleClass", "submittedValue", "tabindex", "title",
220: "validator", "value", "valueChangeListener", });
221: beanMap
222: .put(HtmlSelectManyCheckbox.class, new String[] {
223: "accesskey", "attributes", "border",
224: "children", "childCount", "converter", "dir",
225: "disabled", "disabledClass", "enabledClass",
226: "id", "family", "facets", "immediate", "lang",
227: "layout", "localValue", "localValueSet",
228: "onblur", "onchange", "onclick", "ondblclick",
229: "onfocus", "onkeydown", "onkeypress",
230: "onkeyup", "onmousedown", "onmousemove",
231: "onmouseout", "onmouseover", "onmouseup",
232: "onselect", "parent", "readonly", "rendered",
233: "rendererType", "rendersChildren", "required",
234: "selectedValues", "style", "styleClass",
235: "submittedValue", "tabindex", "title",
236: "validator", "value", "valueChangeListener", });
237: beanMap.put(HtmlSelectManyListbox.class, new String[] {
238: "accesskey", "attributes", "children", "childCount",
239: "converter", "dir", "disabled", "disabledClass",
240: "enabledClass", "id", "family", "facets", "immediate",
241: "lang", "localValue", "localValueSet", "onblur",
242: "onchange", "onclick", "ondblclick", "onfocus",
243: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
244: "onmousemove", "onmouseout", "onmouseover",
245: "onmouseup", "onselect", "parent", "readonly",
246: "rendered", "rendererType", "rendersChildren",
247: "required", "selectedValues", "size", "style",
248: "styleClass", "submittedValue", "tabindex", "title",
249: "validator", "value", "valueChangeListener", });
250: beanMap.put(HtmlSelectManyMenu.class, new String[] {
251: "accesskey", "attributes", "children", "childCount",
252: "converter", "dir", "disabled", "disabledClass",
253: "enabledClass", "id", "family", "facets", "immediate",
254: "lang", "localValue", "localValueSet", "onblur",
255: "onchange", "onclick", "ondblclick", "onfocus",
256: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
257: "onmousemove", "onmouseout", "onmouseover",
258: "onmouseup", "onselect", "parent", "readonly",
259: "rendered", "rendererType", "rendersChildren",
260: "required", "selectedValues", "style", "styleClass",
261: "submittedValue", "tabindex", "title", "validator",
262: "value", "valueChangeListener", });
263: beanMap.put(HtmlSelectOneListbox.class, new String[] {
264: "accesskey", "attributes", "children", "childCount",
265: "converter", "dir", "disabled", "disabledClass",
266: "enabledClass", "id", "family", "facets", "immediate",
267: "lang", "localValue", "localValueSet", "onblur",
268: "onchange", "onclick", "ondblclick", "onfocus",
269: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
270: "onmousemove", "onmouseout", "onmouseover",
271: "onmouseup", "onselect", "parent", "readonly",
272: "rendered", "rendererType", "rendersChildren",
273: "required", "size", "style", "styleClass",
274: "submittedValue", "tabindex", "title", "validator",
275: "value", "valueChangeListener", });
276: beanMap.put(HtmlSelectOneMenu.class, new String[] {
277: "accesskey", "attributes", "children", "childCount",
278: "converter", "dir", "disabled", "disabledClass",
279: "enabledClass", "id", "family", "facets", "immediate",
280: "lang", "localValue", "localValueSet", "onblur",
281: "onchange", "onclick", "ondblclick", "onfocus",
282: "onkeydown", "onkeypress", "onkeyup", "onmousedown",
283: "onmousemove", "onmouseout", "onmouseover",
284: "onmouseup", "onselect", "parent", "readonly",
285: "rendered", "rendererType", "rendersChildren",
286: "required", "style", "styleClass", "submittedValue",
287: "tabindex", "title", "validator", "value",
288: "valueChangeListener", });
289: beanMap.put(HtmlSelectOneRadio.class, new String[] {
290: "accesskey", "attributes", "border", "children",
291: "childCount", "converter", "dir", "disabled",
292: "disabledClass", "enabledClass", "id", "family",
293: "facets", "immediate", "lang", "layout", "localValue",
294: "localValueSet", "onblur", "onchange", "onclick",
295: "ondblclick", "onfocus", "onkeydown", "onkeypress",
296: "onkeyup", "onmousedown", "onmousemove", "onmouseout",
297: "onmouseover", "onmouseup", "onselect", "parent",
298: "readonly", "rendered", "rendererType",
299: "rendersChildren", "required", "style", "styleClass",
300: "submittedValue", "tabindex", "title", "validator",
301: "value", "valueChangeListener", });
302:
303: String[] sp = Introspector.getBeanInfoSearchPath();
304: List paths = new ArrayList(Arrays.asList(sp));
305: paths
306: .add("org.netbeans.modules.visualweb.faces.dt.component.html");
307: Introspector.setBeanInfoSearchPath((String[]) paths
308: .toArray(new String[paths.size()]));
309: }
310:
311: protected void tearDown() throws Exception {
312: }
313:
314: public void testBeanInfos() throws Exception {
315: for (Object key : beanMap.keySet()) {
316: Class beanClass = (Class) key;
317: this .testBeanInfo(beanClass);
318: }
319: }
320:
321: public void testBeanInfo(Class beanClass) throws Exception {
322: System.out.print(beanClass.getName() + "... ");
323: BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
324: String beanName = beanInfo.getBeanDescriptor().getName();
325: Set<String> expectedPropertySet = new HashSet(Arrays
326: .asList((String[]) beanMap.get(beanClass)));
327: Set<String> introspectedPropertySet = new HashSet();
328: for (PropertyDescriptor p : beanInfo.getPropertyDescriptors()) {
329: introspectedPropertySet.add(p.getName());
330: }
331: for (String prop : expectedPropertySet) {
332: this .assertTrue(beanName + " is missing '" + prop + "'",
333: introspectedPropertySet.contains(prop));
334: }
335: for (String prop : introspectedPropertySet) {
336: this .assertTrue(beanName + " should not have '" + prop
337: + "'", expectedPropertySet.contains(prop));
338: }
339: System.out.println("done");
340: }
341:
342: }
|