thanks for the reply.
I want to run the code outside of the Repository instance (outside of AEM). I don't want to run any tests remotely, i.e. like in a JSP that still resides on the AEM itself.
My goal is just to open a connection to the repository like I can do with JcrUtils.getRepository(). This way I still can connect and operate to any JCR nodes directly. But I like to use the Sling Features (i.e. adaptTo).
There can be two approach to solve your problem
a) Considering the test class resides inside OSGI, you can inject a reference to this service 
b) If you still need a slingRequest Object(from current user session), you can make a rest end point(write all ur test class code in jsp) and hit this rest end point. For this you can refer  
Let me know if you still face any problem.