OK I have narrowed things down a BIT but still am not sure of the best
direction. Because my component is a template-based component (with a
.html file), the component is not self-contained in the Java class
like the Insert component. So, in the "testNoFormat" method when the
newInstance is called for my component it doesn't appear to be
handling the component as I expected. The newInstance returns a
component but the component.render(writer, cycle) never does anything.
I traced into the code running the test and in

   BaseComponent.renderComponent(writer,cycle)

the _outerCount is 0, so the _outer[i].render(writer,cycle) is never executed.

It APPEARS the newInstance cannot be usefully used to create a
component that is based on a template. I guess I now need to figure
out HOW to write a unit test for a component that is based on
templates.

Kevin

On 4/21/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> I think some of this will require getting a little bit more comforatable
> with the easymock.org library. If newBasePage() is setting up expected calls
> for isRewinding() and your component doesn't check for that then you might
> need to define your own version of that method.
>
> (You might want to double check whether or not you should be calling
> isRewinding() as well, as it's an important item to get right to make form
> rewinds work correctly)
>
> On 4/21/06, Kevin C. Dorff <[EMAIL PROTECTED]> wrote:
> >
> > This was asked before but there was no response, so, effectively I am
> > going to ask it again.
> >
> > I have some relatively simple (and not so simple) components I have
> > wrapped up into my own library. As part of my progression to Tapestry
> > 4, I am having to re-write the parts of the library and would like to
> > add some automated testing using JUnit and notably base them on
> > BaseComponentTestCase - I see it is now being used for a number of the
> > component tests within Tapestry.
> >
> > I have a component that is VERY similar to Insert but does some
> > optional special formatting on the data. Given that it is so similar
> > to insert I decided I should be able to just copy the TestInsert.java,
> > make a few modifications to the code, and it should work.
> >
> > The difference is that MY component is built using a template, ie, my
> > component consists of an .html file, a .jwc file, and a .java file
> > where the .java file is just providing support to the .jwc file for
> > creating values, etc. (via getter methods). The .html file is
> > incredible simple, a single INSERT componet. The .jwc file has pretty
> > much the same parameters as the Insert component plus a couple more.
> > This should be the simplest component in the world to test.
> >
> > So, from within my test I removed all methods except "newBasePage" and
> > "testNoFormat" to simplify things. I run the test and it fails with:
> >
> >   > Expectation failure on verify: isRewinding(): expected: 1, actual: 0
> >   >
> >   > junit.framework.AssertionFailedError: Expectation failure on
> > verify: isRewinding():
> >   >    expected: 1, actual: 0 at
> >   > org.easymock.internal.AbstractBehavior.verify(AbstractBehavior.java:63)
> > at
> >   > org.easymock.internal.ReplayState.verify(ReplayState.java:25) at
> >   > org.easymock.MockControl.verify(MockControl.java:189) at
> >   > org.apache.hivemind.test.HiveMindTestCase.verifyControls
> >   >   (HiveMindTestCase.java:649) at
> >   > ktap.tapestry.components.preinsert.TestPreInsert.testNoFormat
> >   >   (TestPreInsert.java:35) at
> >   > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> >   > sun.reflect.NativeMethodAccessorImpl.invoke
> >   >   (NativeMethodAccessorImpl.java:39) at
> >   > sun.reflect.DelegatingMethodAccessorImpl.invoke
> >   >   (DelegatingMethodAccessorImpl.java:25)
> >
> > Does BaseComponentTestCase just not work with template based
> > components? Am I missing something? Any thoughts or suggestions would
> > be greatly appreciated.
> >
> > If somebody has already written up a FAQ or something on using
> > BaseComponentTestCase you can just point me there, it seems like it
> > would be a useful bit of info for everybody.
> >
> > Kevin
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Jesse Kuhnert
> Tacos/Tapestry, team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to