You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Mario Ivankovits <ma...@ops.co.at> on 2006/01/15 22:14:41 UTC

test failed

Hi!

Could someone please confirm that the tests against the current svn head
fail?

Currently I try to implement the "commandLink submit script" but after
an "svn update" the following exception occurs during "mvn install".
I cant see any class I changed being involved ... so I am not sure if
its my fault or if the current svn is somewhat unstable.

junit.framework.AssertionFailedError:
  Unexpected method call
getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
    getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
expected: 0, actual: 1
    getValue(null): expected: 1, actual: 0
        at
org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
        at
org.easymock.classextension.MockClassControl$2.intercept(MockClassControl.java:67)
        at
$javax.faces.el.ValueBinding$$EnhancerByCGLIB$$a458a51c.getValue(<generated>)
        at
javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1151)
        at
javax.faces.component.UIComponentBaseTest.testIsRenderedBinding(UIComponentBaseTest.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)

Thanks!
Mario

Re: test failed

Posted by Simon Kitching <sk...@apache.org>.
On Mon, 2006-01-16 at 08:58 +0100, Mario Ivankovits wrote:
> Hi Simon!
> 
> >  Do you perhaps have some other tests you've
> > written which have not been checked in and which might have this
> > side-effect, and which are run before this test?
> >   
> ;-) No I havent written any tests so far.
> 
> But thanks for the hints, now I got it. Its the UISelectManyTest which
> setup a facesContext and didnt reset it in tearDown.

I'm glad you found it.

I bet OS and/or JVM-version affect the order in which the unit tests are
executed (due to Hashtable or reflection behaviour differences), which
is why tests worked for me but failed for you.


> I'll create a AbstractTestCase which
> *) ensures the facesContext is null in startUp()
> *) sets the context to null in tearDown()
> 
> For this I need to to copy the FacesContextHelper from commons to
> myfaces-api, but its a rather small file, so this should be not that a
> problem.
> Now it works as expected. I'll create a JIRA ticket for it.

Great. I'll commit it unless someone beats me to it.

Cheers,

Simon



Re: test failed

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Simon!

>  Do you perhaps have some other tests you've
> written which have not been checked in and which might have this
> side-effect, and which are run before this test?
>   
;-) No I havent written any tests so far.

But thanks for the hints, now I got it. Its the UISelectManyTest which
setup a facesContext and didnt reset it in tearDown.
I'll create a AbstractTestCase which
*) ensures the facesContext is null in startUp()
*) sets the context to null in tearDown()

For this I need to to copy the FacesContextHelper from commons to
myfaces-api, but its a rather small file, so this should be not that a
problem.
Now it works as expected. I'll create a JIRA ticket for it.

Thanks!
Ciao,
Mario


Re: test failed

