Add TCF smoke test
See gh-142
This commit is contained in:
@@ -9,33 +9,11 @@ import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.UseMainMethod;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, useMainMethod = UseMainMethod.ALWAYS, args = "--test.args=1")
|
||||
class CommandlinerunnerApplicationTests implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private CLR clr;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextIsInjected() {
|
||||
assertThat(this.applicationContext).as("ApplicationContextAware").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void autowiringWorks() {
|
||||
assertThat(this.clr).as("@Autowired field").isNotNull();
|
||||
}
|
||||
class CommandlinerunnerApplicationTests {
|
||||
|
||||
@Test
|
||||
void mainShouldRun() {
|
||||
|
||||
@@ -4,7 +4,7 @@ groups:
|
||||
- batch
|
||||
- name: boot
|
||||
smoke_tests:
|
||||
- actuator-webflux
|
||||
- actuator-webflux
|
||||
- actuator-webflux-mgmt-port
|
||||
- actuator-webmvc
|
||||
- actuator-webmvc-mgmt-port
|
||||
@@ -79,6 +79,7 @@ groups:
|
||||
- rest-template
|
||||
- rsocket
|
||||
- scheduled
|
||||
- tcf
|
||||
- transactional
|
||||
- transactional-event-listener
|
||||
- validation
|
||||
|
||||
1
framework/tcf/README.adoc
Normal file
1
framework/tcf/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
Tests if Spring's TestContext Framework is working
|
||||
16
framework/tcf/build.gradle
Normal file
16
framework/tcf/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
||||
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")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
appTestImplementation(project(":aot-smoke-test-support"))
|
||||
appTestImplementation("org.awaitility:awaitility:4.2.0")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.tcf;
|
||||
|
||||
public interface MyService {
|
||||
|
||||
void sayHello();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.tcf;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class MyServiceConfiguration {
|
||||
|
||||
@Bean
|
||||
MyService myService() {
|
||||
return new MyServiceImpl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.example.tcf;
|
||||
|
||||
class MyServiceImpl implements MyService {
|
||||
|
||||
@Override
|
||||
public void sayHello() {
|
||||
System.out.println("Hello from MyServiceImpl");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.tcf;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class TcfApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TcfApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.example.commandlinerunner;
|
||||
package com.example.tcf;
|
||||
|
||||
import com.example.commandlinerunner.service.MyService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
@SpringBootTest
|
||||
@SpringJUnitConfig(MyServiceConfiguration.class)
|
||||
class MockBeanTests {
|
||||
|
||||
@MockBean
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.example.tcf;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringJUnitConfig(MyServiceConfiguration.class)
|
||||
class TcfApplicationTests implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private MyService myService;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Test
|
||||
void contextIsInjected() {
|
||||
assertThat(this.applicationContext).as("ApplicationContextAware").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void autowiringWorks() {
|
||||
assertThat(this.myService).as("@Autowired field").isNotNull();
|
||||
assertThat(this.myService).isInstanceOf(MyServiceImpl.class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user