I am having a LoginException when loading mock data while testing a servlet using AEMContext in a JUnit test. I want to load a sample node without an exception.
I am using AEMContext within a JUnit test for a servlet.
public final AemContext context = new AemContext(ResourceResolverType.JCR_MOCK);
@BeforeEach
void setUp() throws Exception {
context.load().json(getClass().getResourceAsStream(getClass().getSimpleName() + ".json"),"/var/dupertious/topic");
}
When this code runs, it throws a LoginException:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.032 s <<< FAILURE! - in com.dupertious.servlets.UploadLinksAsCSVTest
[ERROR] testResponseJSON Time elapsed: 0.989 s <<< ERROR!
java.lang.RuntimeException: Creating resource resolver failed.
at com.dupertioius.servlets.UploadLinksAsCSVTest.setUp(UploadLinksAsCSVTest.java:27)
Caused by: org.apache.sling.api.resource.LoginException: Calling bundle missing in authentication info
at com.dupertious.servlets.UploadLinksAsCSVTest.setUp(UploadLinksAsCSVTest.java:27)
Here's the JSON I am trying to load. I have tried it with and without the ACL.
{
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "arq\/data\/topic\/parent",
"jcr:mixinTypes": [
"rep:AccessControllable"
],
"topic-3a953c61-85c4-45d5-a4dc-6ade5f76ef97": {
"jcr:primaryType": "nt:unstructured",
"jcr:title": "Topic",
"id": "3a953c61-85c4-45d5-a4dc-6ade5f76ef97",
"sling:resourceType": "dupertious\/data\/topic",
"jcr:content": {
"jcr:primaryType": "nt:unstructured",
"links": [],
}
},
"rep:policy": {
"jcr:primaryType": "rep:ACL",
"allow": {
"jcr:primaryType": "rep:GrantACE",
"rep:principalName": "everyone",
"rep:privileges": [
"jcr:read"
]
}
}
}
Solved! Go to Solution.
Views
Replies
Total Likes
I don't think that it has something to do with the content in the JSON, but it's a different issue.
java.lang.RuntimeException: Creating resource resolver failed.
The code is here, but I can hardly think of a situation where this fails. Can you check if you get an error/warn message before that? What version of AEM Mocks / Sling Mocks are you using?
I don't think that it has something to do with the content in the JSON, but it's a different issue.
java.lang.RuntimeException: Creating resource resolver failed.
The code is here, but I can hardly think of a situation where this fails. Can you check if you get an error/warn message before that? What version of AEM Mocks / Sling Mocks are you using?
Hi Jörg,
I changed io.wcm.testing.aem-mock.junit5 to 4.0.0 from 2.5.2. It worked after that.
Views
Replies
Total Likes
Views
Likes
Replies