Skip to content
Snippets Groups Projects
Commit de2c02b0 authored by Lukas Malte Monnerjahn's avatar Lukas Malte Monnerjahn
Browse files

exit the xta-adapter by calling exit in a dedicated XtaApplication class

closing the ApplicationContext during event handling leads to an IllegalStateException
parent b8f41606
No related branches found
No related tags found
1 merge request!2OZG-7491 pipeline: Change version format
Pipeline #1630 passed
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration> <configuration>
<mainClass>de.ozgcloud.eingang.Application</mainClass> <mainClass>de.ozgcloud.eingang.xta.XtaApplication</mainClass>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
......
package de.ozgcloud.eingang.xta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;
@Service
class ShutdownService {
@Autowired
private ConfigurableApplicationContext context;
public void shutdown() {
context.close();
}
}
/*
* Copyright (C) 2025 Das Land Schleswig-Holstein vertreten durch den
* Ministerpräsidenten des Landes Schleswig-Holstein
* Staatskanzlei
* Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
*
* Lizenziert unter der EUPL, Version 1.2 oder - sobald
* diese von der Europäischen Kommission genehmigt wurden -
* Folgeversionen der EUPL ("Lizenz");
* Sie dürfen dieses Werk ausschließlich gemäß
* dieser Lizenz nutzen.
* Eine Kopie der Lizenz finden Sie hier:
*
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* Sofern nicht durch anwendbare Rechtsvorschriften
* gefordert oder in schriftlicher Form vereinbart, wird
* die unter der Lizenz verbreitete Software "so wie sie
* ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
* ausdrücklich oder stillschweigend - verbreitet.
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
package de.ozgcloud.eingang.xta;
import java.util.TimeZone;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import de.ozgcloud.eingang.Application;
@SpringBootApplication(scanBasePackages = { "de.ozgcloud" })
@EnableScheduling
public class XtaApplication extends Application {
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
var appContext = SpringApplication.run(XtaApplication.class, args);
SpringApplication.exit(appContext);
}
}
...@@ -41,13 +41,12 @@ class XtaRunner implements ApplicationListener<ContextRefreshedEvent> { ...@@ -41,13 +41,12 @@ class XtaRunner implements ApplicationListener<ContextRefreshedEvent> {
private XtaService service; private XtaService service;
@Autowired @Autowired
private SemantikAdapter semantikAdapter; private SemantikAdapter semantikAdapter;
@Autowired
private ShutdownService shutdownService;
@Override @Override
public void onApplicationEvent(ContextRefreshedEvent event) { public void onApplicationEvent(ContextRefreshedEvent event) {
LOG.info("Fetching XTA Messages"); LOG.info("Fetching XTA Messages");
runGetXtaMessages(); runGetXtaMessages();
shutdownService.shutdown(); // shutdownService.shutdown();
} }
void runGetXtaMessages() { void runGetXtaMessages() {
......
...@@ -49,9 +49,6 @@ class SemantikAdapterITCase { ...@@ -49,9 +49,6 @@ class SemantikAdapterITCase {
@MockitoBean @MockitoBean
private VorgangService vorgangService; private VorgangService vorgangService;
@MockitoBean
private ShutdownService shutdownService;
@Nested @Nested
class TestForFim { class TestForFim {
private final Map<String, Object> excpectedFormDataMap = FimFormDataTestFactory.FORM_DATA_MAP; private final Map<String, Object> excpectedFormDataMap = FimFormDataTestFactory.FORM_DATA_MAP;
......
...@@ -28,17 +28,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; ...@@ -28,17 +28,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import de.ozgcloud.eingang.Application;
@ActiveProfiles({ "local", "itcase" }) @ActiveProfiles({ "local", "itcase" })
@SpringBootTest(classes = Application.class) @SpringBootTest(classes = XtaApplication.class)
class XtaApplicationTest { class XtaApplicationTest {
@MockitoBean
private ShutdownService shutdownService;
@Test @Test
void startup() { void startup() {
// should start without exception // should start without exception
......
...@@ -85,8 +85,6 @@ class XtaITCase { ...@@ -85,8 +85,6 @@ class XtaITCase {
@MockitoBean @MockitoBean
private XtaRemoteService xtaRemoteService; private XtaRemoteService xtaRemoteService;
@MockitoBean
private ShutdownService shutdownService;
@Captor @Captor
private ArgumentCaptor<FormData> formDataArgumentCaptor; private ArgumentCaptor<FormData> formDataArgumentCaptor;
...@@ -116,11 +114,6 @@ class XtaITCase { ...@@ -116,11 +114,6 @@ class XtaITCase {
doReturn("vorgangId(unused)").when(vorgangRemoteService).createVorgang(any(), any(), any(), any()); doReturn("vorgangId(unused)").when(vorgangRemoteService).createVorgang(any(), any(), any(), any());
} }
@DisplayName("should shut down context after processing")
void shouldShutdownContextAfterProcessing() {
verify(shutdownService, times(1)).shutdown();
}
@DisplayName("should have three representations with pdf") @DisplayName("should have three representations with pdf")
@TestZipFileNamesWithPdf @TestZipFileNamesWithPdf
void shouldHaveThreeRepresentationsWithPdf(String zipFileName) { void shouldHaveThreeRepresentationsWithPdf(String zipFileName) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment