stokpop commented on a change in pull request #696:
URL: https://github.com/apache/jmeter/pull/696#discussion_r793042901
##########
File path:
src/core/src/test/java/org/apache/jmeter/gui/util/JSyntaxTextAreaTest.java
##########
@@ -41,7 +45,37 @@ public void testSetLanguage() {
textArea.setLanguage(null);
assertEquals(SyntaxConstants.SYNTAX_STYLE_NONE,
textArea.getSyntaxEditingStyle());
} catch (HeadlessException he) {
- // Does not work in headless mode
+ // Does not work in headless mode, which depends on value of
java.awt.headless property
+ // and the OS (e.g. might work on MacOS and not on Linux due to
missing X11).
+ System.out.println("WARNING for
JSyntaxTextAreaTest.testSetLanguage test: does not work in headless mode");
+ }
+ }
+
+ @Test
+ public void testHeadless() {
+ String key = "java.awt.headless";
+ String initialValue = System.getProperty(key);
+ try {
+ System.setProperty(key, "true");
+ // getInstance returns anonymous class with some overridden methods
+ // to avoid errors due to 'java.awt.headless=true'
+ JSyntaxTextArea textArea = JSyntaxTextArea.getInstance(10,20);
+
+ String myText = "my text";
+ textArea.setText(myText);
+ // next one fails with NPE when getInstance does not provide
overridden method
+ textArea.setCodeFoldingEnabled(true);
+ assertEquals(myText, textArea.getText());
+
+ } catch (HeadlessException he) {
+ fail("WARNING: Does not work in headless mode");
Review comment:
The exception is not expected here, because the explicit
`java.awt.headless=true`, so the fail. This is indeed different from the other
test, that seems to allow the HeadlessException by ignoring it. I can change
fail text.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]