[
https://issues.apache.org/jira/browse/SLING-5040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bertrand Delacretaz updated SLING-5040:
---------------------------------------
Attachment: SLING-5040-BasicTeleporterTest.patch
At http://svn.apache.org/r1703893 I have committed a {{TeleporterRule}} in the
junit.core module (thanks [~andrei.dulvac] for suggesting that name!), with
minimal impact on that module, and a companion
{{org.apache.sling.testing.teleporter}} client-side module that takes care of
actually teleporting and executing the tests.
There are still a few TODOs in the teleporter code, but this works in our
{{launchpad/integration-tests}} with the below {{BasicTeleporterTest}} when
running that test against a {{launchpad/testing}} Sling instance that's already
started. See attached SLING-5040-BasicTeleporterTest.patch for the complete
changes to that module - I need to do some more testing before committing that.
The TeleporterRule also provides OSGi services, which reduces the amount of
boilerplate in tests such as the below one.
{code}
public class BasicTeleporterTest {
@Rule
public final TeleporterRule teleporter =
TeleporterRule.forClass(getClass());
@Test
public void testBundleContext() {
final BundleContext bc = teleporter.getService(BundleContext.class);
assertNotNull("Teleporter should provide a BundleContext", bc);
}
@Test
public void testConfigAdmin() throws IOException {
final String pid = "TEST_" + getClass().getName() + UUID.randomUUID();
final ConfigurationAdmin ca =
teleporter.getService(ConfigurationAdmin.class);
assertNotNull("Teleporter should provide a ConfigurationAdmin", ca);
final Configuration cfg = ca.getConfiguration(pid);
assertNotNull("Expecting to get a Configuration", cfg);
assertEquals("Expecting the correct pid", pid, cfg.getPid());
}
}
{code}
> Simplified server-side tests with ServerSideTestRule
> ----------------------------------------------------
>
> Key: SLING-5040
> URL: https://issues.apache.org/jira/browse/SLING-5040
> Project: Sling
> Issue Type: Improvement
> Components: Testing
> Reporter: Bertrand Delacretaz
> Assignee: Bertrand Delacretaz
> Priority: Minor
> Attachments: SLING-5040-BasicTeleporterTest.patch
>
>
> I've been working on prototype at [1] that makes it much easier to create
> server-side tests.
> _edit: remove obsolete description of {{ServerSideTestRule}}_
> This can be useful along with something like
> https://github.com/fizzed/maven-plugins to quickly update the bundle under
> development when it's modified.
> [1] https://svn.apache.org/repos/asf/sling/whiteboard/bdelacretaz/test-rules
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)