You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Seelmann <se...@apache.org> on 2010/06/03 23:04:43 UTC

[ApacheDS] Move classes of module core-mock to src/test/java of core-api

Hi dev,

the core-mock module includes some mock implementations of ApacheDS
core-api classes (CoreSession, DirectoryService, etc.). It is only used
as test dependency in ldif-partition.

To get rid of the core-mock module I'd like to suggest to move those
classes to src/test/java in core-api. To be able to use the test classes
outside of the core-api module we just need to deploy the test jar of
core-api. The using module then needs to specify a dependency with
classifier "tests", see [1] for details.

Thoughts?

Kind Regards,
Stefan

[1] http://maven.apache.org/guides/mini/guide-attached-tests.html

Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Alex Karasulu <ak...@apache.org>.
On Fri, Jun 4, 2010 at 12:27 AM, Stefan Seelmann <se...@apache.org>wrote:

> Felix Knecht wrote:
> > On 06/03/10 23:04, Stefan Seelmann wrote:
> >> Hi dev,
> >
> >> the core-mock module includes some mock implementations of ApacheDS
> >> core-api classes (CoreSession, DirectoryService, etc.). It is only used
> >> as test dependency in ldif-partition.
> >
> >> To get rid of the core-mock module I'd like to suggest to move those
> >> classes to src/test/java in core-api. To be able to use the test classes
> >> outside of the core-api module we just need to deploy the test jar of
> >> core-api. The using module then needs to specify a dependency with
> >> classifier "tests", see [1] for details.
> >
> >> Thoughts?
> >
> > +1
> >
> > Regards
> > Felix
>
> Should we declare the deployment of test jar for the core-api module
> only or should we deploy the test jars of all modules? In the latter
> case we can declare the maven-jar-module in the project pom, similar to
> the maven-source-plugin.
>
>
I like the idea of deploying some module tests because they can actually be
made to operate on different kinds of LDAP API providers or Partition
implementations as modular tests. Unfortunately JUnit is not the best for
running these tests on multiple implementations. Regardless overall this is
something that will be worth while for us once we tame our testing approach.

So yes I like this idea of enabling deployment of test jars.

-- 
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://directory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu

Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Felix Knecht wrote:
> On 06/03/10 23:04, Stefan Seelmann wrote:
>> Hi dev,
> 
>> the core-mock module includes some mock implementations of ApacheDS
>> core-api classes (CoreSession, DirectoryService, etc.). It is only used
>> as test dependency in ldif-partition.
> 
>> To get rid of the core-mock module I'd like to suggest to move those
>> classes to src/test/java in core-api. To be able to use the test classes
>> outside of the core-api module we just need to deploy the test jar of
>> core-api. The using module then needs to specify a dependency with
>> classifier "tests", see [1] for details.
> 
>> Thoughts?
> 
> +1
> 
> Regards
> Felix

Should we declare the deployment of test jar for the core-api module
only or should we deploy the test jars of all modules? In the latter
case we can declare the maven-jar-module in the project pom, similar to
the maven-source-plugin.

Kind Regards,
Stefan


Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Felix Knecht <fe...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/03/10 23:04, Stefan Seelmann wrote:
> Hi dev,
> 
> the core-mock module includes some mock implementations of ApacheDS
> core-api classes (CoreSession, DirectoryService, etc.). It is only used
> as test dependency in ldif-partition.
> 
> To get rid of the core-mock module I'd like to suggest to move those
> classes to src/test/java in core-api. To be able to use the test classes
> outside of the core-api module we just need to deploy the test jar of
> core-api. The using module then needs to specify a dependency with
> classifier "tests", see [1] for details.
> 
> Thoughts?

+1

Regards
Felix
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwIGiYACgkQ2lZVCB08qHHAWQCcDJyP2q5lL5jnjCmSqazcbYRY
ubIAoOBI+wdlHqgzv/LzW/9BTvt6CeKF
=WhS8
-----END PGP SIGNATURE-----

Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Felix Knecht <fe...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Another option that also works: as the mocks are only used by the LDIF
> partition tests we can also move them to src/test/java of
> ldif-partition. I think that's the better option.

+1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwI7I0ACgkQ2lZVCB08qHHvjgCghKyfA3uDYeTg32ck0UOKbJlY
K6QAoObgzUi1VzuaW0HPsVAGyqKe2+EG
=qIZR
-----END PGP SIGNATURE-----

Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Done.

