Skip to content

Commit

Permalink
Migrate tests to JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed Nov 19, 2023
1 parent 486657e commit 1ca7bb4
Show file tree
Hide file tree
Showing 40 changed files with 417 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import io.trino.spi.function.BlockPosition;
import io.trino.spi.function.SqlNullable;
import io.trino.spi.function.SqlType;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import java.lang.invoke.MethodHandle;
import java.util.ArrayList;
Expand All @@ -36,7 +38,11 @@
import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;

@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public class TestAggregationLoopBuilder
{
private static final MethodHandle INPUT_FUNCTION;
Expand All @@ -59,7 +65,7 @@ public class TestAggregationLoopBuilder
private List<TestParameter> keyBlocks;
private List<TestParameter> valueBlocks;

@BeforeClass
@BeforeAll
public void setUp()
throws ReflectiveOperationException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import java.net.CookieManager;
import java.net.CookieStore;
Expand All @@ -48,7 +50,11 @@
import static jakarta.servlet.http.HttpServletResponse.SC_OK;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import static org.junit.jupiter.api.parallel.ExecutionMode.CONCURRENT;

@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
public class TestOAuth2WebUiAuthenticationFilterWithRefreshTokens
{
protected static final Duration TTL_ACCESS_TOKEN_IN_SECONDS = Duration.ofSeconds(5);
Expand All @@ -65,7 +71,7 @@ public class TestOAuth2WebUiAuthenticationFilterWithRefreshTokens
private URI serverUri;
private URI uiUri;

@BeforeClass
@BeforeAll
public void setup()
throws Exception
{
Expand Down Expand Up @@ -121,7 +127,7 @@ public void setup()
serverUri + "/ui/logout/logout.html");
}

@AfterClass(alwaysRun = true)
@AfterAll
public void tearDown()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import io.trino.spi.block.BlockEncodingSerde;
import io.trino.spi.block.TestingBlockEncodingSerde;
import io.trino.spi.type.Type;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import java.io.File;
import java.io.IOException;
Expand All @@ -47,8 +49,11 @@
import static io.trino.spi.type.VarbinaryType.VARBINARY;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS;
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;

@Test(singleThreaded = true)
@TestInstance(PER_CLASS)
@Execution(SAME_THREAD)
public class TestBinaryFileSpiller
{
private static final List<Type> TYPES = ImmutableList.of(BIGINT, VARCHAR, DOUBLE, BIGINT);
Expand All @@ -60,14 +65,14 @@ public class TestBinaryFileSpiller
private PageSerializer serializer;
private AggregatedMemoryContext memoryContext;

@BeforeClass(alwaysRun = true)
@BeforeAll
public void setUpClass()
throws IOException
{
spillPath = Files.createTempDirectory("tmp").toFile();
}

@BeforeMethod
@BeforeEach
public void setUp()
{
spillerStats = new SpillerStats();
Expand All @@ -83,7 +88,7 @@ public void setUp()
memoryContext = newSimpleAggregatedMemoryContext();
}

@AfterMethod(alwaysRun = true)
@AfterEach
public void tearDown()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -91,14 +89,12 @@ protected LocalQueryRunner createLocalQueryRunner()
}

@BeforeAll
@BeforeClass
public final void initPlanTest()
{
this.queryRunner = createLocalQueryRunner();
}

@AfterAll
@AfterClass(alwaysRun = true)
public final void destroyPlanTest()
{
closeAllRuntimeException(queryRunner);
Expand Down
Loading

0 comments on commit 1ca7bb4

Please sign in to comment.