Skip to content

Commit

Permalink
Add kotlin-functional sample
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Sep 30, 2022
1 parent 4ff7cfe commit c673fdd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
21 changes: 21 additions & 0 deletions kotlin-functional/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'java'
id 'org.springframework.boot'
id 'org.springframework.aot.smoke-test'
id 'org.graalvm.buildtools.native'
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.plugin.spring' version "1.7.10"
}

dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

testImplementation("org.springframework.boot:spring-boot-starter-test")

aotSmokeTestImplementation(project(":aot-smoke-test-support"))
aotSmokeTestImplementation("org.awaitility:awaitility:4.2.0")
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.functional;

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.AotSmokeTest;

import static org.assertj.core.api.Assertions.assertThat;

@AotSmokeTest
public class FunctionalApplicationAotTests {

@Test
void expectedLoggingIsProduced(AssertableOutput output) {
Awaitility.await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> {
assertThat(output).hasSingleLineContaining("Hello World");
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.functional

import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.support.beans

@SpringBootApplication
class FunctionalApplication

fun main(args: Array<String>) {
runApplication<FunctionalApplication>(*args) {
addInitializers(beans {
bean<Foo>()
})
}
}

class Foo : CommandLineRunner {
override fun run(vararg args: String?) {
println("Hello world!")
}
}

1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ include "freemarker-webflux"
include "freemarker-webmvc"
include "hateoas"
include "integration"
include "kotlin-functional"
include "jdbc-h2"
include "jdbc-mariadb"
include "jdbc-mysql"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.example.webflux;

import org.springframework.aot.smoketest.thirdpartyhints.JaxbRuntimeHints;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportRuntimeHints;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@ImportRuntimeHints(JaxbRuntimeHints.class)
public class WebfluxApplication {

public static void main(String[] args) {
Expand Down

0 comments on commit c673fdd

Please sign in to comment.