From 5c928ae5e9a892996fe66f80219a43dd339b42b6 Mon Sep 17 00:00:00 2001 From: Vasili Gulevich Date: Sun, 22 Oct 2023 10:53:01 +0400 Subject: [PATCH] Fix UnsupportedOperationException (#2938) OfflineModeTest fails with UnsupportedOperationException as HttpServer no longer allows direct access to access logs. Change OfflineModeTest to dedicated and limited mutation API for access logs. --- .../eclipse/tycho/test/target/OfflineModeTest.java | 2 +- .../java/org/eclipse/tycho/test/util/HttpServer.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/target/OfflineModeTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/target/OfflineModeTest.java index cade4b8e20..7bdf1ea364 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/target/OfflineModeTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/target/OfflineModeTest.java @@ -92,7 +92,7 @@ private void runAndVerifyOnlineBuild(Verifier verifier) throws VerificationExcep verifier.executeGoal("integration-test"); verifier.verifyErrorFreeLog(); assertFalse(server.getAccessedUrls("test").isEmpty()); - server.getAccessedUrls("test").clear(); + server.clear(); } } diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java b/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java index a67fedffa3..175305c15d 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java @@ -203,6 +203,17 @@ public List getAccessedUrls(String contextName) { } } + /** + * Reset state. + * + * Clear access logs. Does not affect configuration. + **/ + public void clear() { + synchronized (contextName2accessedUrls) { + contextName2accessedUrls.clear(); + } + } + private void registerContext(ServletContextHandler context) { context.addFilter(new FilterHolder(new Monitoring()), "*", EnumSet.of(DispatcherType.REQUEST)); contexts.addHandler(context);