Hi,
What do you think about :
if (renderer == null) {
fail("returned renderer is null");
else if (!renderer instanceof LayerRenderer) {
fail("returned renderer is a " + renderer.getClass().getName());
}
}
Michaël
Sunburned Surveyor a écrit :
> That does help a little Michael.
>
> I'm basically checking two things in my test method, of which I only
> posted a snippet. I want to [1] make sure that the object returned by
> the RendererFactoryTool isn't null, and that [2] it is an instance of
> the LayerRenderer class.
>
> I appreciate the tip on the use of the instanceof operator. That will
> make my code a little cleaner.
>
> The Sunburned Surveyor
>
> On 5/5/07, *Michaël Michaud* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Hi,
>
> Maybe I don't see what you want to do (I just woke up), but it seems
> that your comment doesn't match your test.
> If testResult is an instance of LayerRenderer, so the renderer
> returned
> IS an instance of LayerRenderer !
>
> One more detail : "instance of" is a kind of boolean operator, you can
> just write : if (c instanceof LayerManager)
> No need to add == true
>
> Hope that helps
>
> Michaël
>
> A. Craig West a écrit :
>
> >I think it's just a typo, you have an extra semicolon at the end
> of the if...
> >-Craig
> >
> >On 5/4/07, Sunburned Surveyor < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> >
> >
> >>Hey guys. I need some help with the use of the instanceof
> operator. This one
> >>really has me stumped. :]
> >>
> >>In one of my unit tests I have the following test method:
> >>
> >> else if(testResult instanceof
> >>com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer
> >>== true);
> >> {
> >> Class thisClass = testResult.getClass();
> >> String toPrint = thisClass.getName();
> >> fail("The renderer returned was not an instance of
> >>LayerRenderer. The object " +
> >> "returned was a " + toPrint);
> >> }
> >>
> >>This test method fails and prints the following message: "The
> renderer
> >>returned was not an instance of LayerRenderer. The ojbect
> >> returned was a
> >>com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer"
> >>
> >>How could the testResult object not be an instance of the
> >>com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer
> >>when I use the instanceof operator, but be an object of that
> same class as
> >>indicated by the error message?
> >>
> >>Am I using the instanceof operator incorrectly?
> >>
> >>Thanks in advance for the help.
> >>
> >>The Sunburned Surveyor
> >>
> >>
> >>
>
> >>-------------------------------------------------------------------------
>
> >>This SF.net email is sponsored by DB2 Express
> >>Download DB2 Express C - the FREE version of DB2 express and take
> >>control of your XML. No limits. Just data. Click to get it now.
> >> http://sourceforge.net/powerbar/db2/
> >>_______________________________________________
> >>Jump-pilot-devel mailing list
> >> [email protected]
> <mailto:[email protected]>
> >>https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> >>
> >>
> >>
> >>
> >
> >-------------------------------------------------------------------------
> >This SF.net email is sponsored by DB2 Express
> >Download DB2 Express C - the FREE version of DB2 express and take
> >control of your XML. No limits. Just data. Click to get it now.
> >http://sourceforge.net/powerbar/db2/
> >_______________________________________________
> >Jump-pilot-devel mailing list
> >[email protected]
> <mailto:[email protected]>
> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> >
> >
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> <http://sourceforge.net/powerbar/db2/>
> _______________________________________________
> Jump-pilot-devel mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
>------------------------------------------------------------------------
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Jump-pilot-devel mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel