TransactionXmlReader200 extends AbstractTransactionXmlReader { Update readUpdate( XMLStreamReader xmlStream ) throws NoSuchElementException, XMLStreamException { String handle = xmlStream.getAttributeValue( null, "handle" ); String inputFormat = xmlStream.getAttributeValue( null, "inputFormat" ); String srsName = xmlStream.getAttributeValue( null, "srsName" ); QName typeName = getRequiredAttributeValueAsQName( xmlStream, null, "typeName" ); nextElement( xmlStream ); xmlStream.require( START_ELEMENT, WFS_200_NS, "Property" ); return new Update( handle, null, typeName, inputFormat, srsName, xmlStream, this ); }  @Override Transaction read( XMLStreamReader xmlStream ); @Override TransactionAction readAction( XMLStreamReader xmlStream ); @Override Filter readFilter( XMLStreamReader xmlStream ); @Override PropertyReplacement readProperty( XMLStreamReader xmlStream );  }
@Test public void testReadUpdateWfs200SpecExample1() throws Exception { XMLStreamReader xmlStream = getXMLStreamReader( UPDATE_ACTION1 ); Update action = reader.readUpdate( xmlStream ); assertNull( action.getHandle() ); assertNull( action.getInputFormat() ); assertNull( action.getSRSName() ); Iterator<PropertyReplacement> replacementProps = action.getReplacementProps(); PropertyReplacement replacement = replacementProps.next(); assertNull( replacement.getUpdateAction() ); XMLStreamReader valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( new QName( "populationType" ), replacement.getPropertyName().getAsQName() ); assertEquals( "CITY", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); assertFalse( replacementProps.hasNext() ); nextElement( xmlStream ); Filter filter = action.getFilter(); assertNotNull( filter ); xmlStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Update" ); }
@Test public void testReadUpdateWfs200SpecExample2() throws Exception { XMLStreamReader xmlStream = getXMLStreamReader( UPDATE_ACTION2 ); Update action = reader.readUpdate( xmlStream ); assertNull( action.getHandle() ); assertNull( action.getInputFormat() ); assertNull( action.getSRSName() ); Iterator<PropertyReplacement> replacementProps = action.getReplacementProps(); PropertyReplacement replacement = replacementProps.next(); assertNull( replacement.getUpdateAction() ); assertEquals( new QName( "http: XMLStreamReader valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( "somestring", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); assertFalse( replacementProps.hasNext() ); nextElement( xmlStream ); Filter filter = action.getFilter(); assertNotNull( filter ); xmlStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Update" ); }
@Test public void testReadUpdateWfs200AllOptionalAttributes() throws Exception { XMLStreamReader xmlStream = getXMLStreamReader( UPDATE_ACTION3 ); Update action = reader.readUpdate( xmlStream ); assertEquals( "BLA", action.getHandle() ); assertEquals( "application/gml+xml; version=3.2", action.getInputFormat() ); assertEquals( "EPSG:4326", action.getSRSName() ); Iterator<PropertyReplacement> replacementProps = action.getReplacementProps(); PropertyReplacement replacement = replacementProps.next(); assertEquals( UpdateAction.REPLACE, replacement.getUpdateAction() ); assertEquals( new QName( "http: replacement.getPropertyName().getAsQName() ); XMLStreamReader valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( "CONIFEROUS", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); nextElement( valueStream ); assertTrue( replacementProps.hasNext() ); replacement = replacementProps.next(); assertEquals( UpdateAction.INSERT_AFTER, replacement.getUpdateAction() ); assertEquals( new QName( "http: replacement.getPropertyName().getAsQName() ); valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( "CONIFEROUS", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); nextElement( valueStream ); assertTrue( replacementProps.hasNext() ); replacement = replacementProps.next(); assertEquals( UpdateAction.INSERT_BEFORE, replacement.getUpdateAction() ); assertEquals( new QName( "http: replacement.getPropertyName().getAsQName() ); valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( "CONIFEROUS", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); nextElement( valueStream ); assertTrue( replacementProps.hasNext() ); replacement = replacementProps.next(); assertEquals( UpdateAction.REMOVE, replacement.getUpdateAction() ); assertEquals( new QName( "http: replacement.getPropertyName().getAsQName() ); valueStream = replacement.getReplacementValue(); valueStream.require( XMLStreamReader.START_ELEMENT, WFS_200_NS, "Value" ); assertEquals( "CONIFEROUS", valueStream.getElementText() ); nextElement( valueStream ); valueStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Property" ); nextElement( valueStream ); assertFalse( replacementProps.hasNext() ); Filter filter = action.getFilter(); assertNotNull( filter ); xmlStream.require( XMLStreamReader.END_ELEMENT, WFS_200_NS, "Update" ); }