Skip to content

Commit f7e835d

Browse files
committed
example: fix GUI tests
1 parent 3fe315b commit f7e835d

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

examples/pom.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,34 @@ limitations under the License.
129129
<plugin>
130130
<groupId>org.apache.maven.plugins</groupId>
131131
<artifactId>maven-surefire-plugin</artifactId>
132+
<!-- For some reason (probably due to the testing dependencies) surefire auto-detects a JUnit runner.
133+
Since we use testng exclusively, help the plugin a little bit -->
134+
<dependencies>
135+
<dependency>
136+
<groupId>org.apache.maven.surefire</groupId>
137+
<artifactId>surefire-testng</artifactId>
138+
<version>${surefire-plugin.version}</version>
139+
</dependency>
140+
</dependencies>
132141
<configuration>
133142
<systemPropertyVariables>
134-
<awt.toolkit>com.github.caciocavallosilano.cacio.ctc.CTCToolkit</awt.toolkit>
135-
<java.awt.graphicsenv>com.github.caciocavallosilano.cacio.ctc.CTCGraphicsEnvironment</java.awt.graphicsenv>
136143
<java.awt.headless>false</java.awt.headless>
137144
</systemPropertyVariables>
145+
<argLine>
146+
--add-exports=java.desktop/java.awt=ALL-UNNAMED
147+
--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED
148+
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED
149+
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED
150+
--add-exports=java.desktop/java.awt.dnd.peer=ALL-UNNAMED
151+
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
152+
--add-exports=java.desktop/sun.awt.event=ALL-UNNAMED
153+
--add-exports=java.desktop/sun.awt.datatransfer=ALL-UNNAMED
154+
--add-exports=java.base/sun.security.action=ALL-UNNAMED
155+
--add-opens=java.base/java.util=ALL-UNNAMED
156+
--add-opens=java.desktop/java.awt=ALL-UNNAMED
157+
--add-opens=java.desktop/sun.java2d=ALL-UNNAMED
158+
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
159+
</argLine>
138160
</configuration>
139161
</plugin>
140162
</plugins>

examples/src/test/java/net/automatalib/example/ExamplesTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import javax.swing.SwingUtilities;
2626

27+
import com.github.caciocavallosilano.cacio.ctc.junit.CacioExtension;
2728
import net.automatalib.example.ads.ADSExample;
2829
import net.automatalib.example.brics.SimpleBricsExample;
2930
import net.automatalib.example.dot.DOTExample;
@@ -51,6 +52,9 @@ public class ExamplesTest {
5152
@BeforeClass
5253
public void setupAutoClose() {
5354
if (isJVMCompatible()) {
55+
// hack: the static initializer of this class does the magic we want, so only invoke it on compatible JVMs
56+
new CacioExtension();
57+
5458
// As soon as we observe an event that indicates a new window, close it to prevent blocking the tests.
5559
Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
5660
final WindowEvent windowEvent = (WindowEvent) event;
@@ -151,12 +155,13 @@ public void testOneSEVPAExample() throws InvocationTargetException, InterruptedE
151155
}
152156

153157
private static boolean isJVMCompatible() {
154-
return Runtime.version().feature() == 11;
158+
final int feature = Runtime.version().feature();
159+
return feature == 17 || feature == 21;
155160
}
156161

157162
private static void requireJVMCompatibility() {
158163
if (!isJVMCompatible()) {
159-
throw new SkipException("The headless AWT environment currently only works with Java 11 or <=8");
164+
throw new SkipException("The headless AWT environment only works with specific JVM versions");
160165
}
161166
}
162167

visualization/dot-visualizer/pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ limitations under the License.
102102
<plugin>
103103
<groupId>org.apache.maven.plugins</groupId>
104104
<artifactId>maven-surefire-plugin</artifactId>
105-
<!-- For some reason (probably due to the testing dependencies) surefire auto-detects a JUnit runner.
106-
Since we use testng exclusively, help the plugin a little bit -->
107-
<dependencies>
108-
<dependency>
109-
<groupId>org.apache.maven.surefire</groupId>
110-
<artifactId>surefire-testng</artifactId>
111-
<version>${surefire-plugin.version}</version>
112-
</dependency>
113-
</dependencies>
114105
<executions>
115106
<execution>
116107
<id>default-test</id>

visualization/jung-visualizer/pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ limitations under the License.
143143
<plugin>
144144
<groupId>org.apache.maven.plugins</groupId>
145145
<artifactId>maven-surefire-plugin</artifactId>
146-
<!-- For some reason (probably due to the testing dependencies) surefire auto-detects a JUnit runner.
147-
Since we use testng exclusively, help the plugin a little bit -->
148-
<dependencies>
149-
<dependency>
150-
<groupId>org.apache.maven.surefire</groupId>
151-
<artifactId>surefire-testng</artifactId>
152-
<version>${surefire-plugin.version}</version>
153-
</dependency>
154-
</dependencies>
155146
<executions>
156147
<execution>
157148
<id>default-test</id>

visualization/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ limitations under the License.
4141
<plugin>
4242
<groupId>org.apache.maven.plugins</groupId>
4343
<artifactId>maven-surefire-plugin</artifactId>
44+
<!-- For some reason (probably due to the testing dependencies) surefire auto-detects a JUnit runner.
45+
Since we use testng exclusively, help the plugin a little bit -->
46+
<dependencies>
47+
<dependency>
48+
<groupId>org.apache.maven.surefire</groupId>
49+
<artifactId>surefire-testng</artifactId>
50+
<version>${surefire-plugin.version}</version>
51+
</dependency>
52+
</dependencies>
4453
<configuration>
4554
<systemPropertyVariables>
4655
<java.awt.headless>false</java.awt.headless>

0 commit comments

Comments
 (0)