M1-Fix: Exit-Code für ungültige Konfiguration auf 1 geändert
This commit is contained in:
@@ -19,7 +19,7 @@ import de.gecheckt.pdf.umbenenner.application.usecase.NoOpRunBatchProcessingUseC
|
||||
* <p>
|
||||
* AP-005: Integrates configuration loading via PropertiesConfigurationPortAdapter.
|
||||
* <p>
|
||||
* AP-006: Validates configuration before processing begins, returns exit code 2 on invalid config.
|
||||
* AP-006: Validates configuration before processing begins, returns exit code 1 on invalid config.
|
||||
*/
|
||||
public class BootstrapRunner {
|
||||
|
||||
@@ -97,7 +97,7 @@ public class BootstrapRunner {
|
||||
* AP-005: Wires ConfigurationPort adapter and passes it to the use case.
|
||||
* AP-006: Validates configuration before allowing processing to start.
|
||||
*
|
||||
* @return exit code: 0 for success, 1 for unexpected failure, 2 for invalid configuration
|
||||
* @return exit code: 0 for success, 1 for invalid configuration or unexpected failure
|
||||
*/
|
||||
public int run() {
|
||||
LOG.info("Bootstrap flow started.");
|
||||
@@ -129,12 +129,12 @@ public class BootstrapRunner {
|
||||
} catch (InvalidStartConfigurationException e) {
|
||||
// Controlled failure for invalid configuration - log clearly without stack trace
|
||||
LOG.error("Configuration validation failed: {}", e.getMessage());
|
||||
return 2;
|
||||
return 1;
|
||||
} catch (IllegalStateException e) {
|
||||
// Configuration loading failed due to missing/invalid required properties
|
||||
// Treat as invalid configuration for controlled failure
|
||||
LOG.error("Configuration loading failed: {}", e.getMessage());
|
||||
return 2;
|
||||
return 1;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Bootstrap failure during startup.", e);
|
||||
return 1;
|
||||
|
||||
@@ -46,7 +46,7 @@ class BootstrapRunnerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void run_returnsTwoOnInvalidConfiguration() throws Exception {
|
||||
void run_returnsOneOnInvalidConfiguration() throws Exception {
|
||||
// Create a mock configuration port that returns valid config
|
||||
ConfigurationPort mockConfigPort = new MockConfigurationPort(tempDir, true);
|
||||
|
||||
@@ -67,11 +67,11 @@ class BootstrapRunnerTest {
|
||||
|
||||
int exitCode = runner.run();
|
||||
|
||||
assertEquals(2, exitCode, "Invalid configuration should return exit code 2");
|
||||
assertEquals(1, exitCode, "Invalid configuration should return exit code 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void run_returnsTwoOnConfigurationLoadingFailure() {
|
||||
void run_returnsOneOnConfigurationLoadingFailure() {
|
||||
// Create a mock configuration port that throws IllegalStateException
|
||||
ConfigurationPort failingConfigPort = () -> {
|
||||
throw new IllegalStateException("Simulated configuration loading failure");
|
||||
@@ -86,7 +86,7 @@ class BootstrapRunnerTest {
|
||||
|
||||
int exitCode = runner.run();
|
||||
|
||||
assertEquals(2, exitCode, "Configuration loading failure should return exit code 2");
|
||||
assertEquals(1, exitCode, "Configuration loading failure should return exit code 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -156,11 +156,11 @@ class ExecutableJarSmokeTestIT {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalid-configuration smoke test: verifies controlled failure with exit code 2.
|
||||
* Invalid-configuration smoke test: verifies controlled failure with exit code 1.
|
||||
* <p>
|
||||
* Verifies:
|
||||
* - java -jar runs against invalid configuration
|
||||
* - Exit code is 2
|
||||
* - Exit code is 1
|
||||
* - Startup fails before any processing
|
||||
* - Failure is controlled (not a crash/hang)
|
||||
* - Error output indicates configuration validation failure
|
||||
@@ -260,7 +260,7 @@ class ExecutableJarSmokeTestIT {
|
||||
System.out.println("[SMOKE-TEST-INVALID] Exit code: " + exitCode);
|
||||
System.out.println("[SMOKE-TEST-INVALID] Subprocess stdout/stderr:\n" + outputText);
|
||||
|
||||
assertEquals(2, exitCode, "Invalid configuration should return exit code 2. Output was: " + outputText);
|
||||
assertEquals(1, exitCode, "Invalid configuration should return exit code 1. Output was: " + outputText);
|
||||
|
||||
// Verify error output indicates configuration failure
|
||||
assertTrue(
|
||||
|
||||
Reference in New Issue
Block a user