Expand my Community achievements bar.

SOLVED

JUNIT SAXNotRecognizedException

Avatar

Level 2
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
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi, 


This is because you are missing the "xercesImpl" dependency in your project, please check this thread to know how to fix this issue: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxn... 



Esteban Bustamante

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi, 


This is because you are missing the "xercesImpl" dependency in your project, please check this thread to know how to fix this issue: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxn... 



Esteban Bustamante

Avatar

Administrator

@rute  Did you find the suggestions from @EstebanBustamante helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni