-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Test Resources server is stopped, and cleanup properties files…
… even if it died
- Loading branch information
1 parent
fc91a28
commit 5e54777
Showing
23 changed files
with
569 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
micronaut-maven-integration-tests/src/it/test-resources-start-kill-stop/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals = -ntp -e mn:stop-testresources-service | ||
invoker.os.family = !windows |
173 changes: 173 additions & 0 deletions
173
micronaut-maven-integration-tests/src/it/test-resources-start-kill-stop/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.micronaut.build.examples</groupId> | ||
<artifactId>test-resources-start-kill-stop</artifactId> | ||
<version>0.1</version> | ||
<packaging>${packaging}</packaging> | ||
<parent> | ||
<groupId>io.micronaut.platform</groupId> | ||
<artifactId>micronaut-parent</artifactId> | ||
<version>@it.micronaut.version@</version> | ||
</parent> | ||
<properties> | ||
<packaging>jar</packaging> | ||
<micronaut.version>@it.micronaut.version@</micronaut.version> | ||
<micronaut.runtime>netty</micronaut.runtime> | ||
<micronaut-maven-plugin.version>@project.version@</micronaut-maven-plugin.version> | ||
<exec.mainClass>io.micronaut.build.examples.Application</exec.mainClass> | ||
<micronaut.test.resources.version>@micronaut.test.resources.version@</micronaut.test.resources.version> | ||
<micronaut.test.resources.enabled>true</micronaut.test.resources.enabled> | ||
<maven.native.plugin.version>@native-maven-plugin.version@</maven.native.plugin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-inject</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.validation</groupId> | ||
<artifactId>micronaut-validation</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.test</groupId> | ||
<artifactId>micronaut-test-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-client</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-server-netty</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-jackson-databind</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.sql</groupId> | ||
<artifactId>micronaut-jdbc-hikari</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.yaml</groupId> | ||
<artifactId>snakeyaml</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.data</groupId> | ||
<artifactId>micronaut-data-jdbc</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.micronaut.testresources</groupId> | ||
<artifactId>micronaut-test-resources-client</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.micronaut.maven</groupId> | ||
<artifactId>micronaut-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<!-- Uncomment to enable incremental compilation --> | ||
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> --> | ||
<annotationProcessorPaths combine.self="append"> | ||
<path> | ||
<groupId>io.micronaut.data</groupId> | ||
<artifactId>micronaut-data-processor</artifactId> | ||
<version>${micronaut.data.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-inject</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</path> | ||
<path> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-http-validation</artifactId> | ||
<version>${micronaut.core.version}</version> | ||
</path> | ||
<path> | ||
<groupId>io.micronaut.validation</groupId> | ||
<artifactId>micronaut-validation-processor</artifactId> | ||
<version>${micronaut.validation.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>io.micronaut</groupId> | ||
<artifactId>micronaut-inject</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</path> | ||
</annotationProcessorPaths> | ||
<compilerArgs> | ||
<arg>-Amicronaut.processing.group=io.micronaut.build.examples</arg> | ||
<arg>-Amicronaut.processing.module=test-resources-start-kill-stop</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>setup</id> | ||
<repositories> | ||
<repository> | ||
<id>central</id> | ||
<url>https://repo.maven.apache.org/maven2</url> | ||
</repository> | ||
<repository> | ||
<id>sonatype-snapshots</id> | ||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<releases> | ||
<enabled>false</enabled> | ||
</releases> | ||
</repository> | ||
</repositories> | ||
</profile> | ||
</profiles> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
micronaut-maven-integration-tests/src/it/test-resources-start-kill-stop/setup.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
File mvnw = new File(basedir, '../../../mvnw') | ||
assert mvnw.exists() | ||
|
||
String localRepo = (basedir as File).toPath().resolve("../../../target/local-repo").toFile().absolutePath | ||
|
||
def processBuilder = new ProcessBuilder(mvnw.absolutePath, "-ntp", "-q", "-Dmaven.repo.local=${localRepo}", "-Psetup", "mn:start-testresources-service") | ||
.directory(basedir as File) | ||
.inheritIO() | ||
|
||
Process p = processBuilder.start() | ||
p.waitFor() | ||
|
||
assert p.exitValue() == 0 | ||
|
||
def testResourcesProcess = ProcessHandle.allProcesses() | ||
.filter(process -> process.info().commandLine().map(c -> c.contains("TestResourcesService")).orElse(false)) | ||
.findFirst(); | ||
|
||
if (testResourcesProcess.isPresent()) { | ||
testResourcesProcess.get().destroyForcibly(); | ||
} else { | ||
assert false : "Test Resources Service process not found" | ||
} |
50 changes: 50 additions & 0 deletions
50
...test-resources-start-kill-stop/src/main/java/io/micronaut/build/examples/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.micronaut.build.examples; | ||
|
||
import io.micronaut.context.ApplicationContextBuilder; | ||
import io.micronaut.context.ApplicationContextConfigurer; | ||
import io.micronaut.context.annotation.ContextConfigurer; | ||
import io.micronaut.context.event.StartupEvent; | ||
import io.micronaut.runtime.Micronaut; | ||
import io.micronaut.runtime.event.annotation.EventListener; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
@Singleton | ||
public class Application { | ||
|
||
@Inject | ||
private UserRepository userRepository; | ||
|
||
@Inject | ||
private BookRepository bookRepository; | ||
|
||
@ContextConfigurer | ||
public static class Configurer implements ApplicationContextConfigurer { | ||
@Override | ||
public void configure(ApplicationContextBuilder builder) { | ||
builder.deduceEnvironment(false); | ||
builder.banner(true); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
Micronaut.run(Application.class, args); | ||
} | ||
|
||
@EventListener | ||
public void onStart(StartupEvent event) { | ||
if (userRepository.count() == 0) { | ||
User admin = new User(); | ||
admin.setName("Administrator"); | ||
userRepository.save(admin); | ||
} | ||
if (bookRepository.count() == 0) { | ||
Book book = new Book(); | ||
book.setTitle("The Hitchhiker's Guide to the Galaxy"); | ||
bookRepository.save(book); | ||
} | ||
if (System.getProperty("interrupt.on.startup") != null) { | ||
System.exit(0); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...src/it/test-resources-start-kill-stop/src/main/java/io/micronaut/build/examples/Book.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2003-2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micronaut.build.examples; | ||
|
||
import io.micronaut.data.annotation.GeneratedValue; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
|
||
@MappedEntity | ||
public class Book { | ||
@Id | ||
@GeneratedValue(GeneratedValue.Type.AUTO) | ||
private Long id; | ||
|
||
private String title; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
} |
Oops, something went wrong.