/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
 *   
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation; either
 *    version 2.1 of the License, or (at your option) any later version.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    Created on Apr 29, 2004
 */
package org.geotools.validation.attributes;

import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.net.URL;

import junit.framework.TestCase;
/**
 * GazetteerNameValidationBeanInfoTest purpose.
 * <p>
 * Description of GazetteerNameValidationBeanInfoTest ...
 * </p>
 * 
 * @author dzwiers, Refractions Research, Inc.
 * @author $Author: sploreg $ (last modification)
 * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/test/java/org/geotools/validation/attributes/GazetteerNameValidationBeanInfoTest.java $
 * @version $Id: GazetteerNameValidationBeanInfoTest.java 20884 2006-08-07 14:10:46Z jgarnett $
 */
public class GazetteerNameValidationBeanInfoTest extends TestCase {

	public GazetteerNameValidationBeanInfoTest(){super("");}
	public GazetteerNameValidationBeanInfoTest(String s){super(s);}
	/*
	 * Class to test for PropertyDescriptor[] getPropertyDescriptors()
	 */
	public void testGetPropertyDescriptors() {
		try{
			GazetteerNameValidation gnv = new GazetteerNameValidation();
			gnv.setName("test");
			gnv.setGazetteer(new URL("http://http://hydra/time/"));
			BeanInfo bi = Introspector.getBeanInfo(gnv.getClass());
			PropertyDescriptor[] pd = bi.getPropertyDescriptors();
			PropertyDescriptor url, name;url = name = null;
			for(int i=0;i<pd.length;i++){
				if("name".equals(pd[i].getName())){
					name = pd[i];
				}
				if("gazetteer".equals(pd[i].getName())){
					url = pd[i];
				}
			}
			assertNotNull(url);
			assertNotNull(name);
			assertTrue("test".equals(name.getReadMethod().invoke(gnv,null)));
			assertTrue((new URL("http://http://hydra/time/")).equals(url.getReadMethod().invoke(gnv,null)));
		}catch(Exception e){
			e.printStackTrace();
			fail(e.toString());
		}
	}

}
