From e37a66dfa8f872fc95d143791a6d1984110cdf21 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Mon, 23 Nov 2026 18:56:26 +0100 Subject: [PATCH 1/4] Start NeitzelLib 1.0.6-SNAPSHOT development --- core/pom.xml | 2 +- data-grid-jdbc/pom.xml | 2 +- data-grid/pom.xml | 2 +- encryption/pom.xml | 2 +- fx-example/README.md | 4 ++-- fx-example/docs/product-grid.md | 2 +- fx-example/docs/theme-gallery.md | 2 +- fx-example/pom.xml | 2 +- fx/pom.xml | 2 +- gson/pom.xml | 2 +- injection/pom.xml | 2 +- log4j/pom.xml | 2 +- net/pom.xml | 2 +- pom.xml | 2 +- quarkus/pom.xml | 2 +- 15 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 307056d..bb4ac37 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT core diff --git a/data-grid-jdbc/pom.xml b/data-grid-jdbc/pom.xml index 4dbba00..de2bf1e 100644 --- a/data-grid-jdbc/pom.xml +++ b/data-grid-jdbc/pom.xml @@ -1,5 +1,5 @@ -4.0.0de.neitzel.libneitzellib1.0.5 +4.0.0de.neitzel.libneitzellib1.0.6-SNAPSHOT data-grid-jdbcOptional mapped JDBC grid source de.neitzel.libdata-grid${project.version} com.h2databaseh22.5.252test diff --git a/data-grid/pom.xml b/data-grid/pom.xml index 3a5d9ba..4c2c32f 100644 --- a/data-grid/pom.xml +++ b/data-grid/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - de.neitzel.libneitzellib1.0.5 + de.neitzel.libneitzellib1.0.6-SNAPSHOT data-grid Toolkit-independent filter, query and grid setup contracts diff --git a/encryption/pom.xml b/encryption/pom.xml index f60cdab..4a4afb0 100644 --- a/encryption/pom.xml +++ b/encryption/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT encryption diff --git a/fx-example/README.md b/fx-example/README.md index 51d02fd..2a962d1 100644 --- a/fx-example/README.md +++ b/fx-example/README.md @@ -30,12 +30,12 @@ From the NeitzelLib root with JDK 25: ./mvnw -f fx-example/pom.xml javafx:run ``` -The first command installs local `1.0.5` artifacts; the second runs only the application module. Do not combine `javafx:run` with `-am`, since the parent has no JavaFX launcher. See the [quick start](../fx/docs/quick-start.md) for test reports. +The first command installs local `1.0.6-SNAPSHOT` artifacts; the second runs only the application module. Do not combine `javafx:run` with `-am`, since the parent has no JavaFX launcher. See the [quick start](../fx/docs/quick-start.md) for test reports. The packaged alternative, after `package` or `install`, is: ```bash -java -jar fx-example/target/fx-example-1.0.5.jar +java -jar fx-example/target/fx-example-1.0.6-SNAPSHOT.jar ``` Keep the adjacent `target/libs` directory with the JAR: the manifest refers to those copied runtime dependencies. A desktop session is required. This example has no `module-info.java`; it is a classpath application. diff --git a/fx-example/docs/product-grid.md b/fx-example/docs/product-grid.md index 96bd5d4..b71e767 100644 --- a/fx-example/docs/product-grid.md +++ b/fx-example/docs/product-grid.md @@ -6,7 +6,7 @@ From the repository root with JDK 25, build without installing runtime artifacts ```sh ./mvnw -pl fx-example -am package -DskipTests -java -cp 'fx-example/target/fx-example-1.0.5.jar:fx-example/target/libs/*' de.neitzel.fx.example.grid.ProductGridMain +java -cp 'fx-example/target/fx-example-1.0.6-SNAPSHOT.jar:fx-example/target/libs/*' de.neitzel.fx.example.grid.ProductGridMain ``` The default catalog has 10,000 products. Both backends use identical stable IDs, names, categories, quantities and DECIMAL(12,2) prices. Fixtures include duplicate sort values, nulls, empty text, mixed case, Unicode, apostrophes and literal SQL wildcard characters. One `ProductCatalog` service maintains original text and Locale.ROOT comparison keys together on insertion/reset. Mutations run on application workers and explicitly refresh the grid; browsing is read-only. diff --git a/fx-example/docs/theme-gallery.md b/fx-example/docs/theme-gallery.md index a12a31b..f4d6855 100644 --- a/fx-example/docs/theme-gallery.md +++ b/fx-example/docs/theme-gallery.md @@ -5,7 +5,7 @@ After the reactor `verify` or `package` build, from the repository root (no local artifact install required): ```sh -java -cp 'fx-example/target/fx-example-1.0.5.jar:fx-example/target/libs/*' \ +java -cp 'fx-example/target/fx-example-1.0.6-SNAPSHOT.jar:fx-example/target/libs/*' \ de.neitzel.fx.example.theme.ThemeGalleryMain ``` diff --git a/fx-example/pom.xml b/fx-example/pom.xml index 709eea5..aeebc60 100644 --- a/fx-example/pom.xml +++ b/fx-example/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT fx-example diff --git a/fx/pom.xml b/fx/pom.xml index a1d582e..26d0025 100644 --- a/fx/pom.xml +++ b/fx/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT fx diff --git a/gson/pom.xml b/gson/pom.xml index 6134d37..7db6c9b 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT gson diff --git a/injection/pom.xml b/injection/pom.xml index 29087b1..1e7ecdc 100644 --- a/injection/pom.xml +++ b/injection/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT injection diff --git a/log4j/pom.xml b/log4j/pom.xml index 43f72a1..082e7e3 100644 --- a/log4j/pom.xml +++ b/log4j/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT log4j diff --git a/net/pom.xml b/net/pom.xml index 6d896a5..24ea78f 100644 --- a/net/pom.xml +++ b/net/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT net diff --git a/pom.xml b/pom.xml index 4544c2f..0e337d7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT pom diff --git a/quarkus/pom.xml b/quarkus/pom.xml index e3f3e54..6690b05 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -7,7 +7,7 @@ de.neitzel.lib neitzellib - 1.0.5 + 1.0.6-SNAPSHOT quarkus From 7b3f98f4890b41257a6f78dd1469c673236e6e34 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Mon, 23 Nov 2026 19:01:29 +0100 Subject: [PATCH 2/4] Provide managed JavaFX fixtures for JUnit Jupiter --- README.md | 6 + fx-test/pom.xml | 37 +++++ .../java/de/neitzel/fx/test/FxExtension.java | 37 +++++ .../java/de/neitzel/fx/test/FxFixture.java | 140 ++++++++++++++++++ .../main/java/de/neitzel/fx/test/FxTest.java | 20 +++ .../de/neitzel/fx/test/FxFixtureTest.java | 57 +++++++ .../resources/de/neitzel/fx/test/name.fxml | 8 + pom.xml | 1 + 8 files changed, 306 insertions(+) create mode 100644 fx-test/pom.xml create mode 100644 fx-test/src/main/java/de/neitzel/fx/test/FxExtension.java create mode 100644 fx-test/src/main/java/de/neitzel/fx/test/FxFixture.java create mode 100644 fx-test/src/main/java/de/neitzel/fx/test/FxTest.java create mode 100644 fx-test/src/test/java/de/neitzel/fx/test/FxFixtureTest.java create mode 100644 fx-test/src/test/resources/de/neitzel/fx/test/name.fxml diff --git a/README.md b/README.md index ec5a637..cb830fb 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,12 @@ Optional mapped JDBC DataGrid source, initially qualified with H2. See [data-gri JavaFX docking, saved HTML/SingleFile viewing, standalone bars and optional MVVM bindings from FXML views to ordinary Java models. Docking works with plain JavaFX and standard FXMLLoader without initializing MVVM. See [fx/README.md](fx/README.md) and the [docking guide](fx/docs/docking.md). +### fx-test + +JavaFX fixtures for JUnit Jupiter. Add `de.neitzel.lib:fx-test` at the same version as `fx` with Maven scope `test`. Annotate the class with `@FxTest` and accept an `FxFixture` parameter in each test. Use `fx.run` for actions, `fx.call` for values and `fx.await("dialog closed", () -> !dialog.isShowing())` to wait from the test thread. `fx.load(fxml, model, services)` uses the production ViewLoader and a fresh ViewModelContext per test. + +The extension keeps JavaFX running between tests, isolates the class with JUnit's `@Isolated`, hides windows opened by each test, closes its view context and reports unhandled FX callbacks at teardown. Complete background work before the test ends. Select the backend in the test JVM before toolkit startup, for example `-Dglass.platform=Headless`. + ### injection Package scanner and type-based container used by `fx`. See [injection/README.md](injection/README.md). diff --git a/fx-test/pom.xml b/fx-test/pom.xml new file mode 100644 index 0000000..5106904 --- /dev/null +++ b/fx-test/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + de.neitzel.lib + neitzellib + 1.0.6-SNAPSHOT + + fx-test + + + de.neitzel.lib + fx + ${project.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + Headless + + + + + + diff --git a/fx-test/src/main/java/de/neitzel/fx/test/FxExtension.java b/fx-test/src/main/java/de/neitzel/fx/test/FxExtension.java new file mode 100644 index 0000000..4ee3c75 --- /dev/null +++ b/fx-test/src/main/java/de/neitzel/fx/test/FxExtension.java @@ -0,0 +1,37 @@ +package de.neitzel.fx.test; + +import java.lang.reflect.Method; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolver; + +final class FxExtension implements BeforeEachCallback, AfterEachCallback, ParameterResolver { + private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(FxExtension.class); + + @Override + public void beforeEach(ExtensionContext context) throws Exception { + var fixture = new FxFixture(); + fixture.start(); + context.getStore(NAMESPACE).put(FxFixture.class, fixture); + } + + @Override + public void afterEach(ExtensionContext context) throws Exception { + var fixture = context.getStore(NAMESPACE).remove(FxFixture.class, FxFixture.class); + if (fixture != null) fixture.finish(); + } + + @Override + public boolean supportsParameter(ParameterContext parameter, ExtensionContext context) { + return parameter.getParameter().getType() == FxFixture.class + && parameter.getDeclaringExecutable() instanceof Method + && context.getStore(NAMESPACE).get(FxFixture.class) != null; + } + + @Override + public Object resolveParameter(ParameterContext parameter, ExtensionContext context) { + return context.getStore(NAMESPACE).get(FxFixture.class, FxFixture.class); + } +} diff --git a/fx-test/src/main/java/de/neitzel/fx/test/FxFixture.java b/fx-test/src/main/java/de/neitzel/fx/test/FxFixture.java new file mode 100644 index 0000000..b76e88e --- /dev/null +++ b/fx-test/src/main/java/de/neitzel/fx/test/FxFixture.java @@ -0,0 +1,140 @@ +package de.neitzel.fx.test; + +import de.neitzel.fx.view.LoadedView; +import de.neitzel.fx.view.ViewLoader; +import de.neitzel.fx.view.ViewModelContext; +import de.neitzel.injection.ApplicationContext; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.function.BooleanSupplier; +import javafx.application.Platform; +import javafx.stage.Window; + +/** JavaFX test operations scoped to one JUnit test. Obtain the fixture through {@link FxTest}. */ +public final class FxFixture { + private static final long TIMEOUT_SECONDS = 10; + + private final ViewModelContext models = new ViewModelContext(); + private final List callbackFailures = new ArrayList<>(); + private List previousWindows; + private Thread.UncaughtExceptionHandler previousHandler; + + /** An FX-thread action that may propagate a checked exception. */ + @FunctionalInterface + public interface Action { + /** + * Performs the action. + * @throws Exception on failure + */ + void run() throws Exception; + } + + FxFixture() {} + + void start() throws Exception { + try { + Platform.startup(() -> {}); + } catch (IllegalStateException alreadyStarted) { + // A previous test or another JavaFX client has started this JVM's toolkit. + } + run(() -> { + Platform.setImplicitExit(false); + previousWindows = List.copyOf(Window.getWindows()); + previousHandler = Thread.currentThread().getUncaughtExceptionHandler(); + Thread.currentThread().setUncaughtExceptionHandler((thread, error) -> callbackFailures.add(error)); + }); + } + + /** + * Runs an action on the FX thread and propagates its failure to the test. + * @param action test action + * @throws Exception if the action fails or the wait is interrupted or times out + */ + public void run(Action action) throws Exception { + call(() -> { + action.run(); + return null; + }); + } + + /** + * Returns the result of an FX-thread operation, with a bounded wait on the calling thread. + * @param result type + * @param action operation to perform + * @return the value returned by the operation + * @throws Exception if the operation fails or the wait is interrupted or times out + */ + public T call(Callable action) throws Exception { + if (Platform.isFxApplicationThread()) return action.call(); + var task = new FutureTask<>(action); + Platform.runLater(task); + try { + return task.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (ExecutionException failure) { + if (failure.getCause() instanceof Exception exception) throw exception; + if (failure.getCause() instanceof Error error) throw error; + throw new AssertionError(failure.getCause()); + } catch (TimeoutException | InterruptedException failure) { + task.cancel(false); + throw failure; + } + } + + /** + * Waits on the test thread while evaluating the named condition on the FX thread. + * @param description expected state, included in the timeout message + * @param condition UI predicate to evaluate + * @throws Exception if evaluation fails or waiting is interrupted + * @throws AssertionError if the condition stays false + */ + public void await(String description, BooleanSupplier condition) throws Exception { + if (Platform.isFxApplicationThread()) throw new IllegalStateException("await requires the test thread"); + long start = System.nanoTime(); + while (!call(condition::getAsBoolean)) { + if (System.nanoTime() - start >= TimeUnit.SECONDS.toNanos(TIMEOUT_SECONDS)) { + throw new AssertionError("Timed out waiting for " + description); + } + Thread.sleep(15); + } + } + + /** + * Loads production FXML on the FX thread in the test's automatically closed model context. + * @param fxml view resource + * @param model model for the view + * @param services controller and service container + * @return managed view + * @throws Exception if the view cannot be loaded or the wait is interrupted or times out + */ + public LoadedView load(URL fxml, Object model, ApplicationContext services) throws Exception { + return call(() -> ViewLoader.load(fxml, model, services, models)); + } + + void finish() throws Exception { + run(() -> { + try { + for (var window : List.copyOf(Window.getWindows()).reversed()) { + if (!previousWindows.contains(window)) window.hide(); + } + } finally { + try { + models.close(); + } finally { + Thread.currentThread().setUncaughtExceptionHandler(previousHandler); + } + } + if (!callbackFailures.isEmpty()) { + var failure = new AssertionError("Unhandled exception on the JavaFX application thread", + callbackFailures.getFirst()); + callbackFailures.stream().skip(1).forEach(failure::addSuppressed); + throw failure; + } + }); + } +} diff --git a/fx-test/src/main/java/de/neitzel/fx/test/FxTest.java b/fx-test/src/main/java/de/neitzel/fx/test/FxTest.java new file mode 100644 index 0000000..7f3a8d4 --- /dev/null +++ b/fx-test/src/main/java/de/neitzel/fx/test/FxTest.java @@ -0,0 +1,20 @@ +package de.neitzel.fx.test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.api.parallel.Isolated; + +/** Runs a JavaFX test class in isolation and supplies an FxFixture to each test method. */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +@Isolated +@Execution(ExecutionMode.SAME_THREAD) +@ExtendWith(FxExtension.class) +public @interface FxTest {} diff --git a/fx-test/src/test/java/de/neitzel/fx/test/FxFixtureTest.java b/fx-test/src/test/java/de/neitzel/fx/test/FxFixtureTest.java new file mode 100644 index 0000000..856b013 --- /dev/null +++ b/fx-test/src/test/java/de/neitzel/fx/test/FxFixtureTest.java @@ -0,0 +1,57 @@ +package de.neitzel.fx.test; + +import de.neitzel.injection.ApplicationContext; +import java.io.IOException; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.TextField; +import javafx.stage.Stage; +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +@FxTest +public class FxFixtureTest { + @Getter @Setter + public static class Person { + private String name = "Ada"; + } + + @Test + void teardownDetachesLoadedViewsAndReportsUnhandledCallbacks(FxFixture fx) throws Exception { + var person = new Person(); + var nested = new FxFixture(); + var problem = new IllegalStateException("callback failed"); + nested.start(); + var view = nested.load(getClass().getResource("name.fxml"), person, new ApplicationContext(Person.class)); + var field = nested.call(() -> (TextField) view.getRoot()); + var stage = nested.call(() -> { + assertEquals("Ada", field.getText()); + field.setText("Lin"); + assertEquals("Lin", person.getName()); + var window = new Stage(); + window.setScene(new Scene(field)); + window.show(); + return window; + }); + nested.run(() -> Platform.runLater(() -> { throw problem; })); + assertSame(problem, assertThrows(AssertionError.class, nested::finish).getCause()); + + fx.run(() -> { + assertFalse(stage.isShowing()); + field.setText("Detached"); + assertEquals("Lin", person.getName()); + }); + } + + @Test + void nestedCallsPropagateTheOriginalFailureAndCannotBlockTheFxThread(FxFixture fx) throws Exception { + var problem = new IOException("failed"); + assertSame(problem, assertThrows(IOException.class, () -> fx.run(() -> { + assertTrue(fx.call(Platform::isFxApplicationThread)); + assertThrows(IllegalStateException.class, () -> fx.await("next pulse", () -> false)); + throw problem; + }))); + } +} diff --git a/fx-test/src/test/resources/de/neitzel/fx/test/name.fxml b/fx-test/src/test/resources/de/neitzel/fx/test/name.fxml new file mode 100644 index 0000000..4d492b9 --- /dev/null +++ b/fx-test/src/test/resources/de/neitzel/fx/test/name.fxml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml index 0e337d7..547b4eb 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ data-grid data-grid-jdbc fx + fx-test fx-example gson net From d8b2871f244a6a23592ff8bca44d278e06085be8 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Mon, 23 Nov 2026 19:11:01 +0100 Subject: [PATCH 3/4] Centralize Maven dependency and plugin versions --- core/pom.xml | 5 ++++- data-grid-jdbc/pom.xml | 2 +- encryption/pom.xml | 5 ++++- fx-example/pom.xml | 14 ++++++++++---- fx/pom.xml | 11 ++++++++--- gson/pom.xml | 2 ++ log4j/pom.xml | 2 ++ pom.xml | 25 +++++++++++++------------ quarkus/pom.xml | 1 + 9 files changed, 45 insertions(+), 22 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index bb4ac37..0838395 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -18,13 +18,16 @@ ${project.artifactId} ${project.artifactId} ${project.artifactId}-${project.version} + + + 5.19.1 net.java.dev.jna jna - 5.19.1 + ${jna.version} org.reflections diff --git a/data-grid-jdbc/pom.xml b/data-grid-jdbc/pom.xml index de2bf1e..e3e33a5 100644 --- a/data-grid-jdbc/pom.xml +++ b/data-grid-jdbc/pom.xml @@ -2,4 +2,4 @@ 4.0.0de.neitzel.libneitzellib1.0.6-SNAPSHOT data-grid-jdbcOptional mapped JDBC grid source de.neitzel.libdata-grid${project.version} -com.h2databaseh22.5.252test +com.h2databaseh2${h2.version}test diff --git a/encryption/pom.xml b/encryption/pom.xml index 4a4afb0..2bb3d5e 100644 --- a/encryption/pom.xml +++ b/encryption/pom.xml @@ -18,13 +18,16 @@ ${project.artifactId} ${project.artifactId} ${project.artifactId}-${project.version} + + + 1.0.0 com.idealista format-preserving-encryption - 1.0.0 + ${format-preserving-encryption.version} diff --git a/fx-example/pom.xml b/fx-example/pom.xml index aeebc60..f1b0b8a 100644 --- a/fx-example/pom.xml +++ b/fx-example/pom.xml @@ -18,11 +18,17 @@ ${project.artifactId} de.neitzel.fx.example.Main ${project.artifactId}-${project.version} + + + 0.1.0-SNAPSHOT + + + 3.8.0 de.neitzel.libdata-grid-jdbc${project.version} - com.h2databaseh22.5.252 + com.h2databaseh2${h2.version} de.neitzel.lib fx @@ -103,7 +109,7 @@ de.neitzel.fxdesigner designer-preview-api - 0.1.0-SNAPSHOT + ${designer.version} test @@ -112,7 +118,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.8.0 + ${build.helper.maven.plugin} designer-preview-sources @@ -139,7 +145,7 @@ de.neitzel.fxdesigner designer-model-processor - 0.1.0-SNAPSHOT + ${designer.version} diff --git a/fx/pom.xml b/fx/pom.xml index 26d0025..06077ba 100644 --- a/fx/pom.xml +++ b/fx/pom.xml @@ -18,6 +18,11 @@ ${project.artifactId} ${project.artifactId} ${project.artifactId}-${project.version} + + + 3.15.3 + 1.23.2 + 8.2.3 @@ -47,17 +52,17 @@ org.jsoup jsoup - 1.23.2 + ${jsoup.version} com.helger ph-css - 8.2.3 + ${ph-css.version} com.twelvemonkeys.imageio imageio-webp - 3.15.3 + ${imageio-webp.version} diff --git a/gson/pom.xml b/gson/pom.xml index 7db6c9b..ce1ecc2 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -20,6 +20,8 @@ ${project.artifactId}-${project.version} + + 2.15.0 diff --git a/log4j/pom.xml b/log4j/pom.xml index 082e7e3..d24732f 100644 --- a/log4j/pom.xml +++ b/log4j/pom.xml @@ -20,6 +20,8 @@ ${project.artifactId}-${project.version} + + 1.2.17 diff --git a/pom.xml b/pom.xml index 0e337d7..b8d40ee 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,16 @@ 25 3.9.11 + + pmd + spotbugs + UTF-8 + ${java.version} + ${java.version} + ${java.version} + + 2.5.252 2.0.1 27.0.1 26.1.0 @@ -45,10 +54,11 @@ 0.10.2 2.0.20 - + 2.25.2 0.0.8 0.1.5 + 1.18.20.0 3.5.0 3.16.0 3.11.0 @@ -57,23 +67,14 @@ 3.2.0 3.5.1 3.12.0 + 3.28.0 3.9.0 3.5.0 3.5.3 4.0.0-M16 3.6.1 1.0.0.RC2 - 3.28.0 4.10.5.0 - - - pmd - spotbugs - UTF-8 - ${java.version} - ${java.version} - ${java.version} - @@ -280,7 +281,7 @@ org.projectlombok lombok-maven-plugin - 1.18.20.0 + ${lombok.maven.plugin} org.projectlombok diff --git a/quarkus/pom.xml b/quarkus/pom.xml index 6690b05..9e30aac 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -19,6 +19,7 @@ ${project.artifactId} ${project.artifactId}-${project.version} + 3.40.1.2 From f1b2fd24d4b30b92585afba76cefaa19722371f9 Mon Sep 17 00:00:00 2001 From: Konrad Neitzel Date: Mon, 23 Nov 2026 19:16:45 +0100 Subject: [PATCH 4/4] Test docking activation independently of desktop focus arbitration Glass Headless can report both stages focused. On macOS the desktop can deny the input needed to establish the initial focus. Drive both reported window states explicitly with a Stage spy so the real manager must distinguish NoChange from Applied and request focus. --- .../fx/view/ActivateDockingWindowTest.java | 108 +++--------------- 1 file changed, 18 insertions(+), 90 deletions(-) diff --git a/fx/src/test/java/de/neitzel/fx/view/ActivateDockingWindowTest.java b/fx/src/test/java/de/neitzel/fx/view/ActivateDockingWindowTest.java index 8d2ee22..128cdfb 100644 --- a/fx/src/test/java/de/neitzel/fx/view/ActivateDockingWindowTest.java +++ b/fx/src/test/java/de/neitzel/fx/view/ActivateDockingWindowTest.java @@ -9,125 +9,53 @@ import de.neitzel.fx.docking.Dockable; import de.neitzel.fx.docking.DockableId; import de.neitzel.fx.docking.DockingManager; import de.neitzel.fx.docking.DockingOptions; -import javafx.animation.AnimationTimer; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.geometry.Bounds; import javafx.scene.Scene; import javafx.scene.control.TextArea; -import javafx.scene.input.MouseButton; -import javafx.scene.robot.Robot; import javafx.stage.Stage; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.clearInvocations; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; /** Activating a background window is an applied action even when its selected tab stays the same. */ class ActivateDockingWindowTest { @BeforeAll static void startJavaFx() throws Exception { FxThread.start(); - FxThread.onFx(() -> Platform.setImplicitExit(false)); } @Test void activatingTheSameContentInABackgroundWindowReportsApplied() throws Exception { - AtomicReference state = new AtomicReference<>(); FxThread.onFx(() -> { DockLayout initial = new DockLayout(); initial.setCenter(new DockGroupDefinition("editors")); DockPane pane = new DockPane(); pane.setInitialLayout(initial); - Stage main = new Stage(); + Stage main = spy(new Stage()); main.setScene(new Scene(pane, 480, 280)); DockingManager manager = DockingManager.attach(main, pane, new DockingOptions()); TextArea editor = new TextArea("Unsaved text"); Dockable dockable = new Dockable(new DockableId("notes"), editor); manager.open(dockable, DockTarget.area("editors")); - Stage other = new Stage(); - other.setScene(new Scene(new TextArea("Other window"), 240, 160)); - state.set(new Fixture(main, other, manager, dockable)); - main.show(); + + // Only the desktop's window state is simulated. Selection, scene focus and + // the activation result all come from the real controls and manager. + doReturn(true).when(main).isShowing(); + doReturn(true).when(main).isFocused(); manager.activate(dockable.getId()); + assertSame(dockable, manager.activeDockable()); + assertSame(editor, main.getScene().getFocusOwner()); + assertInstanceOf(ActionResult.NoChange.class, manager.activate(dockable.getId())); + + doReturn(false).when(main).isFocused(); + clearInvocations(main); + assertInstanceOf(ActionResult.Applied.class, manager.activate(dockable.getId())); + verify(main).requestFocus(); }); - Fixture fixture = state.get(); - try { - focus(fixture.main()); - FxThread.onFx(() -> fixture.other().show()); - focus(fixture.other()); - FxThread.onFx(() -> { - assertFalse(fixture.main().isFocused()); - assertSame(fixture.dockable(), fixture.manager().activeDockable()); - assertSame(fixture.dockable().getContent(), fixture.main().getScene().getFocusOwner()); - assertInstanceOf(ActionResult.Applied.class, fixture.manager().activate(fixture.dockable().getId())); - }); - } finally { - FxThread.onFx(() -> { - fixture.other().hide(); - fixture.main().hide(); - }); - } } - - private static void focus(Stage stage) throws Exception { - CountDownLatch focused = new CountDownLatch(1); - ChangeListener listener = (observable, old, current) -> { - if (current) focused.countDown(); - }; - AnimationTimer clickAfterDisplay = new AnimationTimer() { - private int pulses; - private long lastClick; - - @Override - public void handle(long now) { - if (stage.isFocused()) { - focused.countDown(); - stop(); - return; - } - if (++pulses < 2) return; - if (now - lastClick < 250_000_000) return; - lastClick = now; - Bounds bounds = stage.getScene().getRoot().localToScreen( - stage.getScene().getRoot().getBoundsInLocal()); - Robot robot = new Robot(); - robot.mouseMove(bounds.getCenterX(), bounds.getCenterY()); - robot.mouseClick(MouseButton.PRIMARY); - if (stage.isFocused()) focused.countDown(); - } - }; - FxThread.onFx(() -> { - stage.focusedProperty().addListener(listener); - stage.setAlwaysOnTop(true); - stage.toFront(); - stage.requestFocus(); - stage.getScene().getRoot().applyCss(); - stage.getScene().getRoot().layout(); - clickAfterDisplay.start(); - }); - try { - // A native click activates the application even if the previous test or - // another application owned desktop focus. RequestFocus alone cannot - // establish that precondition reliably on macOS. FX pulses do not - // guarantee that the native compositor has displayed the window; - // retry only this focus precondition within the bounded wait. - assertTrue(focused.await(5, TimeUnit.SECONDS), "Desktop did not focus the requested window"); - } finally { - FxThread.onFx(() -> { - clickAfterDisplay.stop(); - stage.focusedProperty().removeListener(listener); - stage.setAlwaysOnTop(false); - }); - } - } - - private record Fixture(Stage main, Stage other, DockingManager manager, Dockable dockable) { } }