You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Martin Koci <ma...@gmail.com> on 2010/11/01 15:42:48 UTC

[test] testNG and EL impl in myfaces-test

Hi,


two questions:


1) 12 test cases in myfaces-api and myfaces-impl use @Test from
org.testng.annotations, 56 test cases use @org.junit.Test. What is the
primary test engine for myfaces? I'm trying to provide patch for
MYFACES-2882 and UIViewRootTest uses TestNG: how to use
org.apache.myfaces.test.base.junit4.AbstractJsfTestCase there?


2) myfaces-test has mock-implementation of expression language API. Is
it possible to use real EL implementation instead? Problem:
MockExpressionFactory.coerceToType has no Enum support yet; use of very
EL implementation makes tests closer to real usage of myfaces.



Regards,


Kočičák




Re: [test] testNG and EL impl in myfaces-test

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

2010/11/1 Martin Koci <ma...@gmail.com>

> Hi,
>
>
> two questions:
>
>
> 1) 12 test cases in myfaces-api and myfaces-impl use @Test from
> org.testng.annotations, 56 test cases use @org.junit.Test. What is the
> primary test engine for myfaces? I'm trying to provide patch for
> MYFACES-2882 and UIViewRootTest uses TestNG: how to use
> org.apache.myfaces.test.base.junit4.AbstractJsfTestCase there?
>
>
There is no preference for any test framework on myfaces-api, but
myfaces-test
supports only JUnit, so there is no
org.apache.myfaces.test.base.testng.AbstractJsfTestCase.
In fact, it was necessary to make some hacks to make both tests work with
maven
(see myfaces api pom.xml).


>
> 2) myfaces-test has mock-implementation of expression language API. Is
> it possible to use real EL implementation instead? Problem:
> MockExpressionFactory.coerceToType has no Enum support yet; use of very
> EL implementation makes tests closer to real usage of myfaces.
>
>
Yes, it is possible, and this hack is used on myfaces-impl. Look this class:

org.apache.myfaces.view.facelets.tag.ui.IncludeParamTestCase

The relevant code is this:

    @Override
    protected void setUpExternalContext() throws Exception
    {
        externalContext =
            new MockExternalContext(servletContext, request, response);


RuntimeConfig.getCurrentInstance(externalContext).setPropertyResolver(
                new PropertyResolverImpl());

RuntimeConfig.getCurrentInstance(externalContext).setVariableResolver(
                new VariableResolverImpl());
        // For this test we need the a real one, because the Mock does not
        // handle VariableMapper stuff properly and ui:param logic will not
work

RuntimeConfig.getCurrentInstance(externalContext).setExpressionFactory(
                new org.apache.el.ExpressionFactoryImpl());
    }

In this case it was necessary to use myfaces ApplicationImpl, but shows that
it is possible to do it. All you have to do is after setUpApplication() call
setExpressionFactory and assign a real one to MockApplication20 class.

regards,

Leonardo Uribe


>
>
> Regards,
>
>
> Kočičák
>
>
>
>