From 30bc3fad7a729bfde020c2c58eab96b33b9dc99a Mon Sep 17 00:00:00 2001 From: sebr72 Date: Wed, 30 Oct 2024 19:33:13 +0100 Subject: [PATCH] Enabled cluster test --- .../mapfish/print/servlet/job/PrintJob.java | 2 +- .../print/servlet/job/ClusteringTaskTest.java | 23 +++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java b/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java index 33c1f6f42c..7d2564736d 100644 --- a/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java +++ b/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java @@ -126,7 +126,7 @@ protected abstract PrintJobResult createResult( throws URISyntaxException, IOException; @Override - public final PrintJobResult call() throws Exception { + public PrintJobResult call() throws Exception { SecurityContextHolder.setContext(this.securityContext); final Timer.Context timer = this.metricRegistry diff --git a/core/src/test/java/org/mapfish/print/servlet/job/ClusteringTaskTest.java b/core/src/test/java/org/mapfish/print/servlet/job/ClusteringTaskTest.java index cdfdae2eac..6ba014c182 100644 --- a/core/src/test/java/org/mapfish/print/servlet/job/ClusteringTaskTest.java +++ b/core/src/test/java/org/mapfish/print/servlet/job/ClusteringTaskTest.java @@ -3,14 +3,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.util.HashMap; import org.json.JSONObject; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mapfish.print.AbstractMapfishSpringTest; import org.mapfish.print.config.access.AlwaysAllowAssertion; -import org.mapfish.print.processor.AbstractProcessor; import org.mapfish.print.servlet.ClusteredMapPrinterServletTest; import org.mapfish.print.servlet.MapPrinterServlet; import org.mapfish.print.servlet.job.impl.PrintJobEntryImpl; @@ -22,7 +19,6 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration(locations = {ClusteredMapPrinterServletTest.CLUSTERED_CONTEXT}) -@Ignore // db must be set up to run this test public class ClusteringTaskTest extends AbstractMapfishSpringTest { TestJobManager jobMan1; @@ -79,8 +75,7 @@ public void testRun() throws Exception { } private class TestJobManager extends ThreadPoolJobManager { - private String name; - + private final String name; private int jobsRun; public TestJobManager(String name) { @@ -94,18 +89,16 @@ protected PrintJob createJob(final PrintJobEntry entry) { PrintJob job = new PrintJob() { @Override - protected PrintResult withOpenOutputStream(PrintAction function) throws Exception { - System.out.println(getEntry().getReferenceId() + " is being run by jobman " + name); - TestJobManager.this.jobsRun++; - Thread.sleep(1000); - return new PrintResult( - 42, new AbstractProcessor.Context(new HashMap())); + protected PrintJobResult createResult( + String fileName, String fileExtension, String mimeType) { + return null; } @Override - protected PrintJobResult createResult( - final String fileName, final String fileExtension, final String mimeType) { - return null; + public PrintJobResult call() throws Exception { + System.out.println(getEntry().getReferenceId() + " is being run by jobman " + name); + jobsRun++; + return super.call(); } }; job.initForTesting(ClusteringTaskTest.this.context);