You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by hwaastad <he...@waastad.org> on 2014/09/02 10:50:26 UTC

"mocking" of abstractentityrepository implementations

Hi,
I'm trying to mock out abstract repositories in different project stages.

I can extend my repository (in test classes) and use alternative/stereotype,
but excluding does not seem to work then.
Is this possible?

br hw




--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by hwaastad <he...@waastad.org>.
HI,
and thanks for answering.

Based on what you mentioned, i made a deactivator an registered it in my
properties so the log shows:

INFO - class:
org.apache.deltaspike.core.impl.scope.DeltaSpikeContextExtension
activated=true
INFO - class:
org.apache.deltaspike.core.impl.exclude.extension.ExcludeExtension
activated=true
INFO - class:
org.apache.deltaspike.core.impl.exclude.CustomProjectStageBeanFilter
activated=true
INFO - class: org.apache.deltaspike.core.impl.exclude.GlobalAlternative
activated=true
INFO - class: org.apache.deltaspike.data.impl.RepositoryExtension
activated=false
INFO - class:
org.apache.deltaspike.partialbean.impl.PartialBeanBindingExtension
activated=true
INFO - class: org.apache.deltaspike.core.impl.config.ConfigurationExtension
activated=true
INFO - class:
org.apache.deltaspike.core.impl.exception.control.extension.ExceptionControlExtension
activated=true
INFO - class: org.apache.deltaspike.core.impl.message.MessageBundleExtension
activated=true
INFO - class:
org.apache.deltaspike.core.impl.message.NamedMessageBundleInvocationHandler
activated=true
INFO - class: org.apache.deltaspike.core.impl.jmx.MBeanExtension
activated=true
INFO - class:
org.apache.deltaspike.jpa.impl.transaction.context.TransactionContextExtension
activated=true

It seems it does not really matter.

A bit more info:

public abstract class TestRepository extends AbstractEntityRepository.....

public abstract class MockTestRepository extends TestRepository

br hw




--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658750.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by "John D. Ament" <jo...@gmail.com>.
Hi

Did you deactivate the RepositoryExtension ?


On Tue, Sep 2, 2014 at 4:50 AM, hwaastad <he...@waastad.org> wrote:

> Hi,
> I'm trying to mock out abstract repositories in different project stages.
>
> I can extend my repository (in test classes) and use
> alternative/stereotype,
> but excluding does not seem to work then.
> Is this possible?
>
> br hw
>
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: "mocking" of abstractentityrepository implementations

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

ejbs are not vetoable btw


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-02 15:10 GMT+02:00 hwaastad <he...@waastad.org>:
> Hi,
> yes it's for testing only.
>
> I'm running openjb embedde (4.7.0) and I can define projectstage in
> container properties.
>
> I've been using @excludes for my SLSB to mock underlying business API's and
> I was hoping to use the same approch with my repositories.
>
> I'll have a look at the partialbindingextension aswell.
>
> br hw
>
>
>
> --
> View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658751.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by hwaastad <he...@waastad.org>.
Hi,
yes it's for testing only.

I'm running openjb embedde (4.7.0) and I can define projectstage in
container properties.

I've been using @excludes for my SLSB to mock underlying business API's and
I was hoping to use the same approch with my repositories.

I'll have a look at the partialbindingextension aswell.

br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658751.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by hwaastad <he...@waastad.org>.
Hi,
always looking out for a better way to build my tests :-)

mocking, well sometimes I just need mock for throwing exceptions and
anomality.

Now, I know arquillian is a powerful framework and I guess you can
dynamically assign alternatives/stereotypes aswell by defining this with a
addasmanifestresource/beans.xml/stringasset.

I guess I just got to roll up my sleaves and do a bit more investigation on
the persistence extension.

I someone has a link or to I would be most greateful :-)
I know Romain wrote something about this in his blog,though.

Well guys,
thanks a lot for feedback.

br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658766.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by Thomas Hug <th...@gmail.com>.
Maybe also have a look at
https://issues.apache.org/jira/browse/DELTASPIKE-588




On Tue, Sep 2, 2014 at 1:24 PM, Thomas Hug <th...@gmail.com> wrote:

> For this case it's probably also the PartialBeanBindingExtension to
> deactivate.
>
> Is this only intended for testing purposes?
>
>
> On Tue, Sep 2, 2014 at 12:42 PM, John D. Ament <jo...@gmail.com>
> wrote:
>
>> Hi
>>
>> Did you deactivate the RepositoryExtension ?
>>
>>
>> On Tue, Sep 2, 2014 at 4:50 AM, hwaastad <he...@waastad.org> wrote:
>>
>> > Hi,
>> > I'm trying to mock out abstract repositories in different project
>> stages.
>> >
>> > I can extend my repository (in test classes) and use
>> > alternative/stereotype,
>> > but excluding does not seem to work then.
>> > Is this possible?
>> >
>> > br hw
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> >
>> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745.html
>> > Sent from the Apache DeltaSpike Incubator Discussions mailing list
>> archive
>> > at Nabble.com.
>> >
>>
>
>

Re: "mocking" of abstractentityrepository implementations

Posted by hwaastad <he...@waastad.org>.
Hi,
and thanks again TH.

I'll begin my quest :-)

br hw



--
View this message in context: http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658777.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at Nabble.com.

Re: "mocking" of abstractentityrepository implementations

Posted by Thomas Hug <th...@gmail.com>.
If you have a specific question on the persistence extension not covered
here [1] you can always ask on the Arquillian forum, the gentleman
responsible for it is very friendly and helpful ;-) For some code samples
you can take [2] as a starting point (concrete Arquillian deployments are
in subclasses in the subpackage).

[1] https://docs.jboss.org/author/display/ARQ/Persistence
[2]
https://github.com/arquillian/arquillian-extension-persistence/blob/master/int-tests/src/test/java/org/jboss/arquillian/integration/persistence/example/NonDeployableUserPersistenceTest.java


On Tue, Sep 2, 2014 at 11:57 PM, hwaastad <he...@waastad.org> wrote:

> Hi,
> always looking out for a better way to build my tests :-)
>
> mocking, well sometimes I just need mock for throwing exceptions and
> anomality.
>
> Now, I know arquillian is a powerful framework and I guess you can
> dynamically assign alternatives/stereotypes aswell by defining this with a
> addasmanifestresource/beans.xml/stringasset.
>
> I guess I just got to roll up my sleaves and do a bit more investigation on
> the persistence extension.
>
> I someone has a link or to I would be most greateful :-)
> I know Romain wrote something about this in his blog,though.
>
> Well guys,
> thanks a lot for feedback.
>
> br hw
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658766.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: "mocking" of abstractentityrepository implementations

Posted by Thomas Hug <th...@gmail.com>.
Repositories are partial beans, so the JIRA issue comment from Gerhard
might help.

Can't resist advertising Arquillian and its persistence extension here if
you look for a testing solution alternative ;-) - this works nicely with
repositories and doesn't need any (tedious) mocking.


On Tue, Sep 2, 2014 at 3:10 PM, hwaastad <he...@waastad.org> wrote:

> Hi,
> yes it's for testing only.
>
> I'm running openjb embedde (4.7.0) and I can define projectstage in
> container properties.
>
> I've been using @excludes for my SLSB to mock underlying business API's and
> I was hoping to use the same approch with my repositories.
>
> I'll have a look at the partialbindingextension aswell.
>
> br hw
>
>
>
> --
> View this message in context:
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745p4658751.html
> Sent from the Apache DeltaSpike Incubator Discussions mailing list archive
> at Nabble.com.
>

Re: "mocking" of abstractentityrepository implementations

Posted by Thomas Hug <th...@gmail.com>.
For this case it's probably also the PartialBeanBindingExtension to
deactivate.

Is this only intended for testing purposes?


On Tue, Sep 2, 2014 at 12:42 PM, John D. Ament <jo...@gmail.com>
wrote:

> Hi
>
> Did you deactivate the RepositoryExtension ?
>
>
> On Tue, Sep 2, 2014 at 4:50 AM, hwaastad <he...@waastad.org> wrote:
>
> > Hi,
> > I'm trying to mock out abstract repositories in different project stages.
> >
> > I can extend my repository (in test classes) and use
> > alternative/stereotype,
> > but excluding does not seem to work then.
> > Is this possible?
> >
> > br hw
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/mocking-of-abstractentityrepository-implementations-tp4658745.html
> > Sent from the Apache DeltaSpike Incubator Discussions mailing list
> archive
> > at Nabble.com.
> >
>