Great! thank you very much for the tip Stefan.

On 25/09/14 16:52, Stefan Seifert wrote:
yes, this is correct, in the latest sling versions you should use 
getServiceResourceResolver.
but you need additional configuration to map to a user - see [1] for details

stefan

[1] 
http://sling.apache.org/documentation/the-sling-engine/service-authentication.html


-----Original Message-----
From: Santiago García Pimentel [mailto:santiago.pimen...@netcentric.biz]
Sent: Thursday, September 25, 2014 4:47 PM
To: users@sling.apache.org
Subject: Re: accessing the repository in a sling test

thanks Stefan. I was trying to use getServiceResourceResolver() instead
of getAdministrativeResourceResolver() since it's deprecated, but I
could not make it work (got  LoginModule could not perform
authentication: Invalid authorizable name '')

I'll use that then.

Thank you

On 25/09/14 16:32, Stefan Seifert wrote:
have a look at existing integration test projects - this is a good example:


https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/integr
ation-tests

https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/integr
ation-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java

Stefan


-----Original Message-----
From: Santiago García Pimentel [mailto:santiago.pimen...@netcentric.biz]
Sent: Thursday, September 25, 2014 4:03 PM
To: users@sling.apache.org
Subject: accessing the repository in a sling test

Hello,

I've been trying writing some tests following the docs in
http://sling.apache.org/documentation/development/sling-testing-tools.html
..
I need to write a test that runs in a sling instance. This test depend
on some content saved in the jcr repository. What is the best way to do
this?

I used the ResourceResolverFactory to obtain a resourceResolver, but I
get null for any resource that I try to get from it.

The test runs with SlingAnnotationsTestRunner.class and I get the
resolver using:

          Session session = session.login();
          Map<String, Object> param = new HashMap<String, Object>();
          param.put("user.jcr.session", session);
          ResourceResolver resolver =
this.resolverFactory.getServiceResourceResolver(param);


Thank you and Greetings.




--
*Santiago García Pimentel* | Software Engineer
Netcentric Ibérica SL
Av. Diagonal 123 -8ª
08005 Barcelona
España
Skype: santiago.garciapimentel
santiago.pimen...@netcentric.biz | www.netcentric.es

--
*Santiago García Pimentel* | Software Engineer
Netcentric Ibérica SL
Av. Diagonal 123 -8ª
08005 Barcelona
España
Skype: santiago.garciapimentel
santiago.pimen...@netcentric.biz | www.netcentric.es


--
*Santiago García Pimentel* | Software Engineer
Netcentric Ibérica SL
Av. Diagonal 123 -8ª
08005 Barcelona
España
Skype: santiago.garciapimentel
santiago.pimen...@netcentric.biz | www.netcentric.es

Reply via email to