Hey Justin, What do you mean by the following?:
most of the integration > tests I write run in Maven and interact with servlets/scripts running > inside Sling via HTTP. Do you have a separate test OSGi bundle where you invoke `mvn test` at and it'll deploy the test bundle and run tests? Are there actual integration tests written with http://sling.apache.org/site/sling-testing-tools.html (not just simple samples) ? I am not sure how to manage ResourceResolver for my Test class. class Test { @TestReference private ResourceResolverFactory resolverFactory; ResourceResolver resourceResolver; } Given above, do I call resolverFactory.getAdministrativeResourceResolver(null); @Before each @Test method? And, call resourceResolver.logout(); @After each @Test? Ideally, I would login/logout to repository once before and after running a bunch of @Test methods. I tried with @BeforeClass and @AfterClass. But, I don't know how to make @TestReference inject to static fields. Why is junit chosen as integration testing? At least testNG supports test dependencies so that I can login to/logout from repository once.. Do you know which projects actually use sling integration tests? http://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests This looks like the only integration test for sling. But, these don't use ResourceResolverFactory (@TestReference). On Fri, Jan 27, 2012 at 9:54 PM, Justin Edelson <[email protected]>wrote: > Sam- > Regardless of whether it is a JSP or Servlet, the correct way to > handle this is to create a node with a sling:resourceType property. > Your JSP or Servlet should be associated with that resource type. If > you need to secure the content, secure the content, but that's an > orthogonal concern to the scripts used to render the content. Mounting > a servlet at a particular path is sometimes necessary and appropriate, > but more often than not it is something you can and should avoid. And, > as you note, this puts the onus of security on your servlet, not the > repository. > > To your question about integration tests, most of the integration > tests I write run in Maven and interact with servlets/scripts running > inside Sling via HTTP. I try not to write test-specific servlets to > the greatest extent possible. We obviously need to create test > services for testing the framework itself, but not for applications > running inside of the framework. I also try to focus on writing unit > tests with good mocks as those tend to be significantly faster than > integration tests. YMMV, of course. > > Justin > > On Fri, Jan 27, 2012 at 1:33 PM, sam ” <[email protected]> wrote: > > Hey, > > > > I have a test script that will make a series of HTTP requests to Sling. > > I need to write servlets that will handle the requests. > > I can either use jsp (/apps/tests/test1/json.jsp, for example). > > Or, I can write a @Service that implements Servlet interface. > > > > Good thing about writing .jsp to the repository is that I can configure > ACL > > to block access to /apps/tests. > > If I write a @Service that implements Servlet interface (that handles > > requests to /bin/tests, for example), anonymous users can make requests. > > Maybe there is a way to configure ACL for resources that do not exist in > > the repository (such as /bin/tests) ?? > > > > How do you write integration tests? > > > > Thanks. > > Sam. >
