Re: [caconfig][mock] configuration resolver mock?

2017-01-04 Thread Nicolas Peltier
awesome! thanks!
On Jan 4, 2017, at 3:07 PM, Stefan Seifert 
mailto:sseif...@pro-vision.de>> wrote:

you have the possibility to set your custom config via ConfigAdmin in the 
mock-osgi context. i've added and example to the documentation:
http://sling.apache.org/documentation/development/osgi-mock.html#provide-your-own-configuration-via-configadmin

you can wrap the code for this in an implementation of 
org.apache.sling.testing.mock.sling.junit.SlingContextCallback and call it in 
the SlingContextBuilder before calling the caconfig context plugin.

stefan

-Original Message-
From: Nicolas Peltier [mailto:npelt...@adobe.com]
Sent: Wednesday, January 4, 2017 2:31 PM
To: users@sling.apache.org<mailto:users@sling.apache.org>
Subject: Re: [caconfig][mock] configuration resolver mock?

Thanks Stefan!

one thing that is not clear to me: how should i configure CA services in my
unit tests.
I know we have different views for
DefaultConfigurationResourceResolvingStrategy’s configPath property, but
e.g. setting DefaultContextPathStrategy’s configRefResourceNames to
“[jcr:content]” so it looks in those children is not trivial: activate
method is private as well as most of the members. Any indication (but going
away from the content model i have)?

Nicolas


On Dec 10, 2016, at 9:38 AM, Stefan Seifert http://vision.de/><mailto:sseif...@pro-vision.de>> wrote:

it's easier now - the recent sling-mock releases got a plugin interface,
and there is a plugin for context-aware configuration (soon to be release,
use 1.0.0-SNAPSHOT vor trying it out).

see http://sling.apache.org/documentation/bundles/context-aware-
configuration/context-aware-configuration.html#unit-tests-with-context-
aware-configuration

stefan


-Original Message-
From: Stefan Seifert [mailto:sseif...@pro-vision.de]
Sent: Thursday, December 1, 2016 9:30 PM
To: 
users@sling.apache.org<mailto:users@sling.apache.org><mailto:users@sling.apache.org>
Subject: RE: [caconfig][mock] configuration resolver mock?

not yet - but it's definitly planned.
i think we do not need a mock of caconfig, we can just use it directly. it
only needs a couple of osgi services registered in the mock context, and we
can make this a bit easier.

until then have a look at [1] and [2] how to do it manually.

stefan

[1]
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/Configura
tionResourceTestUtils.java

[2]
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
config/impl/src/test/java/org/apache/sling/caconfig/impl/ConfigurationTestU
tils.java


-Original Message-
From: Nicolas Peltier [mailto:npelt...@adobe.com]
Sent: Thursday, December 1, 2016 2:13 PM
To: users@sling.apache.org
Subject: [caconfig][mock] configuration resolver mock?

Hi

is there a configuration resolver mock i can use, or is it planned ?

Nicolas



RE: [caconfig][mock] configuration resolver mock?

2017-01-04 Thread Stefan Seifert
you have the possibility to set your custom config via ConfigAdmin in the 
mock-osgi context. i've added and example to the documentation:
http://sling.apache.org/documentation/development/osgi-mock.html#provide-your-own-configuration-via-configadmin

you can wrap the code for this in an implementation of 
org.apache.sling.testing.mock.sling.junit.SlingContextCallback and call it in 
the SlingContextBuilder before calling the caconfig context plugin.

stefan

>-Original Message-
>From: Nicolas Peltier [mailto:npelt...@adobe.com]
>Sent: Wednesday, January 4, 2017 2:31 PM
>To: users@sling.apache.org
>Subject: Re: [caconfig][mock] configuration resolver mock?
>
>Thanks Stefan!
>
>one thing that is not clear to me: how should i configure CA services in my
>unit tests.
>I know we have different views for
>DefaultConfigurationResourceResolvingStrategy’s configPath property, but
>e.g. setting DefaultContextPathStrategy’s configRefResourceNames to
>“[jcr:content]” so it looks in those children is not trivial: activate
>method is private as well as most of the members. Any indication (but going
>away from the content model i have)?
>
>Nicolas
>
>
>On Dec 10, 2016, at 9:38 AM, Stefan Seifert vision.de<mailto:sseif...@pro-vision.de>> wrote:
>
>it's easier now - the recent sling-mock releases got a plugin interface,
>and there is a plugin for context-aware configuration (soon to be release,
>use 1.0.0-SNAPSHOT vor trying it out).
>
>see http://sling.apache.org/documentation/bundles/context-aware-
>configuration/context-aware-configuration.html#unit-tests-with-context-
>aware-configuration
>
>stefan
>
>
>-Original Message-
>From: Stefan Seifert [mailto:sseif...@pro-vision.de]
>Sent: Thursday, December 1, 2016 9:30 PM
>To: users@sling.apache.org<mailto:users@sling.apache.org>
>Subject: RE: [caconfig][mock] configuration resolver mock?
>
>not yet - but it's definitly planned.
>i think we do not need a mock of caconfig, we can just use it directly. it
>only needs a couple of osgi services registered in the mock context, and we
>can make this a bit easier.
>
>until then have a look at [1] and [2] how to do it manually.
>
>stefan
>
>[1]
>https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
>config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/Configura
>tionResourceTestUtils.java
>
>[2]
>https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
>config/impl/src/test/java/org/apache/sling/caconfig/impl/ConfigurationTestU
>tils.java
>
>
>-Original Message-
>From: Nicolas Peltier [mailto:npelt...@adobe.com]
>Sent: Thursday, December 1, 2016 2:13 PM
>To: users@sling.apache.org
>Subject: [caconfig][mock] configuration resolver mock?
>
>Hi
>
>is there a configuration resolver mock i can use, or is it planned ?
>
>Nicolas
>
>
>
>



Re: [caconfig][mock] configuration resolver mock?

2017-01-04 Thread Nicolas Peltier
Thanks Stefan!

one thing that is not clear to me: how should i configure CA services in my 
unit tests.
I know we have different views for 
DefaultConfigurationResourceResolvingStrategy’s configPath property, but e.g. 
setting DefaultContextPathStrategy’s configRefResourceNames to “[jcr:content]” 
so it looks in those children is not trivial: activate method is private as 
well as most of the members. Any indication (but going away from the content 
model i have)?

Nicolas


On Dec 10, 2016, at 9:38 AM, Stefan Seifert 
mailto:sseif...@pro-vision.de>> wrote:

it's easier now - the recent sling-mock releases got a plugin interface, and 
there is a plugin for context-aware configuration (soon to be release, use 
1.0.0-SNAPSHOT vor trying it out).

see 
http://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html#unit-tests-with-context-aware-configuration

stefan


-Original Message-
From: Stefan Seifert [mailto:sseif...@pro-vision.de]
Sent: Thursday, December 1, 2016 9:30 PM
To: users@sling.apache.org<mailto:users@sling.apache.org>
Subject: RE: [caconfig][mock] configuration resolver mock?

not yet - but it's definitly planned.
i think we do not need a mock of caconfig, we can just use it directly. it
only needs a couple of osgi services registered in the mock context, and we
can make this a bit easier.

until then have a look at [1] and [2] how to do it manually.

stefan

[1]
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/Configura
tionResourceTestUtils.java

[2]
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
config/impl/src/test/java/org/apache/sling/caconfig/impl/ConfigurationTestU
tils.java


-Original Message-
From: Nicolas Peltier [mailto:npelt...@adobe.com]
Sent: Thursday, December 1, 2016 2:13 PM
To: users@sling.apache.org
Subject: [caconfig][mock] configuration resolver mock?

Hi

is there a configuration resolver mock i can use, or is it planned ?

Nicolas







RE: [caconfig][mock] configuration resolver mock?

2016-12-10 Thread Stefan Seifert
it's easier now - the recent sling-mock releases got a plugin interface, and 
there is a plugin for context-aware configuration (soon to be release, use 
1.0.0-SNAPSHOT vor trying it out).

see 
http://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html#unit-tests-with-context-aware-configuration

stefan


>-Original Message-
>From: Stefan Seifert [mailto:sseif...@pro-vision.de]
>Sent: Thursday, December 1, 2016 9:30 PM
>To: users@sling.apache.org
>Subject: RE: [caconfig][mock] configuration resolver mock?
>
>not yet - but it's definitly planned.
>i think we do not need a mock of caconfig, we can just use it directly. it
>only needs a couple of osgi services registered in the mock context, and we
>can make this a bit easier.
>
>until then have a look at [1] and [2] how to do it manually.
>
>stefan
>
>[1]
>https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
>config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/Configura
>tionResourceTestUtils.java
>
>[2]
>https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-
>config/impl/src/test/java/org/apache/sling/caconfig/impl/ConfigurationTestU
>tils.java
>
>
>>-Original Message-
>>From: Nicolas Peltier [mailto:npelt...@adobe.com]
>>Sent: Thursday, December 1, 2016 2:13 PM
>>To: users@sling.apache.org
>>Subject: [caconfig][mock] configuration resolver mock?
>>
>>Hi
>>
>>is there a configuration resolver mock i can use, or is it planned ?
>>
>>Nicolas
>
>




RE: [caconfig][mock] configuration resolver mock?

2016-12-01 Thread Stefan Seifert
not yet - but it's definitly planned.
i think we do not need a mock of caconfig, we can just use it directly. it only 
needs a couple of osgi services registered in the mock context, and we can make 
this a bit easier.

until then have a look at [1] and [2] how to do it manually.

stefan

[1] 
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/resource/impl/ConfigurationResourceTestUtils.java

[2] 
https://github.com/apache/sling/blob/trunk/contrib/extensions/contextaware-config/impl/src/test/java/org/apache/sling/caconfig/impl/ConfigurationTestUtils.java


>-Original Message-
>From: Nicolas Peltier [mailto:npelt...@adobe.com]
>Sent: Thursday, December 1, 2016 2:13 PM
>To: users@sling.apache.org
>Subject: [caconfig][mock] configuration resolver mock?
>
>Hi
>
>is there a configuration resolver mock i can use, or is it planned ?
>
>Nicolas