deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Re: Boot External Containers in TestNg Tests
Date Mon, 04 Jul 2016 14:06:09 GMT

Hello Gerhard,

thanks a lot for your very fast answer.

I tried to setup the JSF container manually. I had a look into the source
code of CdiTestRunner and "copied" the specific code lines into my test
class. It looks like this:

final List<ExternalContainer> configuredExternalContainers=
for (final ExternalContainer externalContainer :
configuredExternalContainers) {
        final ExternalContainer externalContainerBean =
BeanProvider.getContextualReference(externalContainer.getClass(), true);

Unfortunately I cannot get it to work properly. The main problem is that a
lot of NoClassDefFound errors appear, because of missing
MyFaces-dependencies. After adding the whole MyFaces implementation I
stopped this approach. I do not want to have such a dependency overload in
my testing phase. Especially not because I am not really sure which version
I have to choose because the MyFaces dependecies are bundled in my
application server at runtime.

So I switched back to another approach. And there is another question
regarding deltaspike testing.

The only problem I have in my tests is the following line of code:
        final HttpSession session = (HttpSession) fCtx.getExternalContext
and this is located in a @PostConstruct method of a @WindowScoped bean.

So the only thing I have to do is to create a simple mock object for the
FacesContext. Unfortunately in the FacesContext the static methods are to
mock. I want to use PowerMock for that because I already use Mockito. If I
use PowerMock via extending the base test class of PowerMock, no DeltaSpike
test container work. I assume the root cause for that issue is the switch
of the classloader which is done by PowerMock.

Do you have any experience or hint using PowerMock and DeltaSpike together
for tests? Or do you have any other ider how to mock static methods of the
FacesContext with DeltaSpike test containers?

Thanks a lot in advance!

Kind regards,

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser Mail oder von Teilen dieser Mail ist nicht gestattet.

Wir haben alle verkehrsüblichen Maßnahmen unternommen, um das Risiko der
Verbreitung virenbefallener Software oder E-Mails zu minimieren, dennoch
raten wir Ihnen, Ihre eigenen Virenkontrollen auf alle Anhänge an dieser
Nachricht durchzuführen. Wir schließen außer für den Fall von Vorsatz oder
grober Fahrlässigkeit die Haftung für jeglichen Verlust oder Schäden durch
virenbefallene Software oder E-Mails aus.

Jede von der Bank versendete E-Mail ist sorgfältig erstellt worden, dennoch
schließen wir die rechtliche Verbindlichkeit aus; sie kann nicht zu einer
irgendwie gearteten Verpflichtung zu Lasten der Bank ausgelegt werden.

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of  the material in this
e-mail or of parts hereof is strictly forbidden.

We have taken precautions to minimize the risk of transmitting software
viruses but nevertheless advise you to carry out your own virus checks on
any attachment of this message. We accept no liability for loss or damage
caused by software viruses except in case of gross negligence or willful

Any e-mail messages from the Bank are sent in good faith, but shall not be
binding or construed as constituting any kind of obligation on the part of
the Bank.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message