Search in sources :

Example 26 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project netty by netty.

the class NativeLibraryLoaderTest method testSingleResourceInTheClassLoader.

@Test
@EnabledOnOs(LINUX)
@EnabledIf("is_x86_64")
void testSingleResourceInTheClassLoader() throws MalformedURLException {
    URL url1 = new File("src/test/data/NativeLibraryLoader/1").toURI().toURL();
    URL url2 = new File("src/test/data/NativeLibraryLoader/2").toURI().toURL();
    URLClassLoader loader = new URLClassLoader(new URL[] { url1, url2 });
    String resourceName = "test2";
    NativeLibraryLoader.load(resourceName, loader);
    assertTrue(true);
}
Also used : URLClassLoader(java.net.URLClassLoader) File(java.io.File) URL(java.net.URL) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test) EnabledIf(org.junit.jupiter.api.condition.EnabledIf)

Example 27 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project netty by netty.

the class NativeLibraryLoaderTest method testMultipleResourcesInTheClassLoader.

@Test
@EnabledOnOs(LINUX)
@EnabledIf("is_x86_64")
void testMultipleResourcesInTheClassLoader() throws MalformedURLException {
    URL url1 = new File("src/test/data/NativeLibraryLoader/1").toURI().toURL();
    URL url2 = new File("src/test/data/NativeLibraryLoader/2").toURI().toURL();
    final URLClassLoader loader = new URLClassLoader(new URL[] { url1, url2 });
    final String resourceName = "test1";
    Exception ise = assertThrows(IllegalStateException.class, new Executable() {

        @Override
        public void execute() {
            NativeLibraryLoader.load(resourceName, loader);
        }
    });
    assertTrue(ise.getMessage().contains("Multiple resources found for 'META-INF/native/lib" + resourceName + ".so'"));
}
Also used : URLClassLoader(java.net.URLClassLoader) Executable(org.junit.jupiter.api.function.Executable) File(java.io.File) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) FileNotFoundException(java.io.FileNotFoundException) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test) EnabledIf(org.junit.jupiter.api.condition.EnabledIf)

Example 28 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project Aeron by real-logic.

the class TimestampingSystemTest method shouldSupportMediaReceiveTimestampsInCDriver.

@Test
@InterruptAfter(10)
@EnabledOnOs(OS.LINUX)
void shouldSupportMediaReceiveTimestampsInCDriver() {
    assumeTrue(TestMediaDriver.shouldRunCMediaDriver());
    final DirectBuffer buffer = new UnsafeBuffer(new byte[64]);
    try (TestMediaDriver driver = driver();
        Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(driver.aeronDirectoryName()))) {
        final Subscription sub = aeron.addSubscription(CHANNEL_WITH_MEDIA_TIMESTAMP, 1000);
        while (null == sub.resolvedEndpoint()) {
            Tests.yieldingIdle("Failed to resolve endpoint");
        }
        final String uri = "aeron:udp?endpoint=" + sub.resolvedEndpoint();
        final Publication pub = aeron.addPublication(uri, 1000);
        Tests.awaitConnected(pub);
        while (0 > pub.offer(buffer, 0, buffer.capacity(), (termBuffer, termOffset, frameLength) -> SENTINEL_VALUE)) {
            Tests.yieldingIdle("Failed to offer message");
        }
        final FragmentHandler fragmentHandler = (buffer1, offset, length, header) -> assertNotEquals(SENTINEL_VALUE, header.reservedValue());
        while (1 > sub.poll(fragmentHandler, 1)) {
            Tests.yieldingIdle("Failed to receive message");
        }
    }
}
Also used : MutableDirectBuffer(org.agrona.MutableDirectBuffer) DirectBuffer(org.agrona.DirectBuffer) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) MediaDriver(io.aeron.driver.MediaDriver) SystemTestWatcher(io.aeron.test.SystemTestWatcher) Tests(io.aeron.test.Tests) BeforeEach(org.junit.jupiter.api.BeforeEach) RegistrationException(io.aeron.exceptions.RegistrationException) InterruptingTestCallback(io.aeron.test.InterruptingTestCallback) OS(org.junit.jupiter.api.condition.OS) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter) MutableLong(org.agrona.collections.MutableLong) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) Objects.requireNonNull(java.util.Objects.requireNonNull) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) MutableDirectBuffer(org.agrona.MutableDirectBuffer) FragmentHandler(io.aeron.logbuffer.FragmentHandler) TestMediaDriver(io.aeron.test.driver.TestMediaDriver) DirectBuffer(org.agrona.DirectBuffer) FragmentHandler(io.aeron.logbuffer.FragmentHandler) TestMediaDriver(io.aeron.test.driver.TestMediaDriver) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 29 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class NantTaskBuilderTest method shouldUseAbsoluteNantPathIfAbsoluteNantPathIsSpecifiedOnWindows.

@Test
@EnabledOnOs(OS.WINDOWS)
void shouldUseAbsoluteNantPathIfAbsoluteNantPathIsSpecifiedOnWindows() {
    NantTask nantTask = new NantTask();
    nantTask.setNantPath("c:\\nantdir");
    CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, pipeline, resolver);
    assertThat(new File(builder.getCommand())).isEqualTo(new File("c:\\nantdir\\nant"));
}
Also used : NantTask(com.thoughtworks.go.config.NantTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 30 with EnabledOnOs

use of org.junit.jupiter.api.condition.EnabledOnOs in project gocd by gocd.

the class CommandBuilderTest method commandWithArgsList_shouldAddCmdBeforeAWindowsCommand.

@Test
@EnabledOnOs(OS.WINDOWS)
void commandWithArgsList_shouldAddCmdBeforeAWindowsCommand() {
    String[] args = { "some thing" };
    CommandBuilderWithArgList commandBuilderWithArgList = new CommandBuilderWithArgList("echo", args, tempWorkDir, null, null, "some desc");
    CommandLine commandLine = commandBuilderWithArgList.buildCommandLine();
    assertThat(commandLine.toStringForDisplay()).isEqualTo("cmd /c echo some thing");
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)36 EnabledOnOs (org.junit.jupiter.api.condition.EnabledOnOs)36 File (java.io.File)14 Path (java.nio.file.Path)7 URI (java.net.URI)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 EnabledForRepository (org.opengrok.indexer.condition.EnabledForRepository)5 TestRepository (org.opengrok.indexer.util.TestRepository)5 URL (java.net.URL)3 URLClassLoader (java.net.URLClassLoader)3 Date (java.util.Date)3 LinkedList (java.util.LinkedList)3 StringBinding (javafx.beans.binding.StringBinding)3 DisplayName (org.junit.jupiter.api.DisplayName)3 EnabledIf (org.junit.jupiter.api.condition.EnabledIf)3 CommandLine (com.thoughtworks.go.util.command.CommandLine)2 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)2 HashSet (java.util.HashSet)2 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)2 NantTask (com.thoughtworks.go.config.NantTask)1