org.junit.jupiter.api.condition.JRE Java Examples

The following examples show how to use org.junit.jupiter.api.condition.JRE. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuleToXmlConverterTest.java    From yare with MIT License 6 votes vote down vote up
@Test
@EnabledOnJre(JRE.JAVA_8)
void shouldThrowExceptionWhenXmlRuleDoesNotSatisfySchemaOnJdk8() {
    // given
    String invalidXmlRule = "" +
            "<yare:Rule xmlns:yare=\"http://www.sabre.com/schema/oss/yare/rules/v1\">\n" +
            "    <yare:unexpectedElement/>\n" +
            "</yare:Rule>";

    // when / then
    assertThatThrownBy(() -> converter.unmarshal(invalidXmlRule))
            .isInstanceOf(SchemaValidationException.class)
            .hasMessage("Given XML rule does not satisfy schema. Errors:\n" +
                    "Line: 2. Column: 30. " +
                    "Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'yare:unexpectedElement'. " +
                    "One of '{\"http://www.sabre.com/schema/oss/yare/rules/v1\":Attribute, " +
                    "\"http://www.sabre.com/schema/oss/yare/rules/v1\":Fact, " +
                    "\"http://www.sabre.com/schema/oss/yare/rules/v1\":Predicate}' " +
                    "is expected.");
}
 
Example #2
Source File: RuleToXmlConverterTest.java    From yare with MIT License 6 votes vote down vote up
@Test
@DisabledOnJre(JRE.JAVA_8)
void shouldThrowExceptionWhenXmlRuleDoesNotSatisfySchemaOnJdkDifferentThan8() {
    // given
    String invalidXmlRule = "" +
            "<yare:Rule xmlns:yare=\"http://www.sabre.com/schema/oss/yare/rules/v1\">\n" +
            "    <yare:unexpectedElement/>\n" +
            "</yare:Rule>";

    // when / then
    assertThatThrownBy(() -> converter.unmarshal(invalidXmlRule))
            .isInstanceOf(SchemaValidationException.class)
            .hasMessage("Given XML rule does not satisfy schema. Errors:\n" +
                    "Line: 2. Column: 30. " +
                    "Error: cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://www.sabre.com/schema/oss/yare/rules/v1\":unexpectedElement}'. " +
                    "One of '{\"http://www.sabre.com/schema/oss/yare/rules/v1\":Attribute, " +
                    "\"http://www.sabre.com/schema/oss/yare/rules/v1\":Fact, " +
                    "\"http://www.sabre.com/schema/oss/yare/rules/v1\":Predicate}' " +
                    "is expected.");
}
 
Example #3
Source File: PidTests.java    From embedded-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
@EnabledOnOs(OS.WINDOWS)
@DisabledOnJre(JRE.JAVA_8)
void constructProcessIdWindowsJava9() throws IOException {
	Process process = new ProcessBuilder("echo", "Hello world").start();
	assertThat(Pid.get(process)).isGreaterThan(0);
}
 
Example #4
Source File: PidTests.java    From embedded-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
@EnabledOnJre(JRE.JAVA_8)
@EnabledOnOs(OS.WINDOWS)
void constructProcessIdWindowsJava8() throws IOException {
	Process process = new ProcessBuilder("echo", "Hello world").start();
	assertThat(Pid.get(process)).isEqualTo(-1);
}
 
Example #5
Source File: InterestNumberFormatFactoryTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech() throws TemplateValueFormatException, TemplateModelException {
    final BigDecimal n = new BigDecimal("0.0001");
    final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE,
            Environment.getCurrentEnvironment());
    final TemplateNumberModel m = () -> n;
    final String result = f.formatToPlainText(m);
    assertThat(result.trim()).isEqualTo("0,01" + (char) 160 + "%");
}
 
Example #6
Source File: InterestNumberFormatFactoryTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech2() throws TemplateValueFormatException, TemplateModelException {
    final BigDecimal n = new BigDecimal("0.0000");
    final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE,
            Environment.getCurrentEnvironment());
    final TemplateNumberModel m = () -> n;
    final String result = f.formatToPlainText(m);
    assertThat(result.trim()).isEqualTo("0,00" + (char) 160 + "%");
}
 
Example #7
Source File: InterestNumberFormatFactoryTest.java    From robozonky with Apache License 2.0 5 votes vote down vote up
@DisabledOnJre(JRE.JAVA_8)
@Test
void formattingCzech3() throws TemplateValueFormatException, TemplateModelException {
    final BigDecimal n = new BigDecimal("0.001");
    final TemplateNumberFormat f = InterestNumberFormatFactory.INSTANCE.get("", Defaults.LOCALE,
            Environment.getCurrentEnvironment());
    final TemplateNumberModel m = () -> n;
    final String result = f.formatToPlainText(m);
    assertThat(result.trim()).isEqualTo("0,10" + (char) 160 + "%");
}
 
Example #8
Source File: JarRunnerIT.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Test
@EnabledForJreRange(min = JRE.JAVA_11)
public void testThatAppCDSAreUsable() throws Exception {
    File testDir = initProject("projects/classic", "projects/project-classic-console-output-appcds");
    RunningInvoker running = new RunningInvoker(testDir, false);

    MavenProcessInvocationResult result = running
            .execute(Arrays.asList("package", "-DskipTests", "-Dquarkus.package.create-appcds=true"),
                    Collections.emptyMap());

    await().atMost(1, TimeUnit.MINUTES).until(() -> result.getProcess() != null && !result.getProcess().isAlive());
    assertThat(running.log()).containsIgnoringCase("BUILD SUCCESS");
    running.stop();

    Path jar = testDir.toPath().toAbsolutePath()
            .resolve(Paths.get("target/acme-1.0-SNAPSHOT-runner.jar"));
    File output = new File(testDir, "target/output.log");
    output.createNewFile();

    // by using '-Xshare:on' we ensure that the JVM will fail if for any reason is cannot use the AppCDS
    // '-Xlog:class+path=info' will print diagnostic information that is useful for debugging if something goes wrong
    Process process = doLaunch(jar.getFileName(), output,
            Arrays.asList("-XX:SharedArchiveFile=app-cds.jsa", "-Xshare:on", "-Xlog:class+path=info"))
                    .directory(jar.getParent().toFile()).start();
    try {
        // Wait until server up
        dumpFileContentOnFailure(() -> {
            await()
                    .pollDelay(1, TimeUnit.SECONDS)
                    .atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/package", 200));
            return null;
        }, output, ConditionTimeoutException.class);

        String logs = FileUtils.readFileToString(output, "UTF-8");

        assertThatOutputWorksCorrectly(logs);
    } finally {
        process.destroy();
    }

}
 
Example #9
Source File: DisabledTests.java    From journaldev with MIT License 4 votes vote down vote up
@Test
@DisabledOnJre(value = JRE.JAVA_10)
void test4() {
	assertFalse(3 < 0);
}
 
Example #10
Source File: DisabledTests.java    From journaldev with MIT License 4 votes vote down vote up
@Test
@EnabledOnJre(value = JRE.JAVA_10)
void test5() {
	assertTrue(System.getProperty("java.version").startsWith("10"));
}
 
Example #11
Source File: DisableTest.java    From demo-junit-5 with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Test
@EnabledOnOs(OS.LINUX)
@DisabledOnJre(JRE.JAVA_10)
void conflictingConditions_executed() {
	assertTrue(true);
}