private final RevFeatureType testCreateFeatureType(ObjectId id, String typeSpec) { SimpleFeatureType type = null; if (typeSpec != null) { try { type = DataUtilities.createType("roads", typeSpec); } catch (SchemaException e) { throw new RuntimeException(e); } } return testCreateFeatureType(id, type); }
public @Test final void createFeatureType() { testCreateFeatureType(id1, "sp:String,ip:Integer,pp:Point:srid=4326"); }
public @Test final void createFeatureTypeUnsupportedAttributeType() { Class<?> unsupportedBinding = TimeZone.class; ex.expect(IllegalArgumentException.class); ex.expectMessage("unsupported type: " + unsupportedBinding.getName()); testCreateFeatureType(id1, "prop:" + unsupportedBinding.getName()); }
public @Test final void createFeatureTypeNullId() { ex.expect(NullPointerException.class); ex.expectMessage("id"); testCreateFeatureType(null, "sp:String,ip:Integer,pp:Point:srid=4326"); }
public @Test final void createFeatureTypeNullFeatureType() { ex.expect(NullPointerException.class); ex.expectMessage("type"); testCreateFeatureType(id1, (SimpleFeatureType) null); }
public @Test final void createFeatureTypeAllSupportedAttributeTypes() { FieldType[] fieldTypes = FieldType.values(); StringBuilder typeSpec = new StringBuilder(); for (FieldType ft : fieldTypes) { if (typeSpec.length() > 0) { typeSpec.append(','); } if (ft != FieldType.NULL && ft != FieldType.UNKNOWN) { typeSpec.append(ft + "_type:").append(ft.getBinding().getName()); } } final String spec = typeSpec.toString(); final RevFeatureType revFType = testCreateFeatureType(id1, spec); for (FieldType ft : fieldTypes) { if (ft == FieldType.NULL || ft == FieldType.UNKNOWN) { continue; } String attName = ft + "_type"; PropertyDescriptor descriptor = revFType.type().getDescriptor(attName); assertNotNull(descriptor); assertEquals(attName, ft.getBinding(), descriptor.getType().getBinding()); } }
sftb.setName(new NameImpl("SimpleName")); SimpleFeatureType featureType = sftb.buildFeatureType(); testCreateFeatureType(id1, featureType);
public @Test final void createFeatureTypeNillability() { FeatureTypeFactory ftf = CommonFactoryFinder.getFeatureTypeFactory(null); Name attName1 = new NameImpl("int_Type"); Name attName2 = new NameImpl("string_Type"); Class<?> binding = Integer.class; boolean isIdentifiable = false; boolean isAbstract = false; List<Filter> restrictions = null; AttributeType superType = null; InternationalString description = null; AttributeType attribute1 = ftf.createAttributeType(attName1, binding, isIdentifiable, isAbstract, restrictions, superType, description); AttributeType attribute2 = ftf.createAttributeType(attName2, binding, isIdentifiable, isAbstract, restrictions, superType, description); int minOccurs = 0; int maxOccurs = 1; boolean isNillable = true; Object defaultValue = null; AttributeDescriptor descriptor1 = ftf.createAttributeDescriptor(attribute1, attribute1.getName(), minOccurs, maxOccurs, isNillable, defaultValue); isNillable = false; AttributeDescriptor descriptor2 = ftf.createAttributeDescriptor(attribute2, attribute2.getName(), minOccurs, maxOccurs, isNillable, defaultValue); SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(ftf); sftb.add(descriptor1); sftb.add(descriptor2); sftb.setName(new NameImpl("SimpleName")); SimpleFeatureType featureType = sftb.buildFeatureType(); testCreateFeatureType(id1, featureType); }
sftb.setName(typeName); SimpleFeatureType featureType = sftb.buildFeatureType(); testCreateFeatureType(id1, featureType);