This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new fd721738ac GROOVY-11876: add test case
fd721738ac is described below
commit fd721738ac8b1680adf4c47303d329d86876c7d0
Author: Eric Milles <[email protected]>
AuthorDate: Sat Mar 21 09:55:28 2026 -0500
GROOVY-11876: add test case
---
.../groovy/swing/beans/BindableSwingTest.groovy | 64 ++++++++++++++++++----
.../groovy/swing/beans/VetoableSwingTest.groovy | 32 ++++++-----
2 files changed, 71 insertions(+), 25 deletions(-)
diff --git
a/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/BindableSwingTest.groovy
b/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/BindableSwingTest.groovy
index fbaac00fb1..dbe8579107 100644
---
a/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/BindableSwingTest.groovy
+++
b/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/BindableSwingTest.groovy
@@ -18,28 +18,68 @@
*/
package groovy.swing.beans
+import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
-import static groovy.swing.GroovySwingTestCase.testInEDT
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.util.HeadlessTestSupport.isHeadless
+import static org.junit.jupiter.api.Assumptions.assumeFalse
final class BindableSwingTest {
+ @BeforeEach
+ void setUp() {
+ assumeFalse(isHeadless())
+ }
+
// GROOVY-8339, GROOVY-10070
@Test
void testExtendsComponent() {
- testInEDT {
- new GroovyShell().evaluate '''
- class BindableTestBean extends javax.swing.JPanel {
- @groovy.beans.Bindable String testValue
+ assertScript '''
+ class BindableTestBean extends javax.swing.JPanel {
+ @groovy.beans.Bindable String testValue
+ }
+
+ changed = false
+
+ def bean = new BindableTestBean(testValue: 'foo')
+ bean.propertyChange = {changed = true}
+ bean.testValue = 'bar'
+ assert changed
+ '''
+ }
+
+ // GROOVY-11876
+ @Test
+ void testBindableProperties() {
+ assertScript '''
+ import groovy.beans.Bindable
+ import groovy.swing.SwingBuilder
+
+ class Main {
+ @Bindable
+ static class Bean {
+ String foo = 'bar'
}
- changed = false
+ static def bean1 = new Bean()
+ static Bean bean2 = new Bean()
+
+ static main(args) {
+ new SwingBuilder().edt {
+ def label1 = label(text: bind { bean1.foo })
+ def label2 = label(text: bind { bean2.foo })
- def bean = new BindableTestBean(testValue: 'foo')
- bean.propertyChange = {changed = true}
- bean.testValue = 'bar'
- assert changed
- '''
- }
+ assert label1.text == 'bar'
+ bean1.foo = 'baz'
+ assert label1.text == 'baz'
+
+ assert label2.text == 'bar'
+ bean2.foo = 'baz'
+ assert label2.text == 'baz'
+ }
+ }
+ }
+ '''
}
}
diff --git
a/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/VetoableSwingTest.groovy
b/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/VetoableSwingTest.groovy
index 73a11c90eb..0e57201b8a 100644
---
a/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/VetoableSwingTest.groovy
+++
b/subprojects/groovy-swing/src/test/groovy/groovy/swing/beans/VetoableSwingTest.groovy
@@ -18,28 +18,34 @@
*/
package groovy.swing.beans
+import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
-import static groovy.swing.GroovySwingTestCase.testInEDT
+import static groovy.test.GroovyAssert.assertScript
+import static groovy.util.HeadlessTestSupport.isHeadless
+import static org.junit.jupiter.api.Assumptions.assumeFalse
final class VetoableSwingTest {
+ @BeforeEach
+ void setUp() {
+ assumeFalse(isHeadless())
+ }
+
// GROOVY-8339, GROOVY-10070
@Test
void testExtendsComponent() {
- testInEDT {
- new GroovyShell().evaluate '''
- class VetoableTestBean extends javax.swing.JPanel {
- @groovy.beans.Vetoable String testValue
- }
+ assertScript '''
+ class VetoableTestBean extends javax.swing.JPanel {
+ @groovy.beans.Vetoable String testValue
+ }
- changed = false
+ changed = false
- def bean = new VetoableTestBean(testValue: 'foo')
- bean.vetoableChange = {changed = true}
- bean.testValue = 'bar'
- assert changed
- '''
- }
+ def bean = new VetoableTestBean(testValue: 'foo')
+ bean.vetoableChange = {changed = true}
+ bean.testValue = 'bar'
+ assert changed
+ '''
}
}