package org.geotools.filter;

import java.net.URI;

import org.geotools.feature.AttributeTypeFactory;
import org.geotools.feature.DefaultFeatureTypeFactory;
import org.geotools.feature.Feature;
import org.geotools.feature.FeatureType;
import org.geotools.feature.FeatureTypeBuilder;

import junit.framework.TestCase;

public class AttributeExpressionTest extends TestCase {

	public void testFeature() throws Exception {
		
                FeatureTypeBuilder typeBuilder = new DefaultFeatureTypeFactory();
                typeBuilder.setName( "test" );
		typeBuilder.setNamespace( new URI("http://www.geotools.org/test") );
		typeBuilder.addType( AttributeTypeFactory.newAttributeType("foo", Integer.class ));
		typeBuilder.addType( AttributeTypeFactory.newAttributeType("bar", Double.class ));
		
		FeatureType type = typeBuilder.getFeatureType();
                Feature feature = type.create( new Object[]{new Integer( 1 ),new Double( 2.0 )}, "fid");
		
		AttributeExpressionImpl ex = new AttributeExpressionImpl( "foo" );
		assertEquals( new Integer( 1 ), ex.evaluate( feature ) );
		
		ex = new AttributeExpressionImpl( "@id" );
		assertEquals( "fid", ex.evaluate( feature ) );
	}
	
	
}
