You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Brian Moseley <bc...@osafoundation.org> on 2005/10/04 00:20:16 UTC

mock jcr implementation

has anybody written a mock implementation of jcr for unit testing?

(is there a better list for this question?)

Re[2]: mock jcr implementation

Posted by Costin Leau <co...@gmail.com>.
> EasyMock is very nice for many cases, but it doesn't IMO very well match the
> needs of JCR unit testing. Even a simple JCR client component ends easily up
> using quite a few of the JCR interfaces (e.g. Session -> Node ->
PropertyIterator ->> Property)  in one method, which makes the EasyMock fixture
> rather complex.
I agree - I simplified the method configuring mocks for Repository,
Session, Node, Property and Iterators inside setUp / tearDown methods.
It's not perfect but it does work as an intermediary solution.

> repository stuff is still based on the file system, making the test
> environment
> more complex to manage.
Exactly :). Plus instead of recreating the repository for each test, I
prefer creating the mocks.

-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com


Re: mock jcr implementation

Posted by Brian Moseley <bc...@osafoundation.org>.
Costin Leau wrote:

> Easy mock comes in two flavours - the 1.2 version which is at least
> 1.3 compatible and version 2.0 which requires JDK 5.0.
> Both are very recent - check out the site again.

wow. the online docs make my head spin. i can't handle all the hot 
dynamic action. and to think i used to be a perl programmer :)

Re[2]: mock jcr implementation

Posted by Costin Leau <co...@gmail.com>.
> Brian Moseley wrote:

>> thanks for the suggestions. i've been going through the pain of setting 
>> up a repository and registering nodetypes and importing data. i would 
>> love an alternative that didn't have so many moving parts, even if it 
>> means a little more work to set up and tear down individual test 
>> fixtures. so i'll give easymock a try, and then fall back to the in mem 
>> pm if necessary.

> ah, i take that back. i have to live with java 1.4 for the time being,
> so i can't use easymock. ah well. hopefully somebody will motivate to 
> write a proper mock implementation of jcr someday. i considered it but
> just don't have the time :/
Easy mock comes in two flavours - the 1.2 version which is at least
1.3 compatible and version 2.0 which requires JDK 5.0.
Both are very recent - check out the site again.


-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com


Re: mock jcr implementation

Posted by Brian Moseley <bc...@osafoundation.org>.
Brian Moseley wrote:

> thanks for the suggestions. i've been going through the pain of setting 
> up a repository and registering nodetypes and importing data. i would 
> love an alternative that didn't have so many moving parts, even if it 
> means a little more work to set up and tear down individual test 
> fixtures. so i'll give easymock a try, and then fall back to the in mem 
> pm if necessary.

ah, i take that back. i have to live with java 1.4 for the time being, 
so i can't use easymock. ah well. hopefully somebody will motivate to 
write a proper mock implementation of jcr someday. i considered it but 
just don't have the time :/

Re: mock jcr implementation

Posted by Brian Moseley <bc...@osafoundation.org>.
Jukka Zitting wrote:

> EasyMock is very nice for many cases, but it doesn't IMO very well match 
> the
> needs of JCR unit testing.
> 
> I've been thinking about a simple in-memory JCR implementation that 
> could be
> used as a kind of a mock for testing JCR applications.

thanks for the suggestions. i've been going through the pain 
of setting up a repository and registering nodetypes and 
importing data. i would love an alternative that didn't have 
so many moving parts, even if it means a little more work to 
set up and tear down individual test fixtures. so i'll give 
easymock a try, and then fall back to the in mem pm if 
necessary.

incidentally, it seems astonishing that we don't have 
simple, scriptable tools for namespace and nodetype 
registration and data import and export. i know edgar is 
working on the jcr-command one, and i'm super anxious to see 
it, cos i'm starting to get hard for a backup/restore 
solution for my webdav server. obviously i can write code to 
import and export xml docviews, and i am, but i'd prefer a 
general purpose tool provided by jackrabbit that's 
maintained by somebody with more intelligence and motivation 
that me :) ideally it would all be as simple as "mysql db < 
create-schema.sql" and "mysqldump db > export.sql" and 
"mysqldump db < import.sql". it's hard for users to screw 
those up :)

Re: mock jcr implementation

Posted by Jukka Zitting <ju...@zitting.name>.
Hi,

Costin Leau wrote:
>> has anybody written a mock implementation of jcr for unit testing?
> You can use easymock (as a replacement or substitute until you find
> the mock implementation).

EasyMock is very nice for many cases, but it doesn't IMO very well match the
needs of JCR unit testing. Even a simple JCR client component ends easily up
using quite a few of the JCR interfaces (e.g. Session -> Node ->
PropertyIterator -> Property)  in one method, which makes the EasyMock fixture
rather complex.

I've been thinking about a simple in-memory JCR implementation that could be
used as a kind of a mock for testing JCR applications. As I've so far not had
much time to work on this idea, I've been using Jackrabbit with the
InMemPersistenceManager as an alternative solution. The problem with this
solution is that even though the node data is kept in memory, much of the
repository stuff is still based on the file system, making the test 
environment
more complex to manage.

BR,

Jukka Zitting

Re: mock jcr implementation

Posted by Costin Leau <co...@gmail.com>.
> has anybody written a mock implementation of jcr for unit testing?
You can use easymock (as a replacement or substitute until you find
the mock implementation).

-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com