diff --git a/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java b/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTestBase.java similarity index 91% rename from quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java rename to quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTestBase.java index 66e15b5e72..6ebbe0167f 100644 --- a/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java +++ b/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTestBase.java @@ -20,12 +20,8 @@ import static org.apache.polaris.admintool.BaseCommand.EXIT_CODE_BOOTSTRAP_ERROR; import static org.apache.polaris.admintool.BaseCommand.EXIT_CODE_USAGE; -import static org.apache.polaris.admintool.PostgresTestResourceLifecycleManager.INIT_SCRIPT; import static org.assertj.core.api.Assertions.assertThat; -import io.quarkus.test.common.ResourceArg; -import io.quarkus.test.common.TestResourceScope; -import io.quarkus.test.common.WithTestResource; import io.quarkus.test.junit.main.Launch; import io.quarkus.test.junit.main.LaunchResult; import io.quarkus.test.junit.main.QuarkusMainLauncher; @@ -41,11 +37,7 @@ import org.junit.jupiter.api.io.TempDir; @QuarkusMainTest -@WithTestResource( - value = PostgresTestResourceLifecycleManager.class, - scope = TestResourceScope.GLOBAL, - initArgs = @ResourceArg(name = INIT_SCRIPT, value = "org/apache/polaris/admintool/init.sql")) -class BootstrapCommandTest { +public abstract class BootstrapCommandTestBase { private static Path json; private static Path yaml; @@ -172,7 +164,7 @@ public void testBootstrapInvalidArg(LaunchResult result) { } private static Path copyResource(Path temp, String resource) throws IOException { - URL source = Objects.requireNonNull(BootstrapCommandTest.class.getResource(resource)); + URL source = Objects.requireNonNull(BootstrapCommandTestBase.class.getResource(resource)); Path dest = temp.resolve(resource); try (InputStream in = source.openStream()) { Files.copy(in, dest); diff --git a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java b/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTestBase.java similarity index 78% rename from quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java rename to quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTestBase.java index ba60d9e25e..758f41d68d 100644 --- a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java +++ b/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTestBase.java @@ -21,31 +21,31 @@ import static org.assertj.core.api.Assertions.assertThat; import io.quarkus.runtime.StartupEvent; -import io.quarkus.test.common.WithTestResource; -import io.quarkus.test.junit.QuarkusTestProfile; -import io.quarkus.test.junit.TestProfile; import io.quarkus.test.junit.main.Launch; import io.quarkus.test.junit.main.LaunchResult; import io.quarkus.test.junit.main.QuarkusMainTest; import jakarta.enterprise.event.Observes; import java.util.List; -import java.util.Map; import org.apache.polaris.core.persistence.MetaStoreManagerFactory; import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet; +import org.assertj.core.api.SoftAssertions; import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @QuarkusMainTest -@WithTestResource(PostgresTestResourceLifecycleManager.class) -@TestProfile(PurgeCommandTest.Profile.class) -class PurgeCommandTest { +public abstract class PurgeCommandTestBase { + protected SoftAssertions soft; - public static class Profile implements QuarkusTestProfile { + @BeforeEach + void setup() { + soft = new SoftAssertions(); + } - @Override - public Map getConfigOverrides() { - return Map.of("pre-bootstrap", "true"); - } + @AfterEach + void after() { + soft.assertAll(); } void preBootstrap( @@ -69,9 +69,9 @@ public void testPurge(LaunchResult result) { value = {"purge", "-r", "realm3"}, exitCode = BaseCommand.EXIT_CODE_PURGE_ERROR) public void testPurgeFailure(LaunchResult result) { - assertThat(result.getOutput()) + soft.assertThat(result.getOutput()) .contains( "Realm realm3 is not bootstrapped, could not load root principal. Please run Bootstrap command."); - assertThat(result.getErrorOutput()).contains("Purge encountered errors during operation."); + soft.assertThat(result.getErrorOutput()).contains("Purge encountered errors during operation."); } } diff --git a/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkBootstrapCommandTest.java b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkBootstrapCommandTest.java new file mode 100644 index 0000000000..025f9ff920 --- /dev/null +++ b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkBootstrapCommandTest.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.admintool.el; + +import io.quarkus.test.junit.TestProfile; +import org.apache.polaris.admintool.BootstrapCommandTestBase; + +@TestProfile(EclipselinkProfile.class) +class EclipselinkBootstrapCommandTest extends BootstrapCommandTestBase {} diff --git a/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkProfile.java b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkProfile.java new file mode 100644 index 0000000000..693a5e504e --- /dev/null +++ b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkProfile.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.admintool.el; + +import static org.apache.polaris.admintool.PostgresTestResourceLifecycleManager.INIT_SCRIPT; + +import io.quarkus.test.junit.QuarkusTestProfile; +import java.util.List; +import java.util.Map; +import org.apache.polaris.admintool.PostgresTestResourceLifecycleManager; + +public class EclipselinkProfile implements QuarkusTestProfile { + + @Override + public Map getConfigOverrides() { + return Map.of(); + } + + @Override + public List testResources() { + return List.of( + new TestResourceEntry( + PostgresTestResourceLifecycleManager.class, + Map.of(INIT_SCRIPT, "org/apache/polaris/admintool/init.sql"))); + } +} diff --git a/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkPurgeCommandTest.java b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkPurgeCommandTest.java new file mode 100644 index 0000000000..b80287cd09 --- /dev/null +++ b/quarkus/admin/src/test/java/org/apache/polaris/admintool/el/EclipselinkPurgeCommandTest.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.admintool.el; + +import io.quarkus.test.junit.TestProfile; +import java.util.Map; +import org.apache.polaris.admintool.PurgeCommandTestBase; +import org.testcontainers.shaded.com.google.common.collect.ImmutableMap; + +@TestProfile(EclipselinkPurgeCommandTest.Profile.class) +class EclipselinkPurgeCommandTest extends PurgeCommandTestBase { + + public static class Profile extends EclipselinkProfile { + @Override + public Map getConfigOverrides() { + return ImmutableMap.builder() + .putAll(super.getConfigOverrides()) + .put("pre-bootstrap", "true") + .build(); + } + } +}