Skip to content

Commit

Permalink
Adapt tests for support for Java 14
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Mar 19, 2020
1 parent 58a45c5 commit 579a6ac
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand Down Expand Up @@ -34,6 +34,7 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter;
import org.springframework.boot.system.JavaVersion;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -153,8 +154,14 @@ void failureAnalysisForNullBeanByType() {
@Test
void failureAnalysisForUnmatchedQualifier() {
FailureAnalysis analysis = analyzeFailure(createFailure(QualifiedBeanConfiguration.class));
assertThat(analysis.getDescription())
.containsPattern("@org.springframework.beans.factory.annotation.Qualifier\\(value=\"*alpha\"*\\)");
assertThat(analysis.getDescription()).containsPattern(determineAnnotationValuePattern());
}

private String determineAnnotationValuePattern() {
if (JavaVersion.getJavaVersion().isEqualOrNewerThan(JavaVersion.FOURTEEN)) {
return "@org.springframework.beans.factory.annotation.Qualifier\\(\"*alpha\"*\\)";
}
return "@org.springframework.beans.factory.annotation.Qualifier\\(value=\"*alpha\"*\\)";
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
<profile>
<id>java13</id>
<activation>
<jdk>13</jdk>
<jdk>[13,)</jdk>
</activation>
<properties>
<gradle.task>assemble</gradle.task>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand Down Expand Up @@ -98,6 +98,7 @@ private static byte[] getNestedJarData(boolean multiRelease) throws Exception {
writeEntry(jarOutputStream, "META-INF/versions/11/multi-release.dat", 11);
writeEntry(jarOutputStream, "META-INF/versions/12/multi-release.dat", 12);
writeEntry(jarOutputStream, "META-INF/versions/13/multi-release.dat", 13);
writeEntry(jarOutputStream, "META-INF/versions/14/multi-release.dat", 14);
}
else {
writeEntry(jarOutputStream, "3.dat", 3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
Expand All @@ -16,6 +16,7 @@

package org.springframework.boot.system;

import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -60,7 +61,12 @@ public enum JavaVersion {
/**
* Java 13.
*/
THIRTEEN("13", String.class, "stripIndent");
THIRTEEN("13", String.class, "stripIndent"),

/**
* Java 14.
*/
FOURTEEN("14", MethodHandles.Lookup.class, "hasFullPrivilegeAccess");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,23 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>java14+</id>
<activation>
<jdk>[14,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 579a6ac

Please sign in to comment.