Posted by Simon Kitching <sk...@apache.org>.
On Mon, 2006-01-16 at 07:55 +0100, Mario Ivankovits wrote:
> Hi!
> > And it works for me too.
> >
> > On Sun, 2006-01-15 at 22:28 +0100, Arvid Hülsebus wrote:
> >   
> >> I just updated the sources and run a 'mvn clean install' and everything
> >> worked out fine. The tests didn't fail.
> All this is odd. I tried it now on another machine and got the same test 
> failure.
> I also tried a completely new checkout.
> 
> But now I know whats the problem is: The mock tests were trained to see 
> a getValue(null) but instead the component issued a 
> getValue(instance-of-mock-context).
> The following patch fixed it for me:
> 
> Index: 
> /home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java
> ===================================================================
> --- 
> /home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java    
> (revision 369368)
> +++ 
> /home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java    
> (working copy)
> @@ -62,7 +62,7 @@
>    public void testIsRenderedBinding() {
>      MockControl bindingControl = 
> MockClassControl.createControl(ValueBinding.class);
>      ValueBinding mockBinding = (ValueBinding)bindingControl.getMock();
> -    mockBinding.getValue(null);
> +    mockBinding.getValue(FacesContext.getCurrentInstance());

Well, the code I've got has
  mockBinding.getValue(null);
and it is definitely working fine.

I tried your patch, and that works too - because
   FacesContext.getCurrentInstance()
is returning null. Putting
  assertNotNull(FacesContext.getCurrentInstance());
in the testIsRenderedBinding method causes test failure.

So clearly for you there is a faces context at this point, while for
myself (and Arvid) there isn't. Weird.

Because the facesContext is in fact a thread-local variable I guess it's
possible that some other test is setting one up, and not clearing it in
the test's teardown method. Do you perhaps have some other tests you've
written which have not been checked in and which might have this
side-effect, and which are run before this test?

Regards,

Simon




Re: test failed

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> And it works for me too.
>
> On Sun, 2006-01-15 at 22:28 +0100, Arvid Hülsebus wrote:
>   
>> I just updated the sources and run a 'mvn clean install' and everything
>> worked out fine. The tests didn't fail.
All this is odd. I tried it now on another machine and got the same test 
failure.
I also tried a completely new checkout.

But now I know whats the problem is: The mock tests were trained to see 
a getValue(null) but instead the component issued a 
getValue(instance-of-mock-context).
The following patch fixed it for me:

Index: 
/home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java
===================================================================
--- 
/home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java    
(revision 369368)
+++ 
/home/im/projects/myfaces/api/api/src/test/java/javax/faces/component/UIComponentBaseTest.java    
(working copy)
@@ -62,7 +62,7 @@
   public void testIsRenderedBinding() {
     MockControl bindingControl = 
MockClassControl.createControl(ValueBinding.class);
     ValueBinding mockBinding = (ValueBinding)bindingControl.getMock();
-    mockBinding.getValue(null);
+    mockBinding.getValue(FacesContext.getCurrentInstance());
     bindingControl.setReturnValue(Boolean.FALSE);
     bindingControl.replay();
     mock.setValueBinding("rendered", mockBinding);
@@ -375,7 +375,7 @@
   public void testSetRendererTypeStringBinding() {
     MockControl bindingControl = 
MockClassControl.createControl(ValueBinding.class);
     ValueBinding mockBinding = (ValueBinding)bindingControl.getMock();
-    mockBinding.getValue(null);
+    mockBinding.getValue(FacesContext.getCurrentInstance());
     String whumpy = "Whumpy";
     bindingControl.setReturnValue(whumpy);
     bindingControl.replay();

But why did this work on your machines without this patch?

Ciao,
Mario


Re: test failed

Posted by Simon Kitching <sk...@apache.org>.
And it works for me too.

On Sun, 2006-01-15 at 22:28 +0100, Arvid Hülsebus wrote:
> Hello!
> 
> I just updated the sources and run a 'mvn clean install' and everything
> worked out fine. The tests didn't fail. Did you try a clean? Are you
> using Maven 2.0.1?
> 
> Regards,
> Arvid
> 
> Mario Ivankovits wrote:
> > Hi!
> >
> > Could someone please confirm that the tests against the current svn head
> > fail?
> >
> > Currently I try to implement the "commandLink submit script" but after
> > an "svn update" the following exception occurs during "mvn install".
> > I cant see any class I changed being involved ... so I am not sure if
> > its my fault or if the current svn is somewhat unstable.
> >
> > junit.framework.AssertionFailedError:
> >   Unexpected method call
> > getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
> >     getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
> > expected: 0, actual: 1
> >     getValue(null): expected: 1, actual: 0
> >         at
> > org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
> >         at
> > org.easymock.classextension.MockClassControl$2.intercept(MockClassControl.java:67)
> >         at
> > $javax.faces.el.ValueBinding$$EnhancerByCGLIB$$a458a51c.getValue(<generated>)
> >         at
> > javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1151)
> >         at
> > javax.faces.component.UIComponentBaseTest.testIsRenderedBinding(UIComponentBaseTest.java:69)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:585)
> >         at junit.framework.TestCase.runTest(TestCase.java:154)
> >
> > Thanks!
> > Mario
> >   
> 


Re: test failed

Posted by Arvid Hülsebus <ar...@atanion.com>.
Hello!

I just updated the sources and run a 'mvn clean install' and everything
worked out fine. The tests didn't fail. Did you try a clean? Are you
using Maven 2.0.1?

Regards,
Arvid

Mario Ivankovits wrote:
> Hi!
>
> Could someone please confirm that the tests against the current svn head
> fail?
>
> Currently I try to implement the "commandLink submit script" but after
> an "svn update" the following exception occurs during "mvn install".
> I cant see any class I changed being involved ... so I am not sure if
> its my fault or if the current svn is somewhat unstable.
>
> junit.framework.AssertionFailedError:
>   Unexpected method call
> getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
>     getValue(org.apache.myfaces.mock.MockFacesContext@19a8416):
> expected: 0, actual: 1
>     getValue(null): expected: 1, actual: 0
>         at
> org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:44)
>         at
> org.easymock.classextension.MockClassControl$2.intercept(MockClassControl.java:67)
>         at
> $javax.faces.el.ValueBinding$$EnhancerByCGLIB$$a458a51c.getValue(<generated>)
>         at
> javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1151)
>         at
> javax.faces.component.UIComponentBaseTest.testIsRenderedBinding(UIComponentBaseTest.java:69)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at junit.framework.TestCase.runTest(TestCase.java:154)
>
> Thanks!
> Mario
>