islands/tests/RobustXmlFeedParserTest.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 08 Oct 2014 00:33:44 +0100
changeset 387 e2b2ccaa4de6
child 389 009c2e13973c
permissions -rw-r--r--
Commited a island parser support (MC package PetitIslands) Name: PetitIslands-JanKurs.10 Author: JanKurs Time: 06-10-2014, 11:50:57 AM UUID: 19560ad2-4899-43d5-8c69-cf7274ad4f04 Repository: http://smalltalkhub.com/mc/Moose/PetitParser/main

"{ Package: 'stx:goodies/petitparser/islands/tests' }"

PPCompositeParserTest subclass:#RobustXmlFeedParserTest
	instanceVariableNames:'debugResult'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitIslands-Examples'
!

RobustXmlFeedParserTest comment:''
!

!RobustXmlFeedParserTest methodsFor:'as yet unclassified'!

feed03
^'
<shoplist>
<name>ABC Shop</name>
<address>Here and there 123, 123 45 Somewhere</address>
<item>
  <name>socks</name>
  <price>123</price>
  <availability>1</availability>
</item>


<item>
  <name> shoes </name>
  <price>2345</price>
  <!!-- this one is malformed -->
  <availability>1 </
</item>

<item>
  <name> shoes </name>
  <price>3456</price>
  <availability>0</availability>
</item>


</shoplist>
'
!

parserClass
	^ RobustXmlFeedParser 
!

testXmlFeed03
	self parse: self feed03.
	
	self assert: result size = 3.
	self assert: (result first at:#name) = 'socks'.
	self assert: (result first at:#price) = '123'.
	self assert: (result first at:#availability) = '1'.

	self assert: (result second at:#name) = 'shoes'.
	self assert: (result second at:#price) = '2345'.
	
	self assert: (result third at:#name) = 'shoes'.
	self assert: (result third at:#price) = '3456'.
	self assert: (result third at:#availability) = '0'.
! !