Solved
JUNIT SAXNotRecognizedException
Testing locally and getting error at this this line: ctx.load().json("/com/test/core/models/impl/CardTest.json", "/content");
Java test class:
@ExtendWith({AemContextExtension.class, MockitoExtension.class})
public class CardTest {
private final AemContext ctx = new AemContext();
private Card card;
@BeforeEach public void setUp() throws Exception {
ctx.addModelsForClasses(Card .class);
ctx.load().json("/com/test/core/models/impl/CardTest.json", "/content");
}
@test
void testGetTitle() {
ctx.currentResource("/content/cardtest");
card = ctx.request().adaptTo(Card.class);
assertEquals("Title", card.getTitle());
}
CardTest.json { "cardtest": { "jcr:primaryType": "nt:unstructured", "sling:resourceType": "test/components/test-component", "title": "Title" } }
java.lang.IllegalStateException: Unable to enable secure processing. at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.(JCRXMLContentParser.java:61) at org.apache.sling.testing.mock.sling.loader.ContentLoader.(ContentLoader.java:149) at
org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:376) at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:366) at
com.test.core.models.impl.card.CardTest .setUp(CardTest.java:22) at
java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: org.xml.sax.SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized. at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source) at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source) at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source) at
org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.(JCRXMLContentParser.java:57) ... 77 more