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