001: package org.geoserver.wfs.v1_1;
002:
003: import net.opengis.ows.OwsFactory;
004: import net.opengis.wfs.GetCapabilitiesType;
005: import net.opengis.wfs.WfsFactory;
006:
007: import org.geoserver.wfs.CapabilitiesTransformer;
008: import org.geoserver.wfs.GetCapabilities;
009: import org.geoserver.wfs.WFSTestSupport;
010: import org.geotools.xml.transform.TransformerBase;
011:
012: public class VersionNegotiationTest extends WFSTestSupport {
013:
014: GetCapabilities getCaps;
015:
016: WfsFactory factory;
017:
018: OwsFactory owsFactory;
019:
020: protected void setUp() throws Exception {
021: super .setUp();
022:
023: getCaps = new GetCapabilities(getWFS(), getCatalog());
024:
025: factory = WfsFactory.eINSTANCE;
026: owsFactory = OwsFactory.eINSTANCE;
027: }
028:
029: public void test0() throws Exception {
030: // test when provided and accepted match up
031: GetCapabilitiesType request = factory
032: .createGetCapabilitiesType();
033: request.setService("WFS");
034: request
035: .setAcceptVersions(owsFactory
036: .createAcceptVersionsType());
037: request.getAcceptVersions().getVersion().add("1.0.0");
038: request.getAcceptVersions().getVersion().add("1.1.0");
039:
040: TransformerBase tx = getCaps.run(request);
041: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_1);
042: }
043:
044: public void test1() throws Exception {
045: // test accepted only 1.0
046: GetCapabilitiesType request = factory
047: .createGetCapabilitiesType();
048: request.setService("WFS");
049: request
050: .setAcceptVersions(owsFactory
051: .createAcceptVersionsType());
052: request.getAcceptVersions().getVersion().add("1.0.0");
053:
054: TransformerBase tx = getCaps.run(request);
055: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_0);
056: }
057:
058: public void test2() throws Exception {
059: // test accepted only 1.1
060: GetCapabilitiesType request = factory
061: .createGetCapabilitiesType();
062: request.setService("WFS");
063: request
064: .setAcceptVersions(owsFactory
065: .createAcceptVersionsType());
066: request.getAcceptVersions().getVersion().add("1.1.0");
067:
068: TransformerBase tx = getCaps.run(request);
069: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_1);
070: }
071:
072: public void test5() throws Exception {
073: // test accepted = 0.0.0
074:
075: GetCapabilitiesType request = factory
076: .createGetCapabilitiesType();
077: request.setService("WFS");
078: request
079: .setAcceptVersions(owsFactory
080: .createAcceptVersionsType());
081: request.getAcceptVersions().getVersion().add("0.0.0");
082:
083: TransformerBase tx = getCaps.run(request);
084: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_0);
085: }
086:
087: public void test6() throws Exception {
088: // test accepted = 1.1.1
089:
090: GetCapabilitiesType request = factory
091: .createGetCapabilitiesType();
092: request.setService("WFS");
093: request
094: .setAcceptVersions(owsFactory
095: .createAcceptVersionsType());
096: request.getAcceptVersions().getVersion().add("1.1.1");
097:
098: TransformerBase tx = getCaps.run(request);
099: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_1);
100: }
101:
102: public void test7() throws Exception {
103: // test accepted = 1.0.5
104: GetCapabilitiesType request = factory
105: .createGetCapabilitiesType();
106: request.setService("WFS");
107: request
108: .setAcceptVersions(owsFactory
109: .createAcceptVersionsType());
110: request.getAcceptVersions().getVersion().add("1.0.5");
111:
112: TransformerBase tx = getCaps.run(request);
113: assertTrue(tx instanceof CapabilitiesTransformer.WFS1_0);
114: }
115:
116: }
|