You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Henry Kuijpers (Jira)" <ji...@apache.org> on 2023/03/31 11:05:00 UTC

[jira] [Updated] (SLING-11815) Let context.load().json() accept class as input, to help resolving files more local to the test class

     [ https://issues.apache.org/jira/browse/SLING-11815?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henry Kuijpers updated SLING-11815:
-----------------------------------
    Affects Version/s: Testing Sling Mock 3.4.4

> Let context.load().json() accept class as input, to help resolving files more local to the test class
> -----------------------------------------------------------------------------------------------------
>
>                 Key: SLING-11815
>                 URL: https://issues.apache.org/jira/browse/SLING-11815
>             Project: Sling
>          Issue Type: Bug
>    Affects Versions: Testing Sling Mock 3.4.4
>            Reporter: Henry Kuijpers
>            Priority: Major
>
> When testing functionality in package "a.b.c" for class "X" (in "src/java") typically the unit test class is created in package "a.b.c" as well, called "XTest" (in "src/test").
> Sometimes, we want to load resources (such as JSON files) as content in the virtual repository. It would be very convenient if we could load these resources relative to the current package: I.e. by creating the following structure:
> * src/test/java/a/b/c/XTest.java
> * src/test/resources/a/b/c/my-content.json
> and then loading it by using:
> context.load().json("my-content.json");
> Of course, the context's ContentLoader cannot know anything about the class it is being used from, which is why the ContentLoader class is used to load the resource. This could be a default way of doing it. However, it would be nice to send an additional argument to the json()-method, providing the class to use, which could easily be filled in with "getClass()", to go in the context of the current test class and allows resolving the file in the package as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)