Skip to content

Commit 7751b39

Browse files
authoredMar 19, 2025··
Merge pull request #960 from marilynel/master
Updated configuration to enable strictMode unit testing with Maven
2 parents 6452a6f + 628d8c4 commit 7751b39

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
 

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ gradlew clean build test
103103
gradlew testWithStrictMode
104104
```
105105

106+
*Optional* Execute the test suite in strict mode with Maven:
107+
108+
```shell
109+
mvn test -P test-strict-mode
110+
```
111+
106112
# Notes
107113

108114
For more information, please see [NOTES.md](https://github.com/stleary/JSON-java/blob/master/docs/NOTES.md)

‎pom.xml

+51
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,55 @@
200200
</plugin>
201201
</plugins>
202202
</build>
203+
<profiles>
204+
<profile>
205+
<id>test-strict-mode</id>
206+
<build>
207+
<plugins>
208+
<plugin>
209+
<groupId>com.google.code.maven-replacer-plugin</groupId>
210+
<artifactId>replacer</artifactId>
211+
<version>1.5.3</version>
212+
<executions>
213+
<!-- Enable strict mode -->
214+
<execution>
215+
<id>enable-strict-mode</id>
216+
<phase>process-sources</phase>
217+
<goals>
218+
<goal>replace</goal>
219+
</goals>
220+
<configuration>
221+
<file>src/main/java/org/json/JSONParserConfiguration.java</file>
222+
<replacements>
223+
<replacement>
224+
<token>// this.strictMode = true;</token>
225+
<value>this.strictMode = true;</value>
226+
</replacement>
227+
</replacements>
228+
</configuration>
229+
</execution>
230+
<!-- Restore original code after tests -->
231+
<execution>
232+
<id>restore-original</id>
233+
<phase>test</phase>
234+
<goals>
235+
<goal>replace</goal>
236+
</goals>
237+
<configuration>
238+
<file>src/main/java/org/json/JSONParserConfiguration.java</file>
239+
<replacements>
240+
<replacement>
241+
<token>this.strictMode = true;</token>
242+
<value>// this.strictMode = true;</value>
243+
</replacement>
244+
</replacements>
245+
</configuration>
246+
</execution>
247+
</executions>
248+
</plugin>
249+
</plugins>
250+
</build>
251+
</profile>
252+
</profiles>
253+
203254
</project>

0 commit comments

Comments
 (0)
Please sign in to comment.