You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Sean Schofield <se...@gmail.com> on 2006/02/18 01:27:32 UTC

Re: Weird ClassCastException

Yeah I was thinking that maven is relying on the jars and since there
is a config file in there the myfaces render kit is getting loaded
instead.

I will check into it.  Thanks.

Sean

On 2/17/06, Craig McClanahan <cr...@apache.org> wrote:
> On 2/17/06, Sean Schofield <se...@gmail.com> wrote:
> >
> > Yeah this is the test.
>
>
> Ah, you meant line 131 of AbstractJsfTestCase :-)
>
> The only thing I can think of is maybe somehow the "real" API classes might
> be getting injected into the classpath somehow.  Maybe you could try
> temporarily changing the variable type to RenderKit instead of
> MockRenderKit, and change the assignment to:
>
>        renderKit = renderKitFactory.getRenderKit(null,
> RenderKitFactory.HTML_BASIC_RENDER_KIT);
>        System.out.println("Renderer type is " + renderKit.getClass
> ().getClassName());
>
> and see if you get the MyFaces implementation?
>
> Craig
>
>
>
> -------------------------------------------------------------------------------
> > Battery: org.apache.myfaces.custom.tree2.HtmlTreeRendererTest
> >
> >
> -------------------------------------------------------------------------------
> > Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.046 sec
> >
> > testHideRootNodeServer(
> > org.apache.myfaces.custom.tree2.HtmlTreeRendererTest)
> > Time elapsed: 0.016 sec  <<< ERROR!
> >
> > [ stdout ] ---------------------------------------------------------------
> >
> >
> >
> > [ stderr ] ---------------------------------------------------------------
> >
> >
> >
> > [ stacktrace ] -----------------------------------------------------------
> >
> > java.lang.ClassCastException
> >         at org.apache.shale.test.base.AbstractJsfTestCase.setUp(
> > AbstractJsfTestCase.java:131)
> >         at org.apache.myfaces.custom.tree2.HtmlTreeRendererTest.setUp(
> > HtmlTreeRendererTest.java:82)
> >         at junit.framework.TestCase.runBare(TestCase.java:125)
> >         at junit.framework.TestResult$1.protect(TestResult.java:106)
> >         at junit.framework.TestResult.runProtected(TestResult.java:124)
> >         at junit.framework.TestResult.run(TestResult.java:109)
> >         at junit.framework.TestCase.run(TestCase.java:118)
> >         at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >         at junit.framework.TestSuite.run(TestSuite.java:203)
> >
> > On 2/17/06, Craig McClanahan <cr...@apache.org> wrote:
> > > On 2/17/06, Sean Schofield <se...@gmail.com> wrote:
> > > >
> > > > I'm attaching my test case.  Its a test for the latest MyFaces trunk
> > code.
> > >
> > >
> > > Are you sure this is the failing test?  It doesn't seem to have the line
> > you
> > > quotes earlier.
> > >
> > > Craig
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Weird ClassCastException

Posted by Craig McClanahan <cr...@apache.org>.
On 2/19/06, Sean Schofield <se...@gmail.com> wrote:
>
> One other thing.  I believe we should change the suite() method in
> AbstractJsfTestCase to return new TestSuite().
>
> I had an abstract test class of my own that extended
> AbstractJsfTestCase but I didn't have the suite method thinking - hey
> this is abstract anyways so what is there to test.  Well maven2 threw
> an assertion error that there were no test methods in the class.  I
> only had this with maven2.  When running in the IDE - no problems.
>
> I believe Shale will have the same problem when it eventually switches
> to maven2 for the build.  An empty TestSuite seems to do the trick
> though.


Makes sense ... this will show up in nightly build 20060220.

Sean


Craig

Re: Weird ClassCastException

Posted by Sean Schofield <se...@gmail.com>.
One other thing.  I believe we should change the suite() method in
AbstractJsfTestCase to return new TestSuite().

I had an abstract test class of my own that extended
AbstractJsfTestCase but I didn't have the suite method thinking - hey
this is abstract anyways so what is there to test.  Well maven2 threw
an assertion error that there were no test methods in the class.  I
only had this with maven2.  When running in the IDE - no problems.

I believe Shale will have the same problem when it eventually switches
to maven2 for the build.  An empty TestSuite seems to do the trick
though.

Sean

On 2/18/06, Craig McClanahan <cr...@apache.org> wrote:
> On 2/18/06, Sean Schofield <se...@gmail.com> wrote:
> >
> > I believe the problem I was not running the entire test suite of
> > myfaces tests in my IDE.  When I ran them in Maven, I believe an
> > earlier test was calling the get method for the RenderKitFactory and
> > therefore loading the default one into memory.  Apparently you are not
> > allowed to set a new one (as the setup in the AbstractJsfTestCase
> > attempts to do) once the getter is called.
> >
> > I changed the struts code to releaseFactories() in the setup method to
> > ensure you are able to set the factories as anticipated.
>
>
> +1.
>
> That's also something that might make sense as an application shuts down, in
> order to prevent potential memory leaks.  I'll take a look at that.
>
> Sean
> >
> > ps. Nice work on this test stuff.  I think we are going to convert all
> > of the MyFaces tests to use it!
>
>
> Cool!  I'm glad it's helpful.
>
> Craig
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Weird ClassCastException

