01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * Created on Apr 29, 2004
17: */
18: package org.geotools.validation.attributes;
19:
20: import java.beans.BeanInfo;
21: import java.beans.Introspector;
22: import java.beans.PropertyDescriptor;
23: import java.net.URL;
24:
25: import junit.framework.TestCase;
26:
27: /**
28: * GazetteerNameValidationBeanInfoTest purpose.
29: * <p>
30: * Description of GazetteerNameValidationBeanInfoTest ...
31: * </p>
32: *
33: * @author dzwiers, Refractions Research, Inc.
34: * @author $Author: sploreg $ (last modification)
35: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/test/java/org/geotools/validation/attributes/GazetteerNameValidationBeanInfoTest.java $
36: * @version $Id: GazetteerNameValidationBeanInfoTest.java 20884 2006-08-07 14:10:46Z jgarnett $
37: */
38: public class GazetteerNameValidationBeanInfoTest extends TestCase {
39:
40: public GazetteerNameValidationBeanInfoTest() {
41: super ("");
42: }
43:
44: public GazetteerNameValidationBeanInfoTest(String s) {
45: super (s);
46: }
47:
48: /*
49: * Class to test for PropertyDescriptor[] getPropertyDescriptors()
50: */
51: public void testGetPropertyDescriptors() {
52: try {
53: GazetteerNameValidation gnv = new GazetteerNameValidation();
54: gnv.setName("test");
55: gnv.setGazetteer(new URL("http://http://hydra/time/"));
56: BeanInfo bi = Introspector.getBeanInfo(gnv.getClass());
57: PropertyDescriptor[] pd = bi.getPropertyDescriptors();
58: PropertyDescriptor url, name;
59: url = name = null;
60: for (int i = 0; i < pd.length; i++) {
61: if ("name".equals(pd[i].getName())) {
62: name = pd[i];
63: }
64: if ("gazetteer".equals(pd[i].getName())) {
65: url = pd[i];
66: }
67: }
68: assertNotNull(url);
69: assertNotNull(name);
70: assertTrue("test".equals(name.getReadMethod().invoke(gnv,
71: null)));
72: assertTrue((new URL("http://http://hydra/time/"))
73: .equals(url.getReadMethod().invoke(gnv, null)));
74: } catch (Exception e) {
75: e.printStackTrace();
76: fail(e.toString());
77: }
78: }
79:
80: }
|