fix: Replaced classLoader in DriverJar (#1811)
This commit is contained in:
@@ -32,7 +32,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
ARCH="${{ matrix.runs-on == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}"
|
ARCH="${{ matrix.runs-on == 'ubuntu-24.04-arm' && 'arm64' || 'amd64' }}"
|
||||||
bash utils/docker/build.sh --$ARCH ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
|
bash utils/docker/build.sh --$ARCH ${{ matrix.flavor }} playwright-java:localbuild-${{ matrix.flavor }}
|
||||||
- name: Test
|
- name: Start container
|
||||||
run: |
|
run: |
|
||||||
CONTAINER_ID="$(docker run --rm -e CI --ipc=host -v $(pwd):/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)"
|
CONTAINER_ID=$(docker run --rm -e CI --ipc=host -v "$(pwd)":/root/playwright --name playwright-docker-test -d -t playwright-java:localbuild-${{ matrix.flavor }} /bin/bash)
|
||||||
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
|
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Run test in container
|
||||||
|
run: |
|
||||||
|
docker exec "$CONTAINER_ID" /root/playwright/tools/test-local-installation/create_project_and_run_tests.sh
|
||||||
|
|
||||||
|
- name: Test ClassLoader
|
||||||
|
run: |
|
||||||
|
docker exec "${CONTAINER_ID}" /root/playwright/tools/test-spring-boot-starter/package_and_run_async_test.sh
|
||||||
|
|
||||||
|
- name: Stop container
|
||||||
|
run: |
|
||||||
|
docker stop "$CONTAINER_ID"
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class DriverJar extends Driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static URI getDriverResourceURI() throws URISyntaxException {
|
public static URI getDriverResourceURI() throws URISyntaxException {
|
||||||
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classloader = DriverJar.class.getClassLoader();
|
||||||
return classloader.getResource("driver/" + platformDir()).toURI();
|
return classloader.getResource("driver/" + platformDir()).toURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set +x
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
mvn package -D skipTests --no-transfer-progress
|
||||||
|
java -jar target/test-spring-boot-starter*.jar --async
|
||||||
+16
@@ -5,6 +5,9 @@ import org.springframework.boot.CommandLineRunner;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class TestApp implements CommandLineRunner {
|
public class TestApp implements CommandLineRunner {
|
||||||
|
|
||||||
@@ -14,6 +17,19 @@ public class TestApp implements CommandLineRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) {
|
public void run(String... args) {
|
||||||
|
if (Arrays.asList(args).contains("--async")) {
|
||||||
|
runAsync();
|
||||||
|
} else {
|
||||||
|
runSync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAsync() {
|
||||||
|
CompletableFuture<Void> voidCompletableFuture = CompletableFuture.runAsync(this::runSync);
|
||||||
|
voidCompletableFuture.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runSync() {
|
||||||
try (Playwright playwright = Playwright.create()) {
|
try (Playwright playwright = Playwright.create()) {
|
||||||
BrowserType browserType = getBrowserTypeFromEnv(playwright);
|
BrowserType browserType = getBrowserTypeFromEnv(playwright);
|
||||||
System.out.println("Running test with " + browserType.name());
|
System.out.println("Running test with " + browserType.name());
|
||||||
|
|||||||
Reference in New Issue
Block a user