Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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
Level 2

How I solved:

            <dependency>
                <groupId>junit-addons</groupId>
                <artifactId>junit-addons</artifactId>
                <scope>test</scope>
                <version>1.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

 

View solution in original post

4 Replies

Avatar

Employee Advisor

Which version of jackson are you using? It should be listed in your pom.

Avatar

Level 9

To fix this issue you need to add below dependency in pom.xml

<dependency>
	<groupId>xerces</groupId>
	<artifactId>xercesImpl</artifactId>
	<version>2.12.2</version>
	<scope>test</scope>
</dependency>

Please refer this link of same issue : 
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxn...

 

Avatar

Correct answer by
Level 2

How I solved:

            <dependency>
                <groupId>junit-addons</groupId>
                <artifactId>junit-addons</artifactId>
                <scope>test</scope>
                <version>1.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>