cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Knecht <>
Subject Re: Problematical implementation of Iterator API ?
Date Sat, 03 Nov 2007 20:32:51 GMT
Carsten Ziegeler schrieb:
> Felix Knecht wrote:
>> Hi all
>> I have found at different locations [1] an implementation (more or less similar)
for an EmptyIterator, e.g.
>> static class EmptyIterator implements Iterator {
>>     public boolean hasNext() { return false; }
>>     public Object next() { return null; }
>>     public void remove() {}
>> }
>> Many of them are lacking the same problem:
>> Iterator next() [2] method says to throws an exception when there are no more elements
to return (what would be the case
>> here). In fact null is returned instead of an error.
>> Is this done this way on purpose?
> No, it's a mistake - I never read the java docs correctly :(
> So it should throw an exception.

Trying to fix it I run into following testcase failure:

Test set: org.apache.cocoon.template.jxtg.JXTemplateGeneratorTestCase
Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.133 sec <<< FAILURE!
testJXForEach(org.apache.cocoon.template.jxtg.JXTemplateGeneratorTestCase)  Time elapsed:
0.174 sec  <<< FAILURE!
junit.framework.AssertionFailedError: Test if the assertion document is equal, org.custommonkey.xmlunit.Diff
[different] Expected presence of child nodes to be 'true' but was 'false' - comparing <loop...>
to <loop...>
 expected:<true> but was:<false>
	at junit.framework.Assert.failNotEquals(
	at junit.framework.Assert.assertEquals(
	at junit.framework.Assert.assertEquals(
	at org.apache.cocoon.SitemapComponentTestCase.assertEqual(

The problem is, that I'm not really sure if the testcase is testing the way it should. - and
this is what I'd like to

(before JXTransformation)
<root xmlns:jx="">
  <snip />

    <jx:forEach varStatus="status" begin="1" end="5">

should produce (so the testcase) (,after JXTransformation)
  <snip />


Now my question:

Documentation for 2.2. is still not complete, so the link to 2.1 [1]
"The forEach tag allows you to iterate over a collection of objects, ..."

In the 'before' I'm completely missing a collection thus a result should IMO rather look like
  <snip />



[1] [forEach]

View raw message