Search in sources :

Example 1 with EnabledForJreRange

use of org.junit.jupiter.api.condition.EnabledForJreRange in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method implicitlyBoundRecordProperties.

@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void implicitlyBoundRecordProperties(@TempDir File temp) throws IOException {
    File exampleRecord = new File(temp, "ExampleRecord.java");
    try (PrintWriter writer = new PrintWriter(new FileWriter(exampleRecord))) {
        writer.println("@org.springframework.boot.configurationsample.ConfigurationProperties(\"implicit\")");
        writer.println("public record ExampleRecord(String someString, Integer someInteger) {");
        writer.println("}");
    }
    ConfigurationMetadata metadata = compile(exampleRecord);
    assertThat(metadata).has(Metadata.withProperty("implicit.some-string"));
    assertThat(metadata).has(Metadata.withProperty("implicit.some-integer"));
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) PrintWriter(java.io.PrintWriter) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) Test(org.junit.jupiter.api.Test)

Example 2 with EnabledForJreRange

use of org.junit.jupiter.api.condition.EnabledForJreRange in project aeron by real-logic.

the class FailedFirstElectionClusterTest method shouldRecoverWhenFollowerIsMultipleTermsBehindFromEmptyLog.

@Test
@EnabledForJreRange(min = JRE.JAVA_11)
@InterruptAfter(60)
public void shouldRecoverWhenFollowerIsMultipleTermsBehindFromEmptyLog() {
    final int numNodes = 3;
    final int messageCount = 10;
    final int numTerms = 3;
    final TestCluster cluster = aCluster().withStaticNodes(numNodes).start(2);
    systemTestWatcher.cluster(cluster);
    systemTestWatcher.ignoreErrorsMatching((s) -> s.contains("Forced failure"));
    int totalMessages = 0;
    for (int i = 0; i < numTerms; i++) {
        final TestNode oldLeader = cluster.awaitLeader();
        cluster.connectClient();
        cluster.sendMessages(messageCount);
        totalMessages += messageCount;
        cluster.awaitResponseMessageCount(totalMessages);
        cluster.stopNode(oldLeader);
        cluster.startStaticNode(oldLeader.index(), false);
        cluster.awaitLeader();
    }
    cluster.startStaticNode(2, true);
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    totalMessages += messageCount;
    cluster.awaitResponseMessageCount(totalMessages);
    cluster.awaitServicesMessageCount(totalMessages);
    cluster.assertRecordingLogsEqual();
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 3 with EnabledForJreRange

use of org.junit.jupiter.api.condition.EnabledForJreRange in project mapstruct by mapstruct.

the class JodaConversionTest method testSourceToTargetMappingForStringsJdk11.

@ProcessorTest
@EnabledForJreRange(min = JRE.JAVA_11)
public // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
void testSourceToTargetMappingForStringsJdk11() {
    Source src = new Source();
    src.setLocalTime(new LocalTime(0, 0));
    src.setLocalDate(new LocalDate(2014, 1, 1));
    src.setLocalDateTime(new LocalDateTime(2014, 1, 1, 0, 0));
    src.setDateTime(new DateTime(2014, 1, 1, 0, 0, 0, DateTimeZone.UTC));
    // with given format
    Target target = SourceTargetMapper.INSTANCE.sourceToTarget(src);
    assertThat(target).isNotNull();
    assertThat(target.getDateTime()).isEqualTo("01.01.2014 00:00 UTC");
    assertThat(target.getLocalDateTime()).isEqualTo("01.01.2014 00:00");
    assertThat(target.getLocalDate()).isEqualTo("01.01.2014");
    assertThat(target.getLocalTime()).isEqualTo("00:00");
    // and now with default mappings
    target = SourceTargetMapper.INSTANCE.sourceToTargetDefaultMapping(src);
    assertThat(target).isNotNull();
    assertThat(target.getDateTime()).isEqualTo("1. Januar 2014 um 00:00:00 UTC");
    assertThat(target.getLocalDateTime()).isEqualTo("1. Januar 2014 um 00:00:00");
    assertThat(target.getLocalDate()).isEqualTo("1. Januar 2014");
    assertThat(target.getLocalTime()).isEqualTo("00:00:00");
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 4 with EnabledForJreRange

use of org.junit.jupiter.api.condition.EnabledForJreRange in project spring-boot by spring-projects.

the class ConfigurationMetadataAnnotationProcessorTests method multiConstructorRecordProperties.

@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void multiConstructorRecordProperties(@TempDir File temp) throws IOException {
    File exampleRecord = new File(temp, "ExampleRecord.java");
    try (PrintWriter writer = new PrintWriter(new FileWriter(exampleRecord))) {
        writer.println("@org.springframework.boot.configurationsample.ConfigurationProperties(\"multi\")");
        writer.println("public record ExampleRecord(String someString, Integer someInteger) {");
        writer.println("    @org.springframework.boot.configurationsample.ConstructorBinding");
        writer.println("    public ExampleRecord(String someString) {");
        writer.println("        this(someString, 42);");
        writer.println("    }");
        writer.println("    public ExampleRecord(Integer someInteger) {");
        writer.println("        this(\"someString\", someInteger);");
        writer.println("    }");
        writer.println("}");
    }
    ConfigurationMetadata metadata = compile(exampleRecord);
    assertThat(metadata).has(Metadata.withProperty("multi.some-string"));
    assertThat(metadata).doesNotHave(Metadata.withProperty("multi.some-integer"));
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) ConfigurationMetadata(org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata) PrintWriter(java.io.PrintWriter) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) Test(org.junit.jupiter.api.Test)

Example 5 with EnabledForJreRange

use of org.junit.jupiter.api.condition.EnabledForJreRange in project zaproxy by zaproxy.

the class VerifyScriptTemplates method shouldParseJsTemplates.

@Test
@EnabledForJreRange(max = JRE.JAVA_14)
void shouldParseJsTemplates() throws Exception {
    // Given
    List<Path> templates = getScriptTemplates(".js");
    Compilable se = (Compilable) new ScriptEngineManager().getEngineByName("ECMAScript");
    assertThat("No ECMAScript script engine found.", se, is(not(nullValue())));
    for (Path template : templates) {
        try (Reader reader = Files.newBufferedReader(template, StandardCharsets.UTF_8)) {
            // When / Then
            se.compile(reader);
        }
    }
}
Also used : Path(java.nio.file.Path) Compilable(javax.script.Compilable) ScriptEngineManager(javax.script.ScriptEngineManager) Reader(java.io.Reader) EnabledForJreRange(org.junit.jupiter.api.condition.EnabledForJreRange) Test(org.junit.jupiter.api.Test)

Aggregations

EnabledForJreRange (org.junit.jupiter.api.condition.EnabledForJreRange)6 Test (org.junit.jupiter.api.Test)5 InterruptAfter (io.aeron.test.InterruptAfter)2 SlowTest (io.aeron.test.SlowTest)2 TestCluster (io.aeron.test.cluster.TestCluster)2 TestNode (io.aeron.test.cluster.TestNode)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 ConfigurationMetadata (org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata)2 Reader (java.io.Reader)1 Path (java.nio.file.Path)1 Compilable (javax.script.Compilable)1 ScriptEngineManager (javax.script.ScriptEngineManager)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 LocalDateTime (org.joda.time.LocalDateTime)1 LocalTime (org.joda.time.LocalTime)1 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)1