Skip to content

Commit

Permalink
Add log, cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 31, 2024
1 parent 30bc3fa commit 18adf44
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ tests: build-builder
--volume=$(PWD)/core/build/scripts/:/src/core/build/scripts/ \
--volume=$(PWD)/core/src/test/:/src/core/src/test/ \
mapfish_print_builder \
gradle --parallel --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \
gradle --no-parallel --exclude-task=:core:spotbugsMain --exclude-task=:core:checkstyleMain \
--exclude-task=:core:spotbugsTest --exclude-task=:core:checkstyleTest \
:core:test :core:testCli
--info :core:test :core:testCli

.PHONY: acceptance-tests-up
acceptance-tests-up: build .env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
import org.junit.Before;
import org.junit.Test;
import org.mapfish.print.AbstractMapfishSpringTest;
import org.mapfish.print.Constants;
import org.mapfish.print.config.access.AlwaysAllowAssertion;
import org.mapfish.print.servlet.ClusteredMapPrinterServletTest;
import org.mapfish.print.servlet.MapPrinterServlet;
import org.mapfish.print.servlet.job.impl.PrintJobEntryImpl;
import org.mapfish.print.servlet.job.impl.ThreadPoolJobManager;
import org.mapfish.print.wrapper.json.PJsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.context.SecurityContextHolder;
Expand All @@ -21,6 +24,8 @@
@ContextConfiguration(locations = {ClusteredMapPrinterServletTest.CLUSTERED_CONTEXT})
public class ClusteringTaskTest extends AbstractMapfishSpringTest {

private static final Logger LOGGER = LoggerFactory.getLogger(ClusteringTaskTest.class);

TestJobManager jobMan1;
TestJobManager jobMan2;
@Autowired private ApplicationContext context;
Expand All @@ -34,9 +39,26 @@ public void setup() {

@Test(timeout = 60000)
public void testRun() throws Exception {
LOGGER.error("Starting jobs");

PJsonObject requestData =
new PJsonObject(
new JSONObject("{\"" + MapPrinterServlet.JSON_APP + "\":\"default\"}"), "job");
new JSONObject(
"{"
// App
+ "\""
+ MapPrinterServlet.JSON_APP
+ "\": \"default\", "
// Output format
+ "\""
+ MapPrinterServlet.JSON_OUTPUT_FORMAT
+ "\": \"pdf\", "
// Layout
+ "\""
+ Constants.JSON_LAYOUT_KEY
+ "\": \"A4 Landscape\""
+ "}"),
"job");
jobMan1.submit(
new PrintJobEntryImpl(
"first job", requestData, System.currentTimeMillis(), new AlwaysAllowAssertion()));
Expand Down Expand Up @@ -66,6 +88,8 @@ public void testRun() throws Exception {
}
}

LOGGER.error("All jobs are done");

// verify each job was run only once
assertEquals(4, jobMan1.getJobsRun() + jobMan2.getJobsRun());

Expand All @@ -86,6 +110,7 @@ public TestJobManager(String name) {
}

protected PrintJob createJob(final PrintJobEntry entry) {
LOGGER.error("createJob on " + name);
PrintJob job =
new PrintJob() {
@Override
Expand All @@ -96,7 +121,7 @@ protected PrintJobResult createResult(

@Override
public PrintJobResult call() throws Exception {
System.out.println(getEntry().getReferenceId() + " is being run by jobman " + name);
LOGGER.error(getEntry().getReferenceId() + " is being run by jobman " + name);
jobsRun++;
return super.call();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.json.JSONObject;
import org.junit.Test;
import org.mapfish.print.AbstractMapfishSpringTest;
import org.mapfish.print.Constants;
import org.mapfish.print.config.Configuration;
import org.mapfish.print.config.Template;
import org.mapfish.print.processor.AbstractProcessor;
Expand Down Expand Up @@ -101,7 +102,22 @@ private class TestPrintJob extends PrintJob {
PrintJobEntryImpl entry = (PrintJobEntryImpl) getEntry();
entry.setRequestData(
new PJsonObject(
new JSONObject("{\"" + MapPrinterServlet.JSON_APP + "\":\"default\"}"), "job"));
new JSONObject(
"{"
// App
+ "\""
+ MapPrinterServlet.JSON_APP
+ "\": \"default\", "
// Output format
+ "\""
+ MapPrinterServlet.JSON_OUTPUT_FORMAT
+ "\": \"pdf\", "
// Layout
+ "\""
+ Constants.JSON_LAYOUT_KEY
+ "\": \"A4 Landscape\""
+ "}"),
"job"));
entry.setReferenceId("abc");
Template template = new Template();
Configuration configuration = new Configuration();
Expand Down

0 comments on commit 18adf44

Please sign in to comment.