Add test for XML config

Closes gh-74
This commit is contained in:
Moritz Halbritter
2022-12-02 14:00:18 +01:00
parent 242ca70198
commit a193d207e8
10 changed files with 119 additions and 0 deletions

View File

@@ -168,6 +168,12 @@ h|nativeTest
|
|
|xml-config
|image:https://ci.spring.io/api/v1/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/xml-config-app-test/badge[link=https://ci.spring.io/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/xml-config-app-test]
|image:https://ci.spring.io/api/v1/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/xml-config-native-app-test/badge[link=https://ci.spring.io/teams/spring-aot-smoke-tests/pipelines/spring-aot-smoke-tests-1.0.x/jobs/xml-config-native-app-test]
|
|
5+^h|Cloud
h|Smoke Test

View File

@@ -0,0 +1 @@
Tests if the XML configuration works

View File

@@ -0,0 +1,14 @@
plugins {
id 'java'
id 'org.springframework.boot'
id 'org.springframework.aot.smoke-test'
id 'org.graalvm.buildtools.native'
}
dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("org.springframework.boot:spring-boot-starter")
appTestImplementation(project(":aot-smoke-test-support"))
appTestImplementation("org.awaitility:awaitility:4.2.0")
}

View File

@@ -0,0 +1,23 @@
package com.example.xmlconfig;
import java.time.Duration;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.springframework.aot.smoketest.support.assertj.AssertableOutput;
import org.springframework.aot.smoketest.support.junit.ApplicationTest;
import static org.assertj.core.api.Assertions.assertThat;
@ApplicationTest
class XmlConfigApplicationAotTests {
@Test
void expectedLoggingIsProduced(AssertableOutput output) {
Awaitility.await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> {
assertThat(output).hasSingleLineContaining("Hello from MyServiceImpl");
});
}
}

View File

@@ -0,0 +1,22 @@
package com.example.xmlconfig;
import com.example.xmlconfig.service.MyService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class CLR implements CommandLineRunner {
private final MyService myService;
public CLR(MyService myService) {
this.myService = myService;
}
@Override
public void run(String... args) {
this.myService.sayHello();
}
}

View File

@@ -0,0 +1,19 @@
package com.example.xmlconfig;
import java.util.Collections;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class XmlConfigApplication {
private static final String CONTEXT_XML = "classpath:/application-context.xml";
public static void main(String[] args) {
SpringApplication application = new SpringApplication();
application.setSources(Collections.singleton(CONTEXT_XML));
application.run(args);
}
}

View File

@@ -0,0 +1,7 @@
package com.example.xmlconfig.service;
public interface MyService {
void sayHello();
}

View File

@@ -0,0 +1,10 @@
package com.example.xmlconfig.service;
class MyServiceImpl implements MyService {
@Override
public void sayHello() {
System.out.println("Hello from MyServiceImpl");
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:property-placeholder/>
<bean id="myService" class="com.example.xmlconfig.service.MyServiceImpl"/>
<bean id="application" class="com.example.xmlconfig.XmlConfigApplication"/>
</beans>

View File

@@ -81,6 +81,9 @@ groups:
- name: tracing-brave-zipkin
app_test: true
test: false
- name: xml-config
app_test: true
test: false
- name: cloud
smoke_tests:
- name: cloud-config-client