You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@deltaspike.apache.org by Lars-Fredrik Smedberg <it...@gmail.com> on 2017/05/04 06:54:44 UTC

Trying mocks using Deltaspike Test Control

Hi

I'm new to using Deltaspike Test Control (1.7.2) and trying to use Mockito
mocks as explained in

http://deltaspike.apache.org/documentation/test-control.html#MockFrameworks

I my META-INF (which is on the classpath when running the tests) I have the
beans.xml and apache-deltaspike.properties that contains

deltaspike.testcontrol.mock-support.allow_mocked_beans=true
deltaspike.testcontrol.mock-support.allow_mocked_producers=true

When calling ...addMock(...) on the injected DynamicMockManager I get the
following error message

java.lang.IllegalStateException: The support for mocked CDI-Beans is
disabled due to a reduced portability across different CDI-implementations.
Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans' and/or
'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true' (in
'META-INF/apache-deltaspike.properties') on your test-classpath.

Running tests using test control without mocks works fine...

Can anyone see what I'm doing wrong or what I'm missing? Probably something
easy!!.... been using Weld JUnit Extensions and CDIUnit before but never
Test Control :(

Regards
LF

-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Trying mocks using Deltaspike Test Control

Posted by Rafael Pestano <rm...@gmail.com>.
Hi,

I've run into the same issue last week where we forgot to include
deltaspike-core-impl in classpath (it was a project which only uses DS for
IT testing).

So +1 for:

"My mistake to not try to add them before but maybe it should be included in
the test control documentation at
http://deltaspike.apache.org/documentation/test-control.html"



2017-05-09 12:22 GMT-03:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Thanks, works fine....
>
> Will try some other use cases we previously used CDIUnit for....
>
> ...will post here if I have some other questions...
>
> Thanks for the help so far
> Regards
> LF
>
> On Tue, May 9, 2017 at 3:37 PM, Gerhard Petracek <
> gerhard.petracek@gmail.com
> > wrote:
>
> > hi lars-fredrik,
> >
> > mocking them (without changing the overall behavior or creating a leak or
> > risking side-effects) isn't that easy.
> > -> if you need to mock them, please use @Specializes for your (manual)
> > mock-instance in the test-classpath (which extends the original bean).
> >
> > regards,
> > gerhard
> >
> > http://www.irian.at
> >
> > Your JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache
> > MyFaces, DeltaSpike and OpenWebBeans
> >
> >
> >
> > 2017-05-09 9:28 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> >
> > > Hi Gerhard et al
> > >
> > > I got it to work, the problem I had with the following output:
> > >
> > > java.lang.IllegalStateException: The support for mocked CDI-Beans is
> > > disabled due to a reduced portability across different
> > CDI-implementations.
> > > Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans'
> > and/or
> > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true'
> > (in
> > > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> > >
> > > ...was since I didn't include the following dependencies
> > >
> > >         <dependency>
> > >             <groupId>org.apache.deltaspike.core</groupId>
> > >             <artifactId>deltaspike-core-api</artifactId>
> > >             <version>1.7.2</version>
> > >         </dependency>
> > >         <dependency>
> > >             <groupId>org.apache.deltaspike.core</groupId>
> > >             <artifactId>deltaspike-core-impl</artifactId>
> > >             <version>1.7.2</version>
> > >             <scope>runtime</scope>
> > >         </dependency>
> > >
> > > My mistake to not try to add them before but maybe it should be
> included
> > in
> > > the test control documentation at
> > > http://deltaspike.apache.org/documentation/test-control.html since it
> > > already mentions all other dependencies needed.
> > >
> > > Also I had some problem mocking @Dependent CDI beans (@RequestScoped
> > works
> > > fine though)... can that be done? I get an error that looks like this:
> > >
> > > java.lang.IllegalArgumentException:
> > > shb.test.ADependentTestClass$$EnhancerByMockitoWithCGLIB$$9502ee22
> > isn't a
> > > supported approach for mocking -> please extend from the original
> class.
> > >
> > > Regards
> > > LF
> > >
> > >
> > >
> > > On Thu, May 4, 2017 at 11:41 PM, Gerhard Petracek <
> > > gerhard.petracek@gmail.com> wrote:
> > >
> > > > hi lars-fredrik,
> > > >
> > > > i've pushed an example -> please have a look at [1].
> > > >
> > > > regards,
> > > > gerhard
> > > >
> > > > [1]
> > > > https://github.com/os890/javase-cdi-ds-project-template/
> > > > commit/64ada0a4b48ebb71547d4bdaf56d833628dd9edd
> > > >
> > > >
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JavaEE powerhouse -
> > > > JavaEE Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache
> > > > MyFaces, DeltaSpike and OpenWebBeans
> > > >
> > > > 2017-05-04 10:25 GMT+02:00 Lars-Fredrik Smedberg <itsmeden@gmail.com
> >:
> > > >
> > > > > Hi
> > > > >
> > > > > Thanks for the pointer... cannot see any difference though
> > > > >
> > > > > I also tried to print the class path (to be sure)
> > > > > using  System.out.println(System.getProperty("java.class.path"));
> > and
> > > > also
> > > > > trying to load the apache-deltaspike.properties file, using
> > > > > ...ClassLoader.getSystemResourceAsStream("
> > META-INF/apache-deltaspike.
> > > > > properties");
> > > > > and its on the classpath...
> > > > >
> > > > > Can I debug it somehow? It's probably some easy error I cannot see
> at
> > > the
> > > > > moment
> > > > >
> > > > > Regards
> > > > > LF
> > > > >
> > > > > On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <
> > > > > gerhard.petracek@gmail.com
> > > > > > wrote:
> > > > >
> > > > > > hi lars-fredrik,
> > > > > >
> > > > > > please compare your usage e.g. with [1].
> > > > > >
> > > > > > regards,
> > > > > > gerhard
> > > > > >
> > > > > > [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
> > > > > >
> > > > > >
> > > > > >
> > > > > > http://www.irian.at
> > > > > >
> > > > > > Your JavaEE powerhouse -
> > > > > > JavaEE Consulting, Development and
> > > > > > Courses in English and German
> > > > > >
> > > > > > Professional Support for Apache
> > > > > > MyFaces, DeltaSpike and OpenWebBeans
> > > > > >
> > > > > > 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <
> > itsmeden@gmail.com
> > > >:
> > > > > >
> > > > > > > Hi
> > > > > > >
> > > > > > > I'm new to using Deltaspike Test Control (1.7.2) and trying to
> > use
> > > > > > Mockito
> > > > > > > mocks as explained in
> > > > > > >
> > > > > > > http://deltaspike.apache.org/documentation/test-control.
> > > > > > > html#MockFrameworks
> > > > > > >
> > > > > > > I my META-INF (which is on the classpath when running the
> tests)
> > I
> > > > have
> > > > > > the
> > > > > > > beans.xml and apache-deltaspike.properties that contains
> > > > > > >
> > > > > > > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > > > > > > deltaspike.testcontrol.mock-support.allow_mocked_
> producers=true
> > > > > > >
> > > > > > > When calling ...addMock(...) on the injected
> DynamicMockManager I
> > > get
> > > > > the
> > > > > > > following error message
> > > > > > >
> > > > > > > java.lang.IllegalStateException: The support for mocked
> > CDI-Beans
> > > is
> > > > > > > disabled due to a reduced portability across different
> > > > > > CDI-implementations.
> > > > > > > Please set 'deltaspike.testcontrol.mock-
> > > support.allow_mocked_beans'
> > > > > > and/or
> > > > > > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers'
> to
> > > > 'true'
> > > > > > (in
> > > > > > > 'META-INF/apache-deltaspike.properties') on your
> test-classpath.
> > > > > > >
> > > > > > > Running tests using test control without mocks works fine...
> > > > > > >
> > > > > > > Can anyone see what I'm doing wrong or what I'm missing?
> Probably
> > > > > > something
> > > > > > > easy!!.... been using Weld JUnit Extensions and CDIUnit before
> > but
> > > > > never
> > > > > > > Test Control :(
> > > > > > >
> > > > > > > Regards
> > > > > > > LF
> > > > > > >
> > > > > > > --
> > > > > > > Med vänlig hälsning / Best regards
> > > > > > >
> > > > > > > Lars-Fredrik Smedberg
> > > > > > >
> > > > > > > STATEMENT OF CONFIDENTIALITY:
> > > > > > > The information contained in this electronic message and any
> > > > > > > attachments to this message are intended for the exclusive use
> of
> > > the
> > > > > > > address(es) and may contain confidential or privileged
> > information.
> > > > If
> > > > > > > you are not the intended recipient, please notify Lars-Fredrik
> > > > Smedberg
> > > > > > > immediately at itsmeden@gmail.com, and destroy all copies of
> > this
> > > > > > > message and any attachments.
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Med vänlig hälsning / Best regards
> > > > >
> > > > > Lars-Fredrik Smedberg
> > > > >
> > > > > STATEMENT OF CONFIDENTIALITY:
> > > > > The information contained in this electronic message and any
> > > > > attachments to this message are intended for the exclusive use of
> the
> > > > > address(es) and may contain confidential or privileged information.
> > If
> > > > > you are not the intended recipient, please notify Lars-Fredrik
> > Smedberg
> > > > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > > > message and any attachments.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Med vänlig hälsning / Best regards
> > >
> > > Lars-Fredrik Smedberg
> > >
> > > STATEMENT OF CONFIDENTIALITY:
> > > The information contained in this electronic message and any
> > > attachments to this message are intended for the exclusive use of the
> > > address(es) and may contain confidential or privileged information. If
> > > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > message and any attachments.
> > >
> >
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>



-- 
Att,

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
http://rpestano.wordpress.com/
@realpestano

Re: Trying mocks using Deltaspike Test Control

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
Thanks, works fine....

Will try some other use cases we previously used CDIUnit for....

...will post here if I have some other questions...

Thanks for the help so far
Regards
LF

On Tue, May 9, 2017 at 3:37 PM, Gerhard Petracek <gerhard.petracek@gmail.com
> wrote:

> hi lars-fredrik,
>
> mocking them (without changing the overall behavior or creating a leak or
> risking side-effects) isn't that easy.
> -> if you need to mock them, please use @Specializes for your (manual)
> mock-instance in the test-classpath (which extends the original bean).
>
> regards,
> gerhard
>
> http://www.irian.at
>
> Your JavaEE powerhouse -
> JavaEE Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache
> MyFaces, DeltaSpike and OpenWebBeans
>
>
>
> 2017-05-09 9:28 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>
> > Hi Gerhard et al
> >
> > I got it to work, the problem I had with the following output:
> >
> > java.lang.IllegalStateException: The support for mocked CDI-Beans is
> > disabled due to a reduced portability across different
> CDI-implementations.
> > Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans'
> and/or
> > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true'
> (in
> > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> >
> > ...was since I didn't include the following dependencies
> >
> >         <dependency>
> >             <groupId>org.apache.deltaspike.core</groupId>
> >             <artifactId>deltaspike-core-api</artifactId>
> >             <version>1.7.2</version>
> >         </dependency>
> >         <dependency>
> >             <groupId>org.apache.deltaspike.core</groupId>
> >             <artifactId>deltaspike-core-impl</artifactId>
> >             <version>1.7.2</version>
> >             <scope>runtime</scope>
> >         </dependency>
> >
> > My mistake to not try to add them before but maybe it should be included
> in
> > the test control documentation at
> > http://deltaspike.apache.org/documentation/test-control.html since it
> > already mentions all other dependencies needed.
> >
> > Also I had some problem mocking @Dependent CDI beans (@RequestScoped
> works
> > fine though)... can that be done? I get an error that looks like this:
> >
> > java.lang.IllegalArgumentException:
> > shb.test.ADependentTestClass$$EnhancerByMockitoWithCGLIB$$9502ee22
> isn't a
> > supported approach for mocking -> please extend from the original class.
> >
> > Regards
> > LF
> >
> >
> >
> > On Thu, May 4, 2017 at 11:41 PM, Gerhard Petracek <
> > gerhard.petracek@gmail.com> wrote:
> >
> > > hi lars-fredrik,
> > >
> > > i've pushed an example -> please have a look at [1].
> > >
> > > regards,
> > > gerhard
> > >
> > > [1]
> > > https://github.com/os890/javase-cdi-ds-project-template/
> > > commit/64ada0a4b48ebb71547d4bdaf56d833628dd9edd
> > >
> > >
> > >
> > > http://www.irian.at
> > >
> > > Your JavaEE powerhouse -
> > > JavaEE Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache
> > > MyFaces, DeltaSpike and OpenWebBeans
> > >
> > > 2017-05-04 10:25 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> > >
> > > > Hi
> > > >
> > > > Thanks for the pointer... cannot see any difference though
> > > >
> > > > I also tried to print the class path (to be sure)
> > > > using  System.out.println(System.getProperty("java.class.path"));
> and
> > > also
> > > > trying to load the apache-deltaspike.properties file, using
> > > > ...ClassLoader.getSystemResourceAsStream("
> META-INF/apache-deltaspike.
> > > > properties");
> > > > and its on the classpath...
> > > >
> > > > Can I debug it somehow? It's probably some easy error I cannot see at
> > the
> > > > moment
> > > >
> > > > Regards
> > > > LF
> > > >
> > > > On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <
> > > > gerhard.petracek@gmail.com
> > > > > wrote:
> > > >
> > > > > hi lars-fredrik,
> > > > >
> > > > > please compare your usage e.g. with [1].
> > > > >
> > > > > regards,
> > > > > gerhard
> > > > >
> > > > > [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
> > > > >
> > > > >
> > > > >
> > > > > http://www.irian.at
> > > > >
> > > > > Your JavaEE powerhouse -
> > > > > JavaEE Consulting, Development and
> > > > > Courses in English and German
> > > > >
> > > > > Professional Support for Apache
> > > > > MyFaces, DeltaSpike and OpenWebBeans
> > > > >
> > > > > 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <
> itsmeden@gmail.com
> > >:
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > I'm new to using Deltaspike Test Control (1.7.2) and trying to
> use
> > > > > Mockito
> > > > > > mocks as explained in
> > > > > >
> > > > > > http://deltaspike.apache.org/documentation/test-control.
> > > > > > html#MockFrameworks
> > > > > >
> > > > > > I my META-INF (which is on the classpath when running the tests)
> I
> > > have
> > > > > the
> > > > > > beans.xml and apache-deltaspike.properties that contains
> > > > > >
> > > > > > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > > > > > deltaspike.testcontrol.mock-support.allow_mocked_producers=true
> > > > > >
> > > > > > When calling ...addMock(...) on the injected DynamicMockManager I
> > get
> > > > the
> > > > > > following error message
> > > > > >
> > > > > > java.lang.IllegalStateException: The support for mocked
> CDI-Beans
> > is
> > > > > > disabled due to a reduced portability across different
> > > > > CDI-implementations.
> > > > > > Please set 'deltaspike.testcontrol.mock-
> > support.allow_mocked_beans'
> > > > > and/or
> > > > > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to
> > > 'true'
> > > > > (in
> > > > > > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> > > > > >
> > > > > > Running tests using test control without mocks works fine...
> > > > > >
> > > > > > Can anyone see what I'm doing wrong or what I'm missing? Probably
> > > > > something
> > > > > > easy!!.... been using Weld JUnit Extensions and CDIUnit before
> but
> > > > never
> > > > > > Test Control :(
> > > > > >
> > > > > > Regards
> > > > > > LF
> > > > > >
> > > > > > --
> > > > > > Med vänlig hälsning / Best regards
> > > > > >
> > > > > > Lars-Fredrik Smedberg
> > > > > >
> > > > > > STATEMENT OF CONFIDENTIALITY:
> > > > > > The information contained in this electronic message and any
> > > > > > attachments to this message are intended for the exclusive use of
> > the
> > > > > > address(es) and may contain confidential or privileged
> information.
> > > If
> > > > > > you are not the intended recipient, please notify Lars-Fredrik
> > > Smedberg
> > > > > > immediately at itsmeden@gmail.com, and destroy all copies of
> this
> > > > > > message and any attachments.
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Med vänlig hälsning / Best regards
> > > >
> > > > Lars-Fredrik Smedberg
> > > >
> > > > STATEMENT OF CONFIDENTIALITY:
> > > > The information contained in this electronic message and any
> > > > attachments to this message are intended for the exclusive use of the
> > > > address(es) and may contain confidential or privileged information.
> If
> > > > you are not the intended recipient, please notify Lars-Fredrik
> Smedberg
> > > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > > message and any attachments.
> > > >
> > >
> >
> >
> >
> > --
> > Med vänlig hälsning / Best regards
> >
> > Lars-Fredrik Smedberg
> >
> > STATEMENT OF CONFIDENTIALITY:
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > address(es) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > immediately at itsmeden@gmail.com, and destroy all copies of this
> > message and any attachments.
> >
>



-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Trying mocks using Deltaspike Test Control

Posted by Gerhard Petracek <ge...@gmail.com>.
hi lars-fredrik,

mocking them (without changing the overall behavior or creating a leak or
risking side-effects) isn't that easy.
-> if you need to mock them, please use @Specializes for your (manual)
mock-instance in the test-classpath (which extends the original bean).

regards,
gerhard

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans



2017-05-09 9:28 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Hi Gerhard et al
>
> I got it to work, the problem I had with the following output:
>
> java.lang.IllegalStateException: The support for mocked CDI-Beans is
> disabled due to a reduced portability across different CDI-implementations.
> Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans' and/or
> 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true' (in
> 'META-INF/apache-deltaspike.properties') on your test-classpath.
>
> ...was since I didn't include the following dependencies
>
>         <dependency>
>             <groupId>org.apache.deltaspike.core</groupId>
>             <artifactId>deltaspike-core-api</artifactId>
>             <version>1.7.2</version>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.deltaspike.core</groupId>
>             <artifactId>deltaspike-core-impl</artifactId>
>             <version>1.7.2</version>
>             <scope>runtime</scope>
>         </dependency>
>
> My mistake to not try to add them before but maybe it should be included in
> the test control documentation at
> http://deltaspike.apache.org/documentation/test-control.html since it
> already mentions all other dependencies needed.
>
> Also I had some problem mocking @Dependent CDI beans (@RequestScoped works
> fine though)... can that be done? I get an error that looks like this:
>
> java.lang.IllegalArgumentException:
> shb.test.ADependentTestClass$$EnhancerByMockitoWithCGLIB$$9502ee22 isn't a
> supported approach for mocking -> please extend from the original class.
>
> Regards
> LF
>
>
>
> On Thu, May 4, 2017 at 11:41 PM, Gerhard Petracek <
> gerhard.petracek@gmail.com> wrote:
>
> > hi lars-fredrik,
> >
> > i've pushed an example -> please have a look at [1].
> >
> > regards,
> > gerhard
> >
> > [1]
> > https://github.com/os890/javase-cdi-ds-project-template/
> > commit/64ada0a4b48ebb71547d4bdaf56d833628dd9edd
> >
> >
> >
> > http://www.irian.at
> >
> > Your JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache
> > MyFaces, DeltaSpike and OpenWebBeans
> >
> > 2017-05-04 10:25 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> >
> > > Hi
> > >
> > > Thanks for the pointer... cannot see any difference though
> > >
> > > I also tried to print the class path (to be sure)
> > > using  System.out.println(System.getProperty("java.class.path")); and
> > also
> > > trying to load the apache-deltaspike.properties file, using
> > > ...ClassLoader.getSystemResourceAsStream("META-INF/apache-deltaspike.
> > > properties");
> > > and its on the classpath...
> > >
> > > Can I debug it somehow? It's probably some easy error I cannot see at
> the
> > > moment
> > >
> > > Regards
> > > LF
> > >
> > > On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <
> > > gerhard.petracek@gmail.com
> > > > wrote:
> > >
> > > > hi lars-fredrik,
> > > >
> > > > please compare your usage e.g. with [1].
> > > >
> > > > regards,
> > > > gerhard
> > > >
> > > > [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
> > > >
> > > >
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JavaEE powerhouse -
> > > > JavaEE Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache
> > > > MyFaces, DeltaSpike and OpenWebBeans
> > > >
> > > > 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <itsmeden@gmail.com
> >:
> > > >
> > > > > Hi
> > > > >
> > > > > I'm new to using Deltaspike Test Control (1.7.2) and trying to use
> > > > Mockito
> > > > > mocks as explained in
> > > > >
> > > > > http://deltaspike.apache.org/documentation/test-control.
> > > > > html#MockFrameworks
> > > > >
> > > > > I my META-INF (which is on the classpath when running the tests) I
> > have
> > > > the
> > > > > beans.xml and apache-deltaspike.properties that contains
> > > > >
> > > > > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > > > > deltaspike.testcontrol.mock-support.allow_mocked_producers=true
> > > > >
> > > > > When calling ...addMock(...) on the injected DynamicMockManager I
> get
> > > the
> > > > > following error message
> > > > >
> > > > > java.lang.IllegalStateException: The support for mocked CDI-Beans
> is
> > > > > disabled due to a reduced portability across different
> > > > CDI-implementations.
> > > > > Please set 'deltaspike.testcontrol.mock-
> support.allow_mocked_beans'
> > > > and/or
> > > > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to
> > 'true'
> > > > (in
> > > > > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> > > > >
> > > > > Running tests using test control without mocks works fine...
> > > > >
> > > > > Can anyone see what I'm doing wrong or what I'm missing? Probably
> > > > something
> > > > > easy!!.... been using Weld JUnit Extensions and CDIUnit before but
> > > never
> > > > > Test Control :(
> > > > >
> > > > > Regards
> > > > > LF
> > > > >
> > > > > --
> > > > > Med vänlig hälsning / Best regards
> > > > >
> > > > > Lars-Fredrik Smedberg
> > > > >
> > > > > STATEMENT OF CONFIDENTIALITY:
> > > > > The information contained in this electronic message and any
> > > > > attachments to this message are intended for the exclusive use of
> the
> > > > > address(es) and may contain confidential or privileged information.
> > If
> > > > > you are not the intended recipient, please notify Lars-Fredrik
> > Smedberg
> > > > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > > > message and any attachments.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Med vänlig hälsning / Best regards
> > >
> > > Lars-Fredrik Smedberg
> > >
> > > STATEMENT OF CONFIDENTIALITY:
> > > The information contained in this electronic message and any
> > > attachments to this message are intended for the exclusive use of the
> > > address(es) and may contain confidential or privileged information. If
> > > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > message and any attachments.
> > >
> >
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>

Re: Trying mocks using Deltaspike Test Control

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
Hi Gerhard et al

I got it to work, the problem I had with the following output:

java.lang.IllegalStateException: The support for mocked CDI-Beans is
disabled due to a reduced portability across different CDI-implementations.
Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans' and/or
'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true' (in
'META-INF/apache-deltaspike.properties') on your test-classpath.

...was since I didn't include the following dependencies

        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-api</artifactId>
            <version>1.7.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-impl</artifactId>
            <version>1.7.2</version>
            <scope>runtime</scope>
        </dependency>

My mistake to not try to add them before but maybe it should be included in
the test control documentation at
http://deltaspike.apache.org/documentation/test-control.html since it
already mentions all other dependencies needed.

Also I had some problem mocking @Dependent CDI beans (@RequestScoped works
fine though)... can that be done? I get an error that looks like this:

java.lang.IllegalArgumentException:
shb.test.ADependentTestClass$$EnhancerByMockitoWithCGLIB$$9502ee22 isn't a
supported approach for mocking -> please extend from the original class.

Regards
LF



On Thu, May 4, 2017 at 11:41 PM, Gerhard Petracek <
gerhard.petracek@gmail.com> wrote:

> hi lars-fredrik,
>
> i've pushed an example -> please have a look at [1].
>
> regards,
> gerhard
>
> [1]
> https://github.com/os890/javase-cdi-ds-project-template/
> commit/64ada0a4b48ebb71547d4bdaf56d833628dd9edd
>
>
>
> http://www.irian.at
>
> Your JavaEE powerhouse -
> JavaEE Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache
> MyFaces, DeltaSpike and OpenWebBeans
>
> 2017-05-04 10:25 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>
> > Hi
> >
> > Thanks for the pointer... cannot see any difference though
> >
> > I also tried to print the class path (to be sure)
> > using  System.out.println(System.getProperty("java.class.path")); and
> also
> > trying to load the apache-deltaspike.properties file, using
> > ...ClassLoader.getSystemResourceAsStream("META-INF/apache-deltaspike.
> > properties");
> > and its on the classpath...
> >
> > Can I debug it somehow? It's probably some easy error I cannot see at the
> > moment
> >
> > Regards
> > LF
> >
> > On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <
> > gerhard.petracek@gmail.com
> > > wrote:
> >
> > > hi lars-fredrik,
> > >
> > > please compare your usage e.g. with [1].
> > >
> > > regards,
> > > gerhard
> > >
> > > [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
> > >
> > >
> > >
> > > http://www.irian.at
> > >
> > > Your JavaEE powerhouse -
> > > JavaEE Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache
> > > MyFaces, DeltaSpike and OpenWebBeans
> > >
> > > 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> > >
> > > > Hi
> > > >
> > > > I'm new to using Deltaspike Test Control (1.7.2) and trying to use
> > > Mockito
> > > > mocks as explained in
> > > >
> > > > http://deltaspike.apache.org/documentation/test-control.
> > > > html#MockFrameworks
> > > >
> > > > I my META-INF (which is on the classpath when running the tests) I
> have
> > > the
> > > > beans.xml and apache-deltaspike.properties that contains
> > > >
> > > > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > > > deltaspike.testcontrol.mock-support.allow_mocked_producers=true
> > > >
> > > > When calling ...addMock(...) on the injected DynamicMockManager I get
> > the
> > > > following error message
> > > >
> > > > java.lang.IllegalStateException: The support for mocked CDI-Beans is
> > > > disabled due to a reduced portability across different
> > > CDI-implementations.
> > > > Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans'
> > > and/or
> > > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to
> 'true'
> > > (in
> > > > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> > > >
> > > > Running tests using test control without mocks works fine...
> > > >
> > > > Can anyone see what I'm doing wrong or what I'm missing? Probably
> > > something
> > > > easy!!.... been using Weld JUnit Extensions and CDIUnit before but
> > never
> > > > Test Control :(
> > > >
> > > > Regards
> > > > LF
> > > >
> > > > --
> > > > Med vänlig hälsning / Best regards
> > > >
> > > > Lars-Fredrik Smedberg
> > > >
> > > > STATEMENT OF CONFIDENTIALITY:
> > > > The information contained in this electronic message and any
> > > > attachments to this message are intended for the exclusive use of the
> > > > address(es) and may contain confidential or privileged information.
> If
> > > > you are not the intended recipient, please notify Lars-Fredrik
> Smedberg
> > > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > > message and any attachments.
> > > >
> > >
> >
> >
> >
> > --
> > Med vänlig hälsning / Best regards
> >
> > Lars-Fredrik Smedberg
> >
> > STATEMENT OF CONFIDENTIALITY:
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > address(es) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > immediately at itsmeden@gmail.com, and destroy all copies of this
> > message and any attachments.
> >
>



-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Trying mocks using Deltaspike Test Control

Posted by Gerhard Petracek <ge...@gmail.com>.
hi lars-fredrik,

i've pushed an example -> please have a look at [1].

regards,
gerhard

[1]
https://github.com/os890/javase-cdi-ds-project-template/commit/64ada0a4b48ebb71547d4bdaf56d833628dd9edd



http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans

2017-05-04 10:25 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Hi
>
> Thanks for the pointer... cannot see any difference though
>
> I also tried to print the class path (to be sure)
> using  System.out.println(System.getProperty("java.class.path")); and also
> trying to load the apache-deltaspike.properties file, using
> ...ClassLoader.getSystemResourceAsStream("META-INF/apache-deltaspike.
> properties");
> and its on the classpath...
>
> Can I debug it somehow? It's probably some easy error I cannot see at the
> moment
>
> Regards
> LF
>
> On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <
> gerhard.petracek@gmail.com
> > wrote:
>
> > hi lars-fredrik,
> >
> > please compare your usage e.g. with [1].
> >
> > regards,
> > gerhard
> >
> > [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
> >
> >
> >
> > http://www.irian.at
> >
> > Your JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache
> > MyFaces, DeltaSpike and OpenWebBeans
> >
> > 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
> >
> > > Hi
> > >
> > > I'm new to using Deltaspike Test Control (1.7.2) and trying to use
> > Mockito
> > > mocks as explained in
> > >
> > > http://deltaspike.apache.org/documentation/test-control.
> > > html#MockFrameworks
> > >
> > > I my META-INF (which is on the classpath when running the tests) I have
> > the
> > > beans.xml and apache-deltaspike.properties that contains
> > >
> > > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > > deltaspike.testcontrol.mock-support.allow_mocked_producers=true
> > >
> > > When calling ...addMock(...) on the injected DynamicMockManager I get
> the
> > > following error message
> > >
> > > java.lang.IllegalStateException: The support for mocked CDI-Beans is
> > > disabled due to a reduced portability across different
> > CDI-implementations.
> > > Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans'
> > and/or
> > > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true'
> > (in
> > > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> > >
> > > Running tests using test control without mocks works fine...
> > >
> > > Can anyone see what I'm doing wrong or what I'm missing? Probably
> > something
> > > easy!!.... been using Weld JUnit Extensions and CDIUnit before but
> never
> > > Test Control :(
> > >
> > > Regards
> > > LF
> > >
> > > --
> > > Med vänlig hälsning / Best regards
> > >
> > > Lars-Fredrik Smedberg
> > >
> > > STATEMENT OF CONFIDENTIALITY:
> > > The information contained in this electronic message and any
> > > attachments to this message are intended for the exclusive use of the
> > > address(es) and may contain confidential or privileged information. If
> > > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > > immediately at itsmeden@gmail.com, and destroy all copies of this
> > > message and any attachments.
> > >
> >
>
>
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>

Re: Trying mocks using Deltaspike Test Control

Posted by Lars-Fredrik Smedberg <it...@gmail.com>.
Hi

Thanks for the pointer... cannot see any difference though

I also tried to print the class path (to be sure)
using  System.out.println(System.getProperty("java.class.path")); and also
trying to load the apache-deltaspike.properties file, using
...ClassLoader.getSystemResourceAsStream("META-INF/apache-deltaspike.properties");
and its on the classpath...

Can I debug it somehow? It's probably some easy error I cannot see at the
moment

Regards
LF

On Thu, May 4, 2017 at 9:44 AM, Gerhard Petracek <gerhard.petracek@gmail.com
> wrote:

> hi lars-fredrik,
>
> please compare your usage e.g. with [1].
>
> regards,
> gerhard
>
> [1} https://github.com/os890/ee6-ds-demo/tree/master/src/test
>
>
>
> http://www.irian.at
>
> Your JavaEE powerhouse -
> JavaEE Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache
> MyFaces, DeltaSpike and OpenWebBeans
>
> 2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:
>
> > Hi
> >
> > I'm new to using Deltaspike Test Control (1.7.2) and trying to use
> Mockito
> > mocks as explained in
> >
> > http://deltaspike.apache.org/documentation/test-control.
> > html#MockFrameworks
> >
> > I my META-INF (which is on the classpath when running the tests) I have
> the
> > beans.xml and apache-deltaspike.properties that contains
> >
> > deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> > deltaspike.testcontrol.mock-support.allow_mocked_producers=true
> >
> > When calling ...addMock(...) on the injected DynamicMockManager I get the
> > following error message
> >
> > java.lang.IllegalStateException: The support for mocked CDI-Beans is
> > disabled due to a reduced portability across different
> CDI-implementations.
> > Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans'
> and/or
> > 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true'
> (in
> > 'META-INF/apache-deltaspike.properties') on your test-classpath.
> >
> > Running tests using test control without mocks works fine...
> >
> > Can anyone see what I'm doing wrong or what I'm missing? Probably
> something
> > easy!!.... been using Weld JUnit Extensions and CDIUnit before but never
> > Test Control :(
> >
> > Regards
> > LF
> >
> > --
> > Med vänlig hälsning / Best regards
> >
> > Lars-Fredrik Smedberg
> >
> > STATEMENT OF CONFIDENTIALITY:
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > address(es) and may contain confidential or privileged information. If
> > you are not the intended recipient, please notify Lars-Fredrik Smedberg
> > immediately at itsmeden@gmail.com, and destroy all copies of this
> > message and any attachments.
> >
>



-- 
Med vänlig hälsning / Best regards

Lars-Fredrik Smedberg

STATEMENT OF CONFIDENTIALITY:
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
address(es) and may contain confidential or privileged information. If
you are not the intended recipient, please notify Lars-Fredrik Smedberg
immediately at itsmeden@gmail.com, and destroy all copies of this
message and any attachments.

Re: Trying mocks using Deltaspike Test Control

Posted by Gerhard Petracek <ge...@gmail.com>.
hi lars-fredrik,

please compare your usage e.g. with [1].

regards,
gerhard

[1} https://github.com/os890/ee6-ds-demo/tree/master/src/test



http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans

2017-05-04 8:54 GMT+02:00 Lars-Fredrik Smedberg <it...@gmail.com>:

> Hi
>
> I'm new to using Deltaspike Test Control (1.7.2) and trying to use Mockito
> mocks as explained in
>
> http://deltaspike.apache.org/documentation/test-control.
> html#MockFrameworks
>
> I my META-INF (which is on the classpath when running the tests) I have the
> beans.xml and apache-deltaspike.properties that contains
>
> deltaspike.testcontrol.mock-support.allow_mocked_beans=true
> deltaspike.testcontrol.mock-support.allow_mocked_producers=true
>
> When calling ...addMock(...) on the injected DynamicMockManager I get the
> following error message
>
> java.lang.IllegalStateException: The support for mocked CDI-Beans is
> disabled due to a reduced portability across different CDI-implementations.
> Please set 'deltaspike.testcontrol.mock-support.allow_mocked_beans' and/or
> 'deltaspike.testcontrol.mock-support.allow_mocked_producers' to 'true' (in
> 'META-INF/apache-deltaspike.properties') on your test-classpath.
>
> Running tests using test control without mocks works fine...
>
> Can anyone see what I'm doing wrong or what I'm missing? Probably something
> easy!!.... been using Weld JUnit Extensions and CDIUnit before but never
> Test Control :(
>
> Regards
> LF
>
> --
> Med vänlig hälsning / Best regards
>
> Lars-Fredrik Smedberg
>
> STATEMENT OF CONFIDENTIALITY:
> The information contained in this electronic message and any
> attachments to this message are intended for the exclusive use of the
> address(es) and may contain confidential or privileged information. If
> you are not the intended recipient, please notify Lars-Fredrik Smedberg
> immediately at itsmeden@gmail.com, and destroy all copies of this
> message and any attachments.
>