Posted by Craig McClanahan <cr...@apache.org>.
On 2/18/06, Sean Schofield <se...@gmail.com> wrote:
>
> I believe the problem I was not running the entire test suite of
> myfaces tests in my IDE.  When I ran them in Maven, I believe an
> earlier test was calling the get method for the RenderKitFactory and
> therefore loading the default one into memory.  Apparently you are not
> allowed to set a new one (as the setup in the AbstractJsfTestCase
> attempts to do) once the getter is called.
>
> I changed the struts code to releaseFactories() in the setup method to
> ensure you are able to set the factories as anticipated.


+1.

That's also something that might make sense as an application shuts down, in
order to prevent potential memory leaks.  I'll take a look at that.

Sean
>
> ps. Nice work on this test stuff.  I think we are going to convert all
> of the MyFaces tests to use it!


Cool!  I'm glad it's helpful.

Craig

Re: Weird ClassCastException

Posted by Sean Schofield <se...@gmail.com>.
I believe the problem I was not running the entire test suite of
myfaces tests in my IDE.  When I ran them in Maven, I believe an
earlier test was calling the get method for the RenderKitFactory and
therefore loading the default one into memory.  Apparently you are not
allowed to set a new one (as the setup in the AbstractJsfTestCase
attempts to do) once the getter is called.

I changed the struts code to releaseFactories() in the setup method to
ensure you are able to set the factories as anticipated.

Sean

ps. Nice work on this test stuff.  I think we are going to convert all
of the MyFaces tests to use it!


On 2/17/06, Sean Schofield <se...@gmail.com> wrote:
> Yeah I was thinking that maven is relying on the jars and since there
> is a config file in there the myfaces render kit is getting loaded
> instead.
>
> I will check into it.  Thanks.
>
> Sean
>
> On 2/17/06, Craig McClanahan <cr...@apache.org> wrote:
> > On 2/17/06, Sean Schofield <se...@gmail.com> wrote:
> > >
> > > Yeah this is the test.
> >
> >
> > Ah, you meant line 131 of AbstractJsfTestCase :-)
> >
> > The only thing I can think of is maybe somehow the "real" API classes might
> > be getting injected into the classpath somehow.  Maybe you could try
> > temporarily changing the variable type to RenderKit instead of
> > MockRenderKit, and change the assignment to:
> >
> >        renderKit = renderKitFactory.getRenderKit(null,
> > RenderKitFactory.HTML_BASIC_RENDER_KIT);
> >        System.out.println("Renderer type is " + renderKit.getClass
> > ().getClassName());
> >
> > and see if you get the MyFaces implementation?
> >
> > Craig
> >
> >
> >
> > -------------------------------------------------------------------------------
> > > Battery: org.apache.myfaces.custom.tree2.HtmlTreeRendererTest
> > >
> > >
> > -------------------------------------------------------------------------------
> > > Tests run: 2, Failures: 0, Errors: 2, Time elapsed: 0.046 sec
> > >
> > > testHideRootNodeServer(
> > > org.apache.myfaces.custom.tree2.HtmlTreeRendererTest)
> > > Time elapsed: 0.016 sec  <<< ERROR!
> > >
> > > [ stdout ] ---------------------------------------------------------------
> > >
> > >
> > >
> > > [ stderr ] ---------------------------------------------------------------
> > >
> > >
> > >
> > > [ stacktrace ] -----------------------------------------------------------
> > >
> > > java.lang.ClassCastException
> > >         at org.apache.shale.test.base.AbstractJsfTestCase.setUp(
> > > AbstractJsfTestCase.java:131)
> > >         at org.apache.myfaces.custom.tree2.HtmlTreeRendererTest.setUp(
> > > HtmlTreeRendererTest.java:82)
> > >         at junit.framework.TestCase.runBare(TestCase.java:125)
> > >         at junit.framework.TestResult$1.protect(TestResult.java:106)
> > >         at junit.framework.TestResult.runProtected(TestResult.java:124)
> > >         at junit.framework.TestResult.run(TestResult.java:109)
> > >         at junit.framework.TestCase.run(TestCase.java:118)
> > >         at junit.framework.TestSuite.runTest(TestSuite.java:208)
> > >         at junit.framework.TestSuite.run(TestSuite.java:203)
> > >
> > > On 2/17/06, Craig McClanahan <cr...@apache.org> wrote:
> > > > On 2/17/06, Sean Schofield <se...@gmail.com> wrote:
> > > > >
> > > > > I'm attaching my test case.  Its a test for the latest MyFaces trunk
> > > code.
> > > >
> > > >
> > > > Are you sure this is the failing test?  It doesn't seem to have the line
> > > you
> > > > quotes earlier.
> > > >
> > > > Craig
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: dev-help@struts.apache.org
> > >
> > >
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org