01: package org.geoserver.wfs.xml;
02:
03: import javax.xml.namespace.QName;
04:
05: import org.eclipse.xsd.XSDComplexTypeDefinition;
06: import org.eclipse.xsd.XSDElementDeclaration;
07: import org.eclipse.xsd.XSDSchema;
08: import org.eclipse.xsd.XSDTypeDefinition;
09:
10: import org.geoserver.data.test.MockData;
11: import org.geoserver.wfs.WFSTestSupport;
12: import org.geotools.gml2.bindings.GML;
13: import org.geotools.xml.Schemas;
14: import org.vfny.geoserver.global.FeatureTypeInfo;
15:
16: public class FeatureTypeInfoSchemaBuilderTest extends WFSTestSupport {
17:
18: public void testBuildGml2() throws Exception {
19: FeatureTypeSchemaBuilder builder = new FeatureTypeSchemaBuilder.GML2(
20: getWFS(), getCatalog(), getResourceLoader());
21:
22: FeatureTypeInfo lines = getCatalog().getFeatureTypeInfo(
23: MockData.LINES);
24: XSDSchema schema = builder.build(
25: new FeatureTypeInfo[] { lines }, getWFS()
26: .getOnlineResource().toExternalForm());
27:
28: assertNotNull(schema);
29: XSDElementDeclaration element = Schemas.getElementDeclaration(
30: schema, MockData.LINES);
31: assertNotNull(element);
32:
33: assertTrue(element.getType() instanceof XSDComplexTypeDefinition);
34:
35: XSDElementDeclaration id = Schemas.getChildElementDeclaration(
36: element, new QName(MockData.CGF_URI, "id"));
37: assertNotNull(id);
38:
39: XSDElementDeclaration lineStringProperty = Schemas
40: .getChildElementDeclaration(element, new QName(
41: MockData.CGF_URI, "lineStringProperty"));
42: assertNotNull(lineStringProperty);
43:
44: XSDTypeDefinition lineStringPropertyType = lineStringProperty
45: .getType();
46: assertEquals(GML.NAMESPACE, lineStringPropertyType
47: .getTargetNamespace());
48: assertEquals(GML.LINESTRINGPROPERTYTYPE.getLocalPart(),
49: lineStringPropertyType.getName());
50:
51: XSDTypeDefinition geometryAssociationType = lineStringPropertyType
52: .getBaseType();
53: assertNotNull(geometryAssociationType);
54: assertEquals(GML.NAMESPACE, geometryAssociationType
55: .getTargetNamespace());
56: assertEquals(GML.GEOMETRYASSOCIATIONTYPE.getLocalPart(),
57: geometryAssociationType.getName());
58: }
59: }
|