Emmanuel Lecharny wrote:
> On 6/4/10 2:53 PM, Stefan Seelmann wrote:
>> Emmanuel Lecharny wrote:
>>   
>>> On 6/4/10 2:01 PM, Stefan Seelmann wrote:
>>>     
>>>>       
>>>>> So where should we put the mocks ? Core-API as you suggested ?
>>>>> (IMO, if
>>>>> that solve the problem, then +1)
>>>>>
>>>>>          
>>>> Yes, this would solve the problem.
>>>>
>>>> Another option that also works: as the mocks are only used by the LDIF
>>>> partition tests we can also move them to src/test/java of
>>>> ldif-partition. I think that's the better option.
>>>>
>>>>        
>>> What if we want to use those mocks in another module in the near (or not
>>> so near) future ?

The future is now :-)

Some tests in apacheds-core defined their own mock classes. It was easy
to remove those duplicate mock classes.

Kind Regards,
Stefan


Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/4/10 2:53 PM, Stefan Seelmann wrote:
> Emmanuel Lecharny wrote:
>    
>> On 6/4/10 2:01 PM, Stefan Seelmann wrote:
>>      
>>>        
>>>> So where should we put the mocks ? Core-API as you suggested ? (IMO, if
>>>> that solve the problem, then +1)
>>>>
>>>>          
>>> Yes, this would solve the problem.
>>>
>>> Another option that also works: as the mocks are only used by the LDIF
>>> partition tests we can also move them to src/test/java of
>>> ldif-partition. I think that's the better option.
>>>
>>>        
>> What if we want to use those mocks in another module in the near (or not
>> so near) future ?
>>
>> Wouldn't it be better to just let the mock be accessible by moving them
>> in core-api?
>>
>> (playing devil's advocate here...)
>>      
> Should I bring another option into the game: Using a mock framework like
>   EaseMock or Mockito?
>    

If it works, then totally +1
> Let's keep it simple. It isn't a big difference to move them to core-api
> or ldif-partition. The latter option is just a bit simpler to solve the
> current problem. But I agree with you, moving them to core-api makes it
> easier to reuse the mocks.
>    
Here, I would say it's up to you. No need to spend more time on 
discussing on the mailing list about the pros and cons ad nauseam, it's 
not changing the way the server works :)

As soon as we know what are our options, and as it's now just a choice 
to make, then let's go for what you think is the best.

Thanks !

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com



Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny wrote:
> On 6/4/10 2:01 PM, Stefan Seelmann wrote:
>>
>>> So where should we put the mocks ? Core-API as you suggested ? (IMO, if
>>> that solve the problem, then +1)
>>>      
>> Yes, this would solve the problem.
>>
>> Another option that also works: as the mocks are only used by the LDIF
>> partition tests we can also move them to src/test/java of
>> ldif-partition. I think that's the better option.
>>    
> 
> What if we want to use those mocks in another module in the near (or not
> so near) future ?
> 
> Wouldn't it be better to just let the mock be accessible by moving them
> in core-api?
> 
> (playing devil's advocate here...)

Should I bring another option into the game: Using a mock framework like
 EaseMock or Mockito?

Let's keep it simple. It isn't a big difference to move them to core-api
or ldif-partition. The latter option is just a bit simpler to solve the
current problem. But I agree with you, moving them to core-api makes it
easier to reuse the mocks.

Kind Regards,
Stefan


Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/4/10 2:01 PM, Stefan Seelmann wrote:
>
>> So where should we put the mocks ? Core-API as you suggested ? (IMO, if
>> that solve the problem, then +1)
>>      
> Yes, this would solve the problem.
>
> Another option that also works: as the mocks are only used by the LDIF
> partition tests we can also move them to src/test/java of
> ldif-partition. I think that's the better option.
>    

What if we want to use those mocks in another module in the near (or not 
so near) future ?

Wouldn't it be better to just let the mock be accessible by moving them 
in core-api?

(playing devil's advocate here...)

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com



Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny schrieb:
> On 6/4/10 10:10 AM, Stefan Seelmann wrote:
>> Emmanuel Lecharny wrote:
>>   
>>> On 6/4/10 1:03 AM, Stefan Seelmann wrote:
>>>     
>>>> Emmanuel Lecharny wrote:
>>>>
>>>>       
>>>>> On 6/3/10 11:04 PM, Stefan Seelmann wrote:
>>>>>
>>>>>         
>>>>>> Hi dev,
>>>>>>
>>>>>> the core-mock module includes some mock implementations of ApacheDS
>>>>>> core-api classes (CoreSession, DirectoryService, etc.). It is only
>>>>>> used
>>>>>> as test dependency in ldif-partition.
>>>>>>
>>>>>> To get rid of the core-mock module I'd like to suggest to move those
>>>>>> classes to src/test/java in core-api. To be able to use the test
>>>>>> classes
>>>>>> outside of the core-api module we just need to deploy the test jar of
>>>>>> core-api. The using module then needs to specify a dependency with
>>>>>> classifier "tests", see [1] for details.
>>>>>>
>>>>>>
>>>>>>            
>>>>> We also had a discussion with Pierre-Arnaud about those unit tests.
>>>>> Once
>>>>> upon a time, we have had some core-unti and server-unit modules. They
>>>>> have been renamed core-intger and server-integ. So far, so good,
>>>>> but we
>>>>> still have another module called apacheds-test-framework.
>>>>>
>>>>> We do think that the classes we have in core/server-integ - I mean,
>>>>> the
>>>>> classes in java/main, not the tests - should be moved to
>>>>> apacheds-test-framework.
>>>>>
>>>>> That being said, we could also move the core-mock into this
>>>>> apacheds-test-framework module.
>>>>>
>>>>> Does it make sense ?
>>>>>
>>>>>          
>>>> I'm afraid that won't be possible because this would cause cyclic
>>>> dependencies.
>>>>
>>>> The integ tests and the test framework start up a real directory
>>>> service
>>>> with real partitions, including an LDIF based config and schema
>>>> partition, so they depend on the ldif-partition.
>>>>
>>>> The mocks are used because we can't start a real directory service in
>>>> ldif-partion module for unit tests.
>>>>
>>>> But we can run the integration tests against the LDIF partition.
>>>>
>>>>        
>>> Ok, so we have the exact same problem than with the LDAP API : we had to
>>> extract the api tests and put them in ApacheDS just to be able to launch
>>> a real server.
>>>
>>> What about doing the same thing and move all the Ldif-Partition tests
>>> out of the ldif-partition module and put them where they can use the
>>> real DS ?
>>>
>>> I mean, tests are not to be close to the part they are testing?
>>>
>>> thoughts ?
>>>      
>> I think we should distinguish unit tests and integration tests.
>>
>> Unit tests should be close to the part they are testing. And they should
>> not test other components around. Thus it is valid to use mocks.
> Absolutely
>> The
>> tests in ldif-partition are unit tests because they just test that the
>> ldif-partition code works, that is that files in the file system are
>> created or deleted. So I think these tests are at the right place.
>>    
> So where should we put the mocks ? Core-API as you suggested ? (IMO, if
> that solve the problem, then +1)

Yes, this would solve the problem.

Another option that also works: as the mocks are only used by the LDIF
partition tests we can also move them to src/test/java of
ldif-partition. I think that's the better option.




Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/4/10 10:10 AM, Stefan Seelmann wrote:
> Emmanuel Lecharny wrote:
>    
>> On 6/4/10 1:03 AM, Stefan Seelmann wrote:
>>      
>>> Emmanuel Lecharny wrote:
>>>
>>>        
>>>> On 6/3/10 11:04 PM, Stefan Seelmann wrote:
>>>>
>>>>          
>>>>> Hi dev,
>>>>>
>>>>> the core-mock module includes some mock implementations of ApacheDS
>>>>> core-api classes (CoreSession, DirectoryService, etc.). It is only used
>>>>> as test dependency in ldif-partition.
>>>>>
>>>>> To get rid of the core-mock module I'd like to suggest to move those
>>>>> classes to src/test/java in core-api. To be able to use the test
>>>>> classes
>>>>> outside of the core-api module we just need to deploy the test jar of
>>>>> core-api. The using module then needs to specify a dependency with
>>>>> classifier "tests", see [1] for details.
>>>>>
>>>>>
>>>>>            
>>>> We also had a discussion with Pierre-Arnaud about those unit tests. Once
>>>> upon a time, we have had some core-unti and server-unit modules. They
>>>> have been renamed core-intger and server-integ. So far, so good, but we
>>>> still have another module called apacheds-test-framework.
>>>>
>>>> We do think that the classes we have in core/server-integ - I mean, the
>>>> classes in java/main, not the tests - should be moved to
>>>> apacheds-test-framework.
>>>>
>>>> That being said, we could also move the core-mock into this
>>>> apacheds-test-framework module.
>>>>
>>>> Does it make sense ?
>>>>
>>>>          
>>> I'm afraid that won't be possible because this would cause cyclic
>>> dependencies.
>>>
>>> The integ tests and the test framework start up a real directory service
>>> with real partitions, including an LDIF based config and schema
>>> partition, so they depend on the ldif-partition.
>>>
>>> The mocks are used because we can't start a real directory service in
>>> ldif-partion module for unit tests.
>>>
>>> But we can run the integration tests against the LDIF partition.
>>>
>>>        
>> Ok, so we have the exact same problem than with the LDAP API : we had to
>> extract the api tests and put them in ApacheDS just to be able to launch
>> a real server.
>>
>> What about doing the same thing and move all the Ldif-Partition tests
>> out of the ldif-partition module and put them where they can use the
>> real DS ?
>>
>> I mean, tests are not to be close to the part they are testing?
>>
>> thoughts ?
>>      
> I think we should distinguish unit tests and integration tests.
>
> Unit tests should be close to the part they are testing. And they should
> not test other components around. Thus it is valid to use mocks.
Absolutely
> The
> tests in ldif-partition are unit tests because they just test that the
> ldif-partition code works, that is that files in the file system are
> created or deleted. So I think these tests are at the right place.
>    
So where should we put the mocks ? Core-API as you suggested ? (IMO, if 
that solve the problem, then +1)

Maybe what I'm suggesting is a bit too convoluted anyway.
> Kind Regards,
> Stefan
>
>
>    


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com



Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny wrote:
> On 6/4/10 1:03 AM, Stefan Seelmann wrote:
>> Emmanuel Lecharny wrote:
>>   
>>> On 6/3/10 11:04 PM, Stefan Seelmann wrote:
>>>     
>>>> Hi dev,
>>>>
>>>> the core-mock module includes some mock implementations of ApacheDS
>>>> core-api classes (CoreSession, DirectoryService, etc.). It is only used
>>>> as test dependency in ldif-partition.
>>>>
>>>> To get rid of the core-mock module I'd like to suggest to move those
>>>> classes to src/test/java in core-api. To be able to use the test
>>>> classes
>>>> outside of the core-api module we just need to deploy the test jar of
>>>> core-api. The using module then needs to specify a dependency with
>>>> classifier "tests", see [1] for details.
>>>>
>>>>        
>>> We also had a discussion with Pierre-Arnaud about those unit tests. Once
>>> upon a time, we have had some core-unti and server-unit modules. They
>>> have been renamed core-intger and server-integ. So far, so good, but we
>>> still have another module called apacheds-test-framework.
>>>
>>> We do think that the classes we have in core/server-integ - I mean, the
>>> classes in java/main, not the tests - should be moved to
>>> apacheds-test-framework.
>>>
>>> That being said, we could also move the core-mock into this
>>> apacheds-test-framework module.
>>>
>>> Does it make sense ?
>>>      
>> I'm afraid that won't be possible because this would cause cyclic
>> dependencies.
>>
>> The integ tests and the test framework start up a real directory service
>> with real partitions, including an LDIF based config and schema
>> partition, so they depend on the ldif-partition.
>>
>> The mocks are used because we can't start a real directory service in
>> ldif-partion module for unit tests.
>>
>> But we can run the integration tests against the LDIF partition.
>>    
> Ok, so we have the exact same problem than with the LDAP API : we had to
> extract the api tests and put them in ApacheDS just to be able to launch
> a real server.
> 
> What about doing the same thing and move all the Ldif-Partition tests
> out of the ldif-partition module and put them where they can use the
> real DS ?
> 
> I mean, tests are not to be close to the part they are testing?
> 
> thoughts ?

I think we should distinguish unit tests and integration tests.

Unit tests should be close to the part they are testing. And they should
not test other components around. Thus it is valid to use mocks. The
tests in ldif-partition are unit tests because they just test that the
ldif-partition code works, that is that files in the file system are
created or deleted. So I think these tests are at the right place.

Kind Regards,
Stefan


Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/4/10 1:03 AM, Stefan Seelmann wrote:
> Emmanuel Lecharny wrote:
>    
>> On 6/3/10 11:04 PM, Stefan Seelmann wrote:
>>      
>>> Hi dev,
>>>
>>> the core-mock module includes some mock implementations of ApacheDS
>>> core-api classes (CoreSession, DirectoryService, etc.). It is only used
>>> as test dependency in ldif-partition.
>>>
>>> To get rid of the core-mock module I'd like to suggest to move those
>>> classes to src/test/java in core-api. To be able to use the test classes
>>> outside of the core-api module we just need to deploy the test jar of
>>> core-api. The using module then needs to specify a dependency with
>>> classifier "tests", see [1] for details.
>>>
>>>        
>> We also had a discussion with Pierre-Arnaud about those unit tests. Once
>> upon a time, we have had some core-unti and server-unit modules. They
>> have been renamed core-intger and server-integ. So far, so good, but we
>> still have another module called apacheds-test-framework.
>>
>> We do think that the classes we have in core/server-integ - I mean, the
>> classes in java/main, not the tests - should be moved to
>> apacheds-test-framework.
>>
>> That being said, we could also move the core-mock into this
>> apacheds-test-framework module.
>>
>> Does it make sense ?
>>      
> I'm afraid that won't be possible because this would cause cyclic
> dependencies.
>
> The integ tests and the test framework start up a real directory service
> with real partitions, including an LDIF based config and schema
> partition, so they depend on the ldif-partition.
>
> The mocks are used because we can't start a real directory service in
> ldif-partion module for unit tests.
>
> But we can run the integration tests against the LDIF partition.
>    
Ok, so we have the exact same problem than with the LDAP API : we had to 
extract the api tests and put them in ApacheDS just to be able to launch 
a real server.

What about doing the same thing and move all the Ldif-Partition tests 
out of the ldif-partition module and put them where they can use the 
real DS ?

I mean, tests are not to be close to the part they are testing?

thoughts ?

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com



Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Stefan Seelmann <se...@apache.org>.
Emmanuel Lecharny wrote:
> On 6/3/10 11:04 PM, Stefan Seelmann wrote:
>> Hi dev,
>>
>> the core-mock module includes some mock implementations of ApacheDS
>> core-api classes (CoreSession, DirectoryService, etc.). It is only used
>> as test dependency in ldif-partition.
>>
>> To get rid of the core-mock module I'd like to suggest to move those
>> classes to src/test/java in core-api. To be able to use the test classes
>> outside of the core-api module we just need to deploy the test jar of
>> core-api. The using module then needs to specify a dependency with
>> classifier "tests", see [1] for details.
>>    
> We also had a discussion with Pierre-Arnaud about those unit tests. Once
> upon a time, we have had some core-unti and server-unit modules. They
> have been renamed core-intger and server-integ. So far, so good, but we
> still have another module called apacheds-test-framework.
> 
> We do think that the classes we have in core/server-integ - I mean, the
> classes in java/main, not the tests - should be moved to
> apacheds-test-framework.
> 
> That being said, we could also move the core-mock into this
> apacheds-test-framework module.
> 
> Does it make sense ?

I'm afraid that won't be possible because this would cause cyclic
dependencies.

The integ tests and the test framework start up a real directory service
with real partitions, including an LDIF based config and schema
partition, so they depend on the ldif-partition.

The mocks are used because we can't start a real directory service in
ldif-partion module for unit tests.

But we can run the integration tests against the LDIF partition.

Kind Regards,
Stefan


Re: [ApacheDS] Move classes of module core-mock to src/test/java of core-api

Posted by Emmanuel Lecharny <el...@gmail.com>.
On 6/3/10 11:04 PM, Stefan Seelmann wrote:
> Hi dev,
>
> the core-mock module includes some mock implementations of ApacheDS
> core-api classes (CoreSession, DirectoryService, etc.). It is only used
> as test dependency in ldif-partition.
>
> To get rid of the core-mock module I'd like to suggest to move those
> classes to src/test/java in core-api. To be able to use the test classes
> outside of the core-api module we just need to deploy the test jar of
> core-api. The using module then needs to specify a dependency with
> classifier "tests", see [1] for details.
>    
We also had a discussion with Pierre-Arnaud about those unit tests. Once 
upon a time, we have had some core-unti and server-unit modules. They 
have been renamed core-intger and server-integ. So far, so good, but we 
still have another module called apacheds-test-framework.

We do think that the classes we have in core/server-integ - I mean, the 
classes in java/main, not the tests - should be moved to 
apacheds-test-framework.

That being said, we could also move the core-mock into this 
apacheds-test-framework module.

Does it make sense ?

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com