From 1fe888810f558c13752b043e4721c838404a0f7f Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Wed, 10 Aug 2022 11:04:50 +0200 Subject: add debug options for deliberately crashing --- .../asit/pdfover/gui/composites/ConfigurationComposite.java | 3 +++ .../pdfover/gui/workflow/config/ConfigurationManager.java | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java index 1f676951..703a9fad 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/ConfigurationComposite.java @@ -279,6 +279,9 @@ public class ConfigurationComposite extends StateComposite { * @param provider */ public void setConfigProvider(ConfigurationManager provider) { + if (provider.crashOnConfig) /* for testing initialization error handlers */ + throw new RuntimeException("A robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n(CRASH=config is set.)"); + this.configProvider = provider; if (this.configProvider != null) { for (ConfigurationCompositeBase c : composites()) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java index eda1e59f..d8c8320c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java @@ -69,6 +69,9 @@ public class ConfigurationManager { // The configuration overlay built from the cmd line args private ConfigurationDataInMemory configurationOverlay; + // whether the configuration screen should crash on startup (for debugging purposes) + public boolean crashOnConfig = false; + /** * Constructor */ @@ -124,6 +127,16 @@ public class ConfigurationManager { diskConfig.load(new FileInputStream(Constants.CONFIG_DIRECTORY + File.separator + getConfigurationFileName())); + { /* for testing of error handlers */ + String crashProperty = diskConfig.getProperty("CRASH"); + if ("startup".equalsIgnoreCase(crashProperty)) + throw new RuntimeException("A robot must obey the orders given it by human beings except where such orders would conflict with the First Law.\n(CRASH=startup is set.)"); + else if ("config".equalsIgnoreCase(crashProperty)) + this.crashOnConfig = true; + else if (crashProperty != null) + log.warn("Unknown value '{}' for CRASH property -- you want 'startup' or 'config'.", crashProperty); + } + setDefaultEmblemPersistent(diskConfig.getProperty(Constants.CFG_EMBLEM)); try { String strProp = diskConfig.getProperty(Constants.CFG_LOGO_ONLY_SIZE); -- cgit v1.2.3