diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/FlightTestUtil.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/FlightTestUtil.java index cd043b639b05c..a0eb80daca6b1 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/FlightTestUtil.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/FlightTestUtil.java @@ -28,7 +28,7 @@ import java.util.Random; import java.util.function.Function; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.function.Executable; @@ -130,7 +130,7 @@ static boolean isNativeTransportAvailable() { */ public static CallStatus assertCode(FlightStatusCode code, Executable r) { final FlightRuntimeException ex = Assertions.assertThrows(FlightRuntimeException.class, r); - Assert.assertEquals(code, ex.status().code()); + Assertions.assertEquals(code, ex.status().code()); return ex.status(); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestApplicationMetadata.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestApplicationMetadata.java index c7b3321af01d0..fb0345b134e28 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestApplicationMetadata.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestApplicationMetadata.java @@ -32,9 +32,9 @@ import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * Tests for application-specific metadata support in Flight. @@ -51,16 +51,16 @@ public class TestApplicationMetadata { */ @Test // This test is consistently flaky on CI, unfortunately. - @Ignore + @Disabled public void retrieveMetadata() { test((allocator, client) -> { try (final FlightStream stream = client.getStream(new Ticket(new byte[0]))) { byte i = 0; while (stream.next()) { final IntVector vector = (IntVector) stream.getRoot().getVector("a"); - Assert.assertEquals(1, vector.getValueCount()); - Assert.assertEquals(10, vector.get(0)); - Assert.assertEquals(i, stream.getLatestMetadata().getByte(0)); + Assertions.assertEquals(1, vector.getValueCount()); + Assertions.assertEquals(10, vector.get(0)); + Assertions.assertEquals(i, stream.getLatestMetadata().getByte(0)); i++; } } catch (Exception e) { @@ -81,7 +81,7 @@ public void arrow6136() { final FlightClient.ClientStreamListener writer = client.startPut(descriptor, root, listener); // Must attempt to retrieve the result to get any server-side errors. final CallStatus status = FlightTestUtil.assertCode(FlightStatusCode.INTERNAL, writer::getResult); - Assert.assertEquals(MESSAGE_ARROW_6136, status.description()); + Assertions.assertEquals(MESSAGE_ARROW_6136, status.description()); } catch (Exception e) { throw new RuntimeException(e); } @@ -92,7 +92,7 @@ public void arrow6136() { * Ensure that a client can send metadata to the server. */ @Test - @Ignore + @Disabled public void uploadMetadataAsync() { final Schema schema = new Schema(Collections.singletonList(Field.nullable("a", new ArrowType.Int(32, true)))); test((allocator, client) -> { @@ -104,8 +104,8 @@ public void uploadMetadataAsync() { @Override public void onNext(PutResult val) { - Assert.assertNotNull(val); - Assert.assertEquals(counter, val.getApplicationMetadata().getByte(0)); + Assertions.assertNotNull(val); + Assertions.assertEquals(counter, val.getApplicationMetadata().getByte(0)); counter++; } }; @@ -134,7 +134,7 @@ public void onNext(PutResult val) { * Ensure that a client can send metadata to the server. Uses the synchronous API. */ @Test - @Ignore + @Disabled public void uploadMetadataSync() { final Schema schema = new Schema(Collections.singletonList(Field.nullable("a", new ArrowType.Int(32, true)))); test((allocator, client) -> { @@ -153,8 +153,8 @@ public void uploadMetadataSync() { root.setRowCount(1); writer.putNext(metadata); try (final PutResult message = listener.poll(5000, TimeUnit.SECONDS)) { - Assert.assertNotNull(message); - Assert.assertEquals(i, message.getApplicationMetadata().getByte(0)); + Assertions.assertNotNull(message); + Assertions.assertEquals(i, message.getApplicationMetadata().getByte(0)); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } @@ -170,7 +170,7 @@ public void uploadMetadataSync() { * Make sure that a {@link SyncPutListener} properly reclaims memory if ignored. */ @Test - @Ignore + @Disabled public void syncMemoryReclaimed() { final Schema schema = new Schema(Collections.singletonList(Field.nullable("a", new ArrowType.Int(32, true)))); test((allocator, client) -> { @@ -216,10 +216,10 @@ public void testMetadataEndianness() throws Exception { final FlightClient.ClientStreamListener writer = client.startPut(descriptor, root, reader); writer.completed(); try (final PutResult metadata = reader.read()) { - Assert.assertEquals(16, metadata.getApplicationMetadata().readableBytes()); + Assertions.assertEquals(16, metadata.getApplicationMetadata().readableBytes()); byte[] bytes = new byte[16]; metadata.getApplicationMetadata().readBytes(bytes); - Assert.assertArrayEquals(EndianFlightProducer.EXPECTED_BYTES, bytes); + Assertions.assertArrayEquals(EndianFlightProducer.EXPECTED_BYTES, bytes); } writer.getResult(); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestAuth.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestAuth.java index 6f0ec9f0255cd..0da49c906fc26 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestAuth.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestAuth.java @@ -24,56 +24,61 @@ import org.apache.arrow.flight.auth.ServerAuthHandler; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestAuth { /** An auth handler that does not send messages should not block the server forever. */ - @Test(expected = RuntimeException.class) + @Test public void noMessages() throws Exception { - try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); - final FlightServer s = FlightTestUtil - .getStartedServer( - location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()).authHandler( - new OneshotAuthHandler()).build()); - final FlightClient client = FlightClient.builder(allocator, s.getLocation()).build()) { - client.authenticate(new ClientAuthHandler() { - @Override - public void authenticate(ClientAuthSender outgoing, Iterator incoming) { - } + Assertions.assertThrows(RuntimeException.class, () -> { + try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); + final FlightServer s = FlightTestUtil + .getStartedServer( + location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()).authHandler( + new OneshotAuthHandler()).build()); + final FlightClient client = FlightClient.builder(allocator, s.getLocation()).build()) { + client.authenticate(new ClientAuthHandler() { + @Override + public void authenticate(ClientAuthSender outgoing, Iterator incoming) { + } - @Override - public byte[] getCallToken() { - return new byte[0]; - } - }); - } + @Override + public byte[] getCallToken() { + return new byte[0]; + } + }); + } + }); } /** An auth handler that sends an error should not block the server forever. */ - @Test(expected = RuntimeException.class) + @Test public void clientError() throws Exception { - try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); - final FlightServer s = FlightTestUtil - .getStartedServer( - location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()).authHandler( - new OneshotAuthHandler()).build()); - final FlightClient client = FlightClient.builder(allocator, s.getLocation()).build()) { - client.authenticate(new ClientAuthHandler() { - @Override - public void authenticate(ClientAuthSender outgoing, Iterator incoming) { - outgoing.send(new byte[0]); - // Ensure the server-side runs - incoming.next(); - outgoing.onError(new RuntimeException("test")); - } + Assertions.assertThrows(RuntimeException.class, () -> { + try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); + final FlightServer s = FlightTestUtil + .getStartedServer( + location -> FlightServer.builder(allocator, location, new NoOpFlightProducer()).authHandler( + new OneshotAuthHandler()).build()); + final FlightClient client = FlightClient.builder(allocator, s.getLocation()).build()) { + client.authenticate(new ClientAuthHandler() { + @Override + public void authenticate(ClientAuthSender outgoing, Iterator incoming) { + outgoing.send(new byte[0]); + // Ensure the server-side runs + incoming.next(); + outgoing.onError(new RuntimeException("test")); + } - @Override - public byte[] getCallToken() { - return new byte[0]; - } - }); - } + @Override + public byte[] getCallToken() { + return new byte[0]; + } + }); + } + }); } private static class OneshotAuthHandler implements ServerAuthHandler { diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBackPressure.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBackPressure.java index 1a71c363e173b..ae691f3ef9003 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBackPressure.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBackPressure.java @@ -30,9 +30,9 @@ import org.apache.arrow.vector.types.Types.MinorType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; @@ -43,7 +43,7 @@ public class TestBackPressure { /** * Make sure that failing to consume one stream doesn't block other streams. */ - @Ignore + @Disabled @Test public void ensureIndependentSteams() throws Exception { ensureIndependentSteams((b) -> (location -> new PerformanceTestServer(b, location))); @@ -52,7 +52,7 @@ public void ensureIndependentSteams() throws Exception { /** * Make sure that failing to consume one stream doesn't block other streams. */ - @Ignore + @Disabled @Test public void ensureIndependentSteamsWithCallbacks() throws Exception { ensureIndependentSteams((b) -> (location -> new PerformanceTestServer(b, location, @@ -62,7 +62,7 @@ public void ensureIndependentSteamsWithCallbacks() throws Exception { /** * Test to make sure stream doesn't go faster than the consumer is consuming. */ - @Ignore + @Disabled @Test public void ensureWaitUntilProceed() throws Exception { ensureWaitUntilProceed(new PollingBackpressureStrategy(), false); @@ -72,7 +72,7 @@ public void ensureWaitUntilProceed() throws Exception { * Test to make sure stream doesn't go faster than the consumer is consuming using a callback-based * backpressure strategy. */ - @Ignore + @Disabled @Test public void ensureWaitUntilProceedWithCallbacks() throws Exception { ensureWaitUntilProceed(new RecordingCallbackBackpressureStrategy(), true); @@ -177,9 +177,14 @@ public void getStream(CallContext context, Ticket ticket, ServerStreamListener l root.clear(); } long expected = wait - epsilon; - Assert.assertTrue( - String.format("Expected a sleep of at least %dms but only slept for %d", expected, - bpStrategy.getSleepTime()), bpStrategy.getSleepTime() > expected); + Assertions.assertTrue( + bpStrategy.getSleepTime() > expected, + String.format( + "Expected a sleep of at least %dms but only slept for %d", + expected, + bpStrategy.getSleepTime() + ) + ); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBasicOperation.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBasicOperation.java index e29cd07ced55c..0a1d7f8a3f842 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBasicOperation.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestBasicOperation.java @@ -50,8 +50,8 @@ import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.google.common.base.Charsets; import com.google.protobuf.ByteString; @@ -65,8 +65,8 @@ public class TestBasicOperation { @Test public void fastPathDefaults() { - Assert.assertTrue(ArrowMessage.ENABLE_ZERO_COPY_READ); - Assert.assertFalse(ArrowMessage.ENABLE_ZERO_COPY_WRITE); + Assertions.assertTrue(ArrowMessage.ENABLE_ZERO_COPY_READ); + Assertions.assertFalse(ArrowMessage.ENABLE_ZERO_COPY_WRITE); } /** @@ -75,7 +75,7 @@ public void fastPathDefaults() { @Test public void unknownScheme() throws URISyntaxException { final Location location = new Location("s3://unknown"); - Assert.assertEquals("s3", location.getUri().getScheme()); + Assertions.assertEquals("s3", location.getUri().getScheme()); } @Test @@ -83,7 +83,7 @@ public void unknownSchemeRemote() throws Exception { test(c -> { try { final FlightInfo info = c.getInfo(FlightDescriptor.path("test")); - Assert.assertEquals(new URI("https://example.com"), info.getEndpoints().get(0).getLocations().get(0).getUri()); + Assertions.assertEquals(new URI("https://example.com"), info.getEndpoints().get(0).getLocations().get(0).getUri()); } catch (URISyntaxException e) { throw new RuntimeException(e); } @@ -93,7 +93,7 @@ public void unknownSchemeRemote() throws Exception { @Test public void roundTripTicket() throws Exception { final Ticket ticket = new Ticket(new byte[]{0, 1, 2, 3, 4, 5}); - Assert.assertEquals(ticket, Ticket.deserialize(ticket.serialize())); + Assertions.assertEquals(ticket, Ticket.deserialize(ticket.serialize())); } @Test @@ -116,17 +116,17 @@ public void roundTripInfo() throws Exception { Location.forGrpcInsecure("localhost", 50051)) ), 200, 500); - Assert.assertEquals(info1, FlightInfo.deserialize(info1.serialize())); - Assert.assertEquals(info2, FlightInfo.deserialize(info2.serialize())); - Assert.assertEquals(info3, FlightInfo.deserialize(info3.serialize())); + Assertions.assertEquals(info1, FlightInfo.deserialize(info1.serialize())); + Assertions.assertEquals(info2, FlightInfo.deserialize(info2.serialize())); + Assertions.assertEquals(info3, FlightInfo.deserialize(info3.serialize())); } @Test public void roundTripDescriptor() throws Exception { final FlightDescriptor cmd = FlightDescriptor.command("test command".getBytes(StandardCharsets.UTF_8)); - Assert.assertEquals(cmd, FlightDescriptor.deserialize(cmd.serialize())); + Assertions.assertEquals(cmd, FlightDescriptor.deserialize(cmd.serialize())); final FlightDescriptor path = FlightDescriptor.path("foo", "bar", "test.arrow"); - Assert.assertEquals(path, FlightDescriptor.deserialize(path.serialize())); + Assertions.assertEquals(path, FlightDescriptor.deserialize(path.serialize())); } @Test @@ -136,7 +136,7 @@ public void getDescriptors() throws Exception { for (FlightInfo i : c.listFlights(Criteria.ALL)) { count += 1; } - Assert.assertEquals(1, count); + Assertions.assertEquals(1, count); }); } @@ -147,7 +147,7 @@ public void getDescriptorsWithCriteria() throws Exception { for (FlightInfo i : c.listFlights(new Criteria(new byte[]{1}))) { count += 1; } - Assert.assertEquals(0, count); + Assertions.assertEquals(0, count); }); } @@ -180,21 +180,21 @@ public void doAction() throws Exception { test(c -> { Iterator stream = c.doAction(new Action("hello")); - Assert.assertTrue(stream.hasNext()); + Assertions.assertTrue(stream.hasNext()); Result r = stream.next(); - Assert.assertArrayEquals("world".getBytes(Charsets.UTF_8), r.getBody()); + Assertions.assertArrayEquals("world".getBytes(Charsets.UTF_8), r.getBody()); }); test(c -> { Iterator stream = c.doAction(new Action("hellooo")); - Assert.assertTrue(stream.hasNext()); + Assertions.assertTrue(stream.hasNext()); Result r = stream.next(); - Assert.assertArrayEquals("world".getBytes(Charsets.UTF_8), r.getBody()); + Assertions.assertArrayEquals("world".getBytes(Charsets.UTF_8), r.getBody()); - Assert.assertTrue(stream.hasNext()); + Assertions.assertTrue(stream.hasNext()); r = stream.next(); - Assert.assertArrayEquals("!".getBytes(Charsets.UTF_8), r.getBody()); - Assert.assertFalse(stream.hasNext()); + Assertions.assertArrayEquals("!".getBytes(Charsets.UTF_8), r.getBody()); + Assertions.assertFalse(stream.hasNext()); }); } @@ -240,7 +240,7 @@ public void putStream() throws Exception { public void propagateErrors() throws Exception { test(client -> { FlightTestUtil.assertCode(FlightStatusCode.UNIMPLEMENTED, () -> { - client.doAction(new Action("invalid-action")).forEachRemaining(action -> Assert.fail()); + client.doAction(new Action("invalid-action")).forEachRemaining(action -> Assertions.fail()); }); }); } @@ -254,7 +254,7 @@ public void getStream() throws Exception { int value = 0; while (stream.next()) { for (int i = 0; i < root.getRowCount(); i++) { - Assert.assertEquals(value, iv.get(i)); + Assertions.assertEquals(value, iv.get(i)); value++; } } @@ -269,12 +269,12 @@ public void getStream() throws Exception { public void getStreamLargeBatch() throws Exception { test(c -> { try (final FlightStream stream = c.getStream(new Ticket(Producer.TICKET_LARGE_BATCH))) { - Assert.assertEquals(128, stream.getRoot().getFieldVectors().size()); - Assert.assertTrue(stream.next()); - Assert.assertEquals(65536, stream.getRoot().getRowCount()); - Assert.assertTrue(stream.next()); - Assert.assertEquals(65536, stream.getRoot().getRowCount()); - Assert.assertFalse(stream.next()); + Assertions.assertEquals(128, stream.getRoot().getFieldVectors().size()); + Assertions.assertTrue(stream.next()); + Assertions.assertEquals(65536, stream.getRoot().getRowCount()); + Assertions.assertTrue(stream.next()); + Assertions.assertEquals(65536, stream.getRoot().getRowCount()); + Assertions.assertFalse(stream.next()); } catch (Exception e) { throw new RuntimeException(e); } @@ -362,28 +362,28 @@ public void testProtobufRecordBatchCompatibility() throws Exception { final MethodDescriptor.Marshaller marshaller = ArrowMessage.createMarshaller(allocator); try (final ArrowMessage message = new ArrowMessage( unloader.getRecordBatch(), /* appMetadata */ null, /* tryZeroCopy */ false, IpcOption.DEFAULT)) { - Assert.assertEquals(ArrowMessage.HeaderType.RECORD_BATCH, message.getMessageType()); + Assertions.assertEquals(ArrowMessage.HeaderType.RECORD_BATCH, message.getMessageType()); // Should have at least one empty body buffer (there may be multiple for e.g. data and validity) Iterator iterator = message.getBufs().iterator(); - Assert.assertTrue(iterator.hasNext()); + Assertions.assertTrue(iterator.hasNext()); while (iterator.hasNext()) { - Assert.assertEquals(0, iterator.next().capacity()); + Assertions.assertEquals(0, iterator.next().capacity()); } final Flight.FlightData protobufData = arrowMessageToProtobuf(marshaller, message) .toBuilder() .clearDataBody() .build(); - Assert.assertEquals(0, protobufData.getDataBody().size()); + Assertions.assertEquals(0, protobufData.getDataBody().size()); ArrowMessage parsedMessage = marshaller.parse(new ByteArrayInputStream(protobufData.toByteArray())); // Should have an empty body buffer Iterator parsedIterator = parsedMessage.getBufs().iterator(); - Assert.assertTrue(parsedIterator.hasNext()); - Assert.assertEquals(0, parsedIterator.next().capacity()); + Assertions.assertTrue(parsedIterator.hasNext()); + Assertions.assertEquals(0, parsedIterator.next().capacity()); // Should have only one (the parser synthesizes exactly one); in the case of empty buffers, this is equivalent - Assert.assertFalse(parsedIterator.hasNext()); + Assertions.assertFalse(parsedIterator.hasNext()); // Should not throw final ArrowRecordBatch rb = parsedMessage.asRecordBatch(); - Assert.assertEquals(rb.computeBodyLength(), 0); + Assertions.assertEquals(rb.computeBodyLength(), 0); } } } @@ -396,17 +396,17 @@ public void testProtobufSchemaCompatibility() throws Exception { final MethodDescriptor.Marshaller marshaller = ArrowMessage.createMarshaller(allocator); Flight.FlightDescriptor descriptor = FlightDescriptor.command(new byte[0]).toProtocol(); try (final ArrowMessage message = new ArrowMessage(descriptor, schema, IpcOption.DEFAULT)) { - Assert.assertEquals(ArrowMessage.HeaderType.SCHEMA, message.getMessageType()); + Assertions.assertEquals(ArrowMessage.HeaderType.SCHEMA, message.getMessageType()); // Should have no body buffers - Assert.assertFalse(message.getBufs().iterator().hasNext()); + Assertions.assertFalse(message.getBufs().iterator().hasNext()); final Flight.FlightData protobufData = arrowMessageToProtobuf(marshaller, message) .toBuilder() .setDataBody(ByteString.EMPTY) .build(); - Assert.assertEquals(0, protobufData.getDataBody().size()); + Assertions.assertEquals(0, protobufData.getDataBody().size()); final ArrowMessage parsedMessage = marshaller.parse(new ByteArrayInputStream(protobufData.toByteArray())); // Should have no body buffers - Assert.assertFalse(parsedMessage.getBufs().iterator().hasNext()); + Assertions.assertFalse(parsedMessage.getBufs().iterator().hasNext()); // Should not throw parsedMessage.asSchema(); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestCallOptions.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestCallOptions.java index d739189e08073..adfa44ef9c805 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestCallOptions.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestCallOptions.java @@ -26,16 +26,16 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import io.grpc.Metadata; public class TestCallOptions { @Test - @Ignore + @Disabled public void timeoutFires() { // Ignored due to CI flakiness test((client) -> { @@ -43,26 +43,26 @@ public void timeoutFires() { Iterator results = client.doAction(new Action("hang"), CallOptions.timeout(1, TimeUnit.SECONDS)); try { results.next(); - Assert.fail("Call should have failed"); + Assertions.fail("Call should have failed"); } catch (RuntimeException e) { - Assert.assertTrue(e.getMessage(), e.getMessage().contains("deadline exceeded")); + Assertions.assertTrue(e.getMessage().contains("deadline exceeded"), e.getMessage()); } Instant end = Instant.now(); - Assert.assertTrue("Call took over 1500 ms despite timeout", Duration.between(start, end).toMillis() < 1500); + Assertions.assertTrue(Duration.between(start, end).toMillis() < 1500, "Call took over 1500 ms despite timeout"); }); } @Test - @Ignore + @Disabled public void underTimeout() { // Ignored due to CI flakiness test((client) -> { Instant start = Instant.now(); // This shouldn't fail and it should complete within the timeout Iterator results = client.doAction(new Action("fast"), CallOptions.timeout(2, TimeUnit.SECONDS)); - Assert.assertArrayEquals(new byte[]{42, 42}, results.next().getBody()); + Assertions.assertArrayEquals(new byte[]{42, 42}, results.next().getBody()); Instant end = Instant.now(); - Assert.assertTrue("Call took over 2500 ms despite timeout", Duration.between(start, end).toMillis() < 2500); + Assertions.assertTrue(Duration.between(start, end).toMillis() < 2500, "Call took over 2500 ms despite timeout"); }); } @@ -104,13 +104,13 @@ private void testHeaders(CallHeaders headers) { FlightServer s = FlightTestUtil.getStartedServer((location) -> FlightServer.builder(a, location, producer).build()); FlightClient client = FlightClient.builder(a, s.getLocation()).build()) { - Assert.assertFalse(client.doAction(new Action(""), new HeaderCallOption(headers)).hasNext()); + Assertions.assertFalse(client.doAction(new Action(""), new HeaderCallOption(headers)).hasNext()); final CallHeaders incomingHeaders = producer.headers(); for (String key : headers.keys()) { if (key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { - Assert.assertArrayEquals(headers.getByte(key), incomingHeaders.getByte(key)); + Assertions.assertArrayEquals(headers.getByte(key), incomingHeaders.getByte(key)); } else { - Assert.assertEquals(headers.get(key), incomingHeaders.get(key)); + Assertions.assertEquals(headers.get(key), incomingHeaders.get(key)); } } } catch (InterruptedException | IOException e) { diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestClientMiddleware.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestClientMiddleware.java index f150a294aa484..a191a597f4157 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestClientMiddleware.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestClientMiddleware.java @@ -28,15 +28,12 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * A basic test of client middleware using a simplified OpenTracing-like example. */ -@RunWith(JUnit4.class) public class TestClientMiddleware { /** @@ -65,9 +62,9 @@ public void middleware_propagateHeader() { FlightTestUtil.assertCode(FlightStatusCode.UNIMPLEMENTED, () -> client.listActions().forEach(actionType -> { })); }); - Assert.assertEquals(context.outgoingSpanId, context.incomingSpanId); - Assert.assertNotNull(context.finalStatus); - Assert.assertEquals(FlightStatusCode.UNIMPLEMENTED, context.finalStatus.code()); + Assertions.assertEquals(context.outgoingSpanId, context.incomingSpanId); + Assertions.assertNotNull(context.finalStatus); + Assertions.assertEquals(FlightStatusCode.UNIMPLEMENTED, context.finalStatus.code()); } /** Ensure both server and client can send and receive multi-valued headers (both binary and text values). */ @@ -87,18 +84,20 @@ public void testMultiValuedHeaders() { for (final Map.Entry> entry : EXPECTED_BINARY_HEADERS.entrySet()) { // Compare header values entry-by-entry because byte arrays don't compare via equals final List receivedValues = clientFactory.lastBinaryHeaders.get(entry.getKey()); - Assert.assertNotNull("Missing for header: " + entry.getKey(), receivedValues); - Assert.assertEquals( - "Missing or wrong value for header: " + entry.getKey(), - entry.getValue().size(), receivedValues.size()); + Assertions.assertNotNull(receivedValues, "Missing for header: " + entry.getKey()); + Assertions.assertEquals( + entry.getValue().size(), + receivedValues.size(), "Missing or wrong value for header: " + entry.getKey()); for (int i = 0; i < entry.getValue().size(); i++) { - Assert.assertArrayEquals(entry.getValue().get(i), receivedValues.get(i)); + Assertions.assertArrayEquals(entry.getValue().get(i), receivedValues.get(i)); } } for (final Map.Entry> entry : EXPECTED_TEXT_HEADERS.entrySet()) { - Assert.assertEquals( - "Missing or wrong value for header: " + entry.getKey(), - entry.getValue(), clientFactory.lastTextHeaders.get(entry.getKey())); + Assertions.assertEquals( + entry.getValue(), + clientFactory.lastTextHeaders.get(entry.getKey()), + "Missing or wrong value for header: " + entry.getKey() + ); } } @@ -329,11 +328,11 @@ public MultiHeaderClientMiddleware(MultiHeaderClientMiddlewareFactory factory) { public void onBeforeSendingHeaders(CallHeaders outgoingHeaders) { for (final Map.Entry> entry : EXPECTED_BINARY_HEADERS.entrySet()) { entry.getValue().forEach((value) -> outgoingHeaders.insert(entry.getKey(), value)); - Assert.assertTrue(outgoingHeaders.containsKey(entry.getKey())); + Assertions.assertTrue(outgoingHeaders.containsKey(entry.getKey())); } for (final Map.Entry> entry : EXPECTED_TEXT_HEADERS.entrySet()) { entry.getValue().forEach((value) -> outgoingHeaders.insert(entry.getKey(), value)); - Assert.assertTrue(outgoingHeaders.containsKey(entry.getKey())); + Assertions.assertTrue(outgoingHeaders.containsKey(entry.getKey())); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDictionaryUtils.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDictionaryUtils.java index b5bf117c62848..b3a716ab3cec5 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDictionaryUtils.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDictionaryUtils.java @@ -32,7 +32,7 @@ import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDoExchange.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDoExchange.java index 6c9b560342b70..c2f8e75596904 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDoExchange.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestDoExchange.java @@ -17,12 +17,12 @@ package org.apache.arrow.flight; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -43,10 +43,10 @@ import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class TestDoExchange { static byte[] EXCHANGE_DO_GET = "do-get".getBytes(StandardCharsets.UTF_8); @@ -60,7 +60,7 @@ public class TestDoExchange { private FlightServer server; private FlightClient client; - @Before + @BeforeEach public void setUp() throws Exception { allocator = new RootAllocator(Integer.MAX_VALUE); final Location serverLocation = Location.forGrpcInsecure(FlightTestUtil.LOCALHOST, 0); @@ -70,7 +70,7 @@ public void setUp() throws Exception { client = FlightClient.builder(allocator, clientLocation).build(); } - @After + @AfterEach public void tearDown() throws Exception { AutoCloseables.close(client, server, allocator); } @@ -115,7 +115,7 @@ public void testDoExchangeDoGet() throws Exception { int value = 0; while (reader.next()) { for (int i = 0; i < root.getRowCount(); i++) { - assertFalse(String.format("Row %d should not be null", value), iv.isNull(i)); + assertFalse(iv.isNull(i), String.format("Row %d should not be null", value)); assertEquals(value, iv.get(i)); value++; } @@ -200,7 +200,7 @@ public void testDoExchangeEcho() throws Exception { stream.getWriter().completed(); // The server will end its side of the call, so this shouldn't block or indicate that // there is more data. - assertFalse("We should not be waiting for any messages", reader.next()); + assertFalse(reader.next(), "We should not be waiting for any messages"); } } @@ -233,7 +233,7 @@ public void testTransform() throws Exception { assertEquals(schema, reader.getSchema()); final VectorSchemaRoot root = reader.getRoot(); for (int batchIndex = 0; batchIndex < 10; batchIndex++) { - assertTrue("Didn't receive batch #" + batchIndex, reader.next()); + assertTrue(reader.next(), "Didn't receive batch #" + batchIndex); assertEquals(batchIndex, root.getRowCount()); for (final FieldVector rawVec : root.getFieldVectors()) { final IntVector vec = (IntVector) rawVec; @@ -244,9 +244,9 @@ public void testTransform() throws Exception { } // The server also sends back a metadata-only message containing the message count - assertTrue("There should be one extra message", reader.next()); + assertTrue(reader.next(), "There should be one extra message"); assertEquals(10, reader.getLatestMetadata().getInt(0)); - assertFalse("There should be no more data", reader.next()); + assertFalse(reader.next(), "There should be no more data"); } } @@ -289,7 +289,7 @@ public void testTransformZeroCopy() throws Exception { assertEquals(schema, reader.getSchema()); final VectorSchemaRoot root = reader.getRoot(); for (int batchIndex = 0; batchIndex < 100; batchIndex++) { - assertTrue("Didn't receive batch #" + batchIndex, reader.next()); + assertTrue(reader.next(), "Didn't receive batch #" + batchIndex); assertEquals(rowsPerBatch, root.getRowCount()); for (final FieldVector rawVec : root.getFieldVectors()) { final IntVector vec = (IntVector) rawVec; @@ -300,9 +300,9 @@ public void testTransformZeroCopy() throws Exception { } // The server also sends back a metadata-only message containing the message count - assertTrue("There should be one extra message", reader.next()); + assertTrue(reader.next(), "There should be one extra message"); assertEquals(100, reader.getLatestMetadata().getInt(0)); - assertFalse("There should be no more data", reader.next()); + assertFalse(reader.next(), "There should be no more data"); } } @@ -354,7 +354,7 @@ public void testServerCancelLeak() throws Exception { /** Have the client cancel without reading; ensure memory is not leaked. */ @Test - @Ignore + @Disabled public void testClientCancel() throws Exception { try (final FlightClient.ExchangeReaderWriter stream = client.doExchange(FlightDescriptor.command(EXCHANGE_DO_GET))) { diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestErrorMetadata.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestErrorMetadata.java index 2c62bc7fa6837..1f1bbbe50fb09 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestErrorMetadata.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestErrorMetadata.java @@ -20,8 +20,8 @@ import org.apache.arrow.flight.perf.impl.PerfOuterClass; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.google.protobuf.Any; import com.google.protobuf.InvalidProtocolBufferException; @@ -58,21 +58,21 @@ public void testGrpcMetadata() throws Exception { }); PerfOuterClass.Perf newPerf = null; ErrorFlightMetadata metadata = flightStatus.metadata(); - Assert.assertNotNull(metadata); - Assert.assertEquals(2, metadata.keys().size()); - Assert.assertTrue(metadata.containsKey("grpc-status-details-bin")); + Assertions.assertNotNull(metadata); + Assertions.assertEquals(2, metadata.keys().size()); + Assertions.assertTrue(metadata.containsKey("grpc-status-details-bin")); Status status = marshaller.parseBytes(metadata.getByte("grpc-status-details-bin")); for (Any details : status.getDetailsList()) { if (details.is(PerfOuterClass.Perf.class)) { try { newPerf = details.unpack(PerfOuterClass.Perf.class); } catch (InvalidProtocolBufferException e) { - Assert.fail(); + Assertions.fail(); } } } - Assert.assertNotNull(newPerf); - Assert.assertEquals(perf, newPerf); + Assertions.assertNotNull(newPerf); + Assertions.assertEquals(perf, newPerf); } } @@ -89,17 +89,17 @@ public void testFlightMetadata() throws Exception { stream.next(); }); ErrorFlightMetadata metadata = flightStatus.metadata(); - Assert.assertNotNull(metadata); - Assert.assertEquals("foo", metadata.get("x-foo")); - Assert.assertArrayEquals(new byte[]{1}, metadata.getByte("x-bar-bin")); + Assertions.assertNotNull(metadata); + Assertions.assertEquals("foo", metadata.get("x-foo")); + Assertions.assertArrayEquals(new byte[]{1}, metadata.getByte("x-bar-bin")); flightStatus = FlightTestUtil.assertCode(FlightStatusCode.INVALID_ARGUMENT, () -> { client.getInfo(FlightDescriptor.command(new byte[0])); }); metadata = flightStatus.metadata(); - Assert.assertNotNull(metadata); - Assert.assertEquals("foo", metadata.get("x-foo")); - Assert.assertArrayEquals(new byte[]{1}, metadata.getByte("x-bar-bin")); + Assertions.assertNotNull(metadata); + Assertions.assertEquals("foo", metadata.get("x-foo")); + Assertions.assertArrayEquals(new byte[]{1}, metadata.getByte("x-bar-bin")); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightClient.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightClient.java index 30e351e941a2b..d6cc175b99d18 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightClient.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightClient.java @@ -40,10 +40,9 @@ import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class TestFlightClient { /** @@ -63,7 +62,7 @@ public void independentShutdown() throws Exception { final ClientStreamListener listener = client1.startPut(FlightDescriptor.path("test"), root, new AsyncPutListener()); try (final FlightClient client2 = FlightClient.builder(allocator, location).build()) { - client2.listActions().forEach(actionType -> Assert.assertNotNull(actionType.getType())); + client2.listActions().forEach(actionType -> Assertions.assertNotNull(actionType.getType())); } listener.completed(); listener.getResult(); @@ -74,7 +73,7 @@ public void independentShutdown() throws Exception { /** * ARROW-5978: make sure that we can properly close a client/stream after requesting dictionaries. */ - @Ignore // Unfortunately this test is flaky in CI. + @Disabled // Unfortunately this test is flaky in CI. @Test public void freeDictionaries() throws Exception { final Schema expectedSchema = new Schema(Collections @@ -88,18 +87,18 @@ public void freeDictionaries() throws Exception { final Location location = Location.forGrpcInsecure(FlightTestUtil.LOCALHOST, server.getPort()); try (final FlightClient client = FlightClient.builder(allocator, location).build()) { try (final FlightStream stream = client.getStream(new Ticket(new byte[0]))) { - Assert.assertTrue(stream.next()); - Assert.assertNotNull(stream.getDictionaryProvider().lookup(1)); + Assertions.assertTrue(stream.next()); + Assertions.assertNotNull(stream.getDictionaryProvider().lookup(1)); final VectorSchemaRoot root = stream.getRoot(); - Assert.assertEquals(expectedSchema, root.getSchema()); - Assert.assertEquals(6, root.getVector("encoded").getValueCount()); + Assertions.assertEquals(expectedSchema, root.getSchema()); + Assertions.assertEquals(6, root.getVector("encoded").getValueCount()); try (final ValueVector decoded = DictionaryEncoder .decode(root.getVector("encoded"), stream.getDictionaryProvider().lookup(1))) { - Assert.assertFalse(decoded.isNull(1)); - Assert.assertTrue(decoded instanceof VarCharVector); - Assert.assertArrayEquals("one".getBytes(StandardCharsets.UTF_8), ((VarCharVector) decoded).get(1)); + Assertions.assertFalse(decoded.isNull(1)); + Assertions.assertTrue(decoded instanceof VarCharVector); + Assertions.assertArrayEquals("one".getBytes(StandardCharsets.UTF_8), ((VarCharVector) decoded).get(1)); } - Assert.assertFalse(stream.next()); + Assertions.assertFalse(stream.next()); } // Closing stream fails if it doesn't free dictionaries; closing dictionaries fails (refcount goes negative) // if reference isn't retained in ArrowMessage @@ -110,7 +109,7 @@ public void freeDictionaries() throws Exception { /** * ARROW-5978: make sure that dictionary ownership can't be claimed twice. */ - @Ignore // Unfortunately this test is flaky in CI. + @Disabled // Unfortunately this test is flaky in CI. @Test public void ownDictionaries() throws Exception { try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); @@ -121,8 +120,8 @@ public void ownDictionaries() throws Exception { final Location location = Location.forGrpcInsecure(FlightTestUtil.LOCALHOST, server.getPort()); try (final FlightClient client = FlightClient.builder(allocator, location).build()) { try (final FlightStream stream = client.getStream(new Ticket(new byte[0]))) { - Assert.assertTrue(stream.next()); - Assert.assertFalse(stream.next()); + Assertions.assertTrue(stream.next()); + Assertions.assertFalse(stream.next()); final DictionaryProvider provider = stream.takeDictionaryOwnership(); Assertions.assertThrows(IllegalStateException.class, stream::takeDictionaryOwnership); Assertions.assertThrows(IllegalStateException.class, stream::getDictionaryProvider); @@ -135,7 +134,7 @@ public void ownDictionaries() throws Exception { /** * ARROW-5978: make sure that dictionaries can be used after closing the stream. */ - @Ignore // Unfortunately this test is flaky in CI. + @Disabled // Unfortunately this test is flaky in CI. @Test public void useDictionariesAfterClose() throws Exception { try (final BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); @@ -160,9 +159,9 @@ public void useDictionariesAfterClose() throws Exception { } try (final ValueVector decoded = DictionaryEncoder .decode(root.getVector("encoded"), provider.lookup(1))) { - Assert.assertFalse(decoded.isNull(1)); - Assert.assertTrue(decoded instanceof VarCharVector); - Assert.assertArrayEquals("one".getBytes(StandardCharsets.UTF_8), ((VarCharVector) decoded).get(1)); + Assertions.assertFalse(decoded.isNull(1)); + Assertions.assertTrue(decoded instanceof VarCharVector); + Assertions.assertArrayEquals("one".getBytes(StandardCharsets.UTF_8), ((VarCharVector) decoded).get(1)); } root.close(); DictionaryUtils.closeDictionaries(root.getSchema(), provider); diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightService.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightService.java index 65ef12a8acfb1..fb47a84164b88 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightService.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestFlightService.java @@ -23,9 +23,9 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.util.AutoCloseables; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import io.grpc.stub.ServerCallStreamObserver; @@ -33,12 +33,12 @@ public class TestFlightService { private BufferAllocator allocator; - @Before + @BeforeEach public void setup() { allocator = new RootAllocator(Long.MAX_VALUE); } - @After + @AfterEach public void cleanup() throws Exception { AutoCloseables.close(allocator); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLargeMessage.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLargeMessage.java index 629b6f5ebd8bc..7c7011a8cd271 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLargeMessage.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLargeMessage.java @@ -29,8 +29,8 @@ import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TestLargeMessage { /** @@ -51,7 +51,7 @@ public void getLargeMessage() throws Exception { int value = 0; final IntVector iv = (IntVector) root.getVector(field.getName()); for (int i = 0; i < root.getRowCount(); i++) { - Assert.assertEquals(value, iv.get(i)); + Assertions.assertEquals(value, iv.get(i)); value++; } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLeak.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLeak.java index 6e28704997f6e..9c9da1249a320 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLeak.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestLeak.java @@ -29,7 +29,7 @@ import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests for scenarios where Flight could leak memory. diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestMetadataVersion.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestMetadataVersion.java index 83a694bf34e51..d6efa4ff80058 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestMetadataVersion.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestMetadataVersion.java @@ -17,10 +17,10 @@ package org.apache.arrow.flight; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -36,9 +36,9 @@ import org.apache.arrow.vector.types.pojo.ArrowType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Test clients/servers with different metadata versions. @@ -50,7 +50,7 @@ public class TestMetadataVersion { private static IpcOption optionV5; private static Schema unionSchema; - @BeforeClass + @BeforeAll public static void setUpClass() { allocator = new RootAllocator(Integer.MAX_VALUE); schema = new Schema(Collections.singletonList(Field.nullable("foo", new ArrowType.Int(32, true)))); @@ -62,7 +62,7 @@ public static void setUpClass() { optionV5 = IpcOption.DEFAULT; } - @AfterClass + @AfterAll public static void tearDownClass() { allocator.close(); } @@ -94,7 +94,7 @@ public void testUnionCheck() throws Exception { final FlightClient client = connect(server); final FlightStream stream = client.getStream(new Ticket("union".getBytes(StandardCharsets.UTF_8)))) { final FlightRuntimeException err = assertThrows(FlightRuntimeException.class, stream::next); - assertTrue(err.getMessage(), err.getMessage().contains("Cannot write union with V4 metadata")); + assertTrue(err.getMessage().contains("Cannot write union with V4 metadata"), err.getMessage()); } try (final FlightServer server = startServer(optionV4); @@ -105,7 +105,7 @@ public void testUnionCheck() throws Exception { final FlightClient.ClientStreamListener listener = client.startPut(descriptor, reader); final IllegalArgumentException err = assertThrows(IllegalArgumentException.class, () -> listener.start(root, null, optionV4)); - assertTrue(err.getMessage(), err.getMessage().contains("Cannot write union with V4 metadata")); + assertTrue(err.getMessage().contains("Cannot write union with V4 metadata"), err.getMessage()); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerMiddleware.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerMiddleware.java index 1f3e35ca38dc9..79c5811c490eb 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerMiddleware.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerMiddleware.java @@ -30,12 +30,9 @@ import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.vector.VectorSchemaRoot; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; -@RunWith(JUnit4.class) public class TestServerMiddleware { private static final RuntimeException EXPECTED_EXCEPTION = new RuntimeException("test"); @@ -56,9 +53,9 @@ public void doPutErrors() { } }, (recorder) -> { final CallStatus status = recorder.statusFuture.get(); - Assert.assertNotNull(status); - Assert.assertNotNull(status.cause()); - Assert.assertEquals(FlightStatusCode.INTERNAL, status.code()); + Assertions.assertNotNull(status); + Assertions.assertNotNull(status.cause()); + Assertions.assertEquals(FlightStatusCode.INTERNAL, status.code()); }); // Check the status after server shutdown (to make sure gRPC finishes pending calls on the server side) } @@ -79,10 +76,10 @@ public void doPutCustomCode() { } }, (recorder) -> { final CallStatus status = recorder.statusFuture.get(); - Assert.assertNotNull(status); - Assert.assertNull(status.cause()); - Assert.assertEquals(FlightStatusCode.UNAVAILABLE, status.code()); - Assert.assertEquals("description", status.description()); + Assertions.assertNotNull(status); + Assertions.assertNull(status.cause()); + Assertions.assertEquals(FlightStatusCode.UNAVAILABLE, status.code()); + Assertions.assertEquals("description", status.description()); }); } @@ -102,11 +99,11 @@ public void doPutUncaught() { }, (recorder) -> { final CallStatus status = recorder.statusFuture.get(); final Throwable err = recorder.errFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.OK, status.code()); - Assert.assertNull(status.cause()); - Assert.assertNotNull(err); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.OK, status.code()); + Assertions.assertNull(status.cause()); + Assertions.assertNotNull(err); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); }); } @@ -117,11 +114,11 @@ public void listFlightsUncaught() { }), (recorder) -> { final CallStatus status = recorder.statusFuture.get(); final Throwable err = recorder.errFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.OK, status.code()); - Assert.assertNull(status.cause()); - Assert.assertNotNull(err); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.OK, status.code()); + Assertions.assertNull(status.cause()); + Assertions.assertNotNull(err); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); }); } @@ -132,11 +129,11 @@ public void doActionUncaught() { }), (recorder) -> { final CallStatus status = recorder.statusFuture.get(); final Throwable err = recorder.errFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.OK, status.code()); - Assert.assertNull(status.cause()); - Assert.assertNotNull(err); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.OK, status.code()); + Assertions.assertNull(status.cause()); + Assertions.assertNotNull(err); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); }); } @@ -147,11 +144,11 @@ public void listActionsUncaught() { }), (recorder) -> { final CallStatus status = recorder.statusFuture.get(); final Throwable err = recorder.errFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.OK, status.code()); - Assert.assertNull(status.cause()); - Assert.assertNotNull(err); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.OK, status.code()); + Assertions.assertNull(status.cause()); + Assertions.assertNotNull(err); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); }); } @@ -162,10 +159,10 @@ public void getFlightInfoUncaught() { FlightTestUtil.assertCode(FlightStatusCode.INTERNAL, () -> client.getInfo(FlightDescriptor.path("test"))); }, (recorder) -> { final CallStatus status = recorder.statusFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.INTERNAL, status.code()); - Assert.assertNotNull(status.cause()); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), status.cause().getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.INTERNAL, status.code()); + Assertions.assertNotNull(status.cause()); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), status.cause().getMessage()); }); } @@ -177,16 +174,16 @@ public void doGetUncaught() { while (stream.next()) { } } catch (Exception e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } }, (recorder) -> { final CallStatus status = recorder.statusFuture.get(); final Throwable err = recorder.errFuture.get(); - Assert.assertNotNull(status); - Assert.assertEquals(FlightStatusCode.OK, status.code()); - Assert.assertNull(status.cause()); - Assert.assertNotNull(err); - Assert.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); + Assertions.assertNotNull(status); + Assertions.assertEquals(FlightStatusCode.OK, status.code()); + Assertions.assertNull(status.cause()); + Assertions.assertNotNull(err); + Assertions.assertEquals(EXPECTED_EXCEPTION.getMessage(), err.getMessage()); }); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerOptions.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerOptions.java index 363ad443e48f2..03f11cec10f8c 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerOptions.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestServerOptions.java @@ -17,8 +17,8 @@ package org.apache.arrow.flight; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.File; import java.util.HashMap; @@ -35,17 +35,14 @@ import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.vector.IntVector; import org.apache.arrow.vector.VectorSchemaRoot; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; import io.grpc.MethodDescriptor; import io.grpc.ServerServiceDefinition; import io.grpc.netty.NettyServerBuilder; -@RunWith(JUnit4.class) public class TestServerOptions { @Test @@ -61,7 +58,7 @@ public void builderConsumer() throws Exception { (location) -> FlightServer.builder(a, location, producer) .transportHint("grpc.builderConsumer", consumer).build() )) { - Assert.assertTrue(consumerCalled.get()); + Assertions.assertTrue(consumerCalled.get()); } } @@ -81,7 +78,7 @@ public void defaultExecutorClosed() throws Exception { assertNotNull(server.grpcExecutor); executor = server.grpcExecutor; } - Assert.assertTrue(executor.isShutdown()); + Assertions.assertTrue(executor.isShutdown()); } /** @@ -99,9 +96,9 @@ public void suppliedExecutorNotClosed() throws Exception { .executor(executor) .build() )) { - Assert.assertNull(server.grpcExecutor); + Assertions.assertNull(server.grpcExecutor); } - Assert.assertFalse(executor.isShutdown()); + Assertions.assertFalse(executor.isShutdown()); } finally { executor.shutdown(); } @@ -109,12 +106,12 @@ public void suppliedExecutorNotClosed() throws Exception { @Test public void domainSocket() throws Exception { - Assume.assumeTrue("We have a native transport available", FlightTestUtil.isNativeTransportAvailable()); + Assumptions.assumeTrue(FlightTestUtil.isNativeTransportAvailable(), "We have a native transport available"); final File domainSocket = File.createTempFile("flight-unit-test-", ".sock"); - Assert.assertTrue(domainSocket.delete()); + Assertions.assertTrue(domainSocket.delete()); // Domain socket paths have a platform-dependent limit. Set a conservative limit and skip the test if the temporary // file name is too long. (We do not assume a particular platform-dependent temporary directory path.) - Assume.assumeTrue("The domain socket path is not too long", domainSocket.getAbsolutePath().length() < 100); + Assumptions.assumeTrue(domainSocket.getAbsolutePath().length() < 100, "The domain socket path is not too long"); final Location location = Location.forGrpcDomainSocket(domainSocket.getAbsolutePath()); try ( BufferAllocator a = new RootAllocator(Long.MAX_VALUE); @@ -130,7 +127,7 @@ public void domainSocket() throws Exception { int value = 0; while (stream.next()) { for (int i = 0; i < root.getRowCount(); i++) { - Assert.assertEquals(value, iv.get(i)); + Assertions.assertEquals(value, iv.get(i)); value++; } } @@ -161,10 +158,10 @@ public void checkReflectionMetadata() { for (final MethodDescriptor descriptor : FlightServiceGrpc.getServiceDescriptor().getMethods()) { final String methodName = descriptor.getFullMethodName(); - Assert.assertTrue("Method is missing from ServerServiceDefinition: " + methodName, - definedMethods.containsKey(methodName)); - Assert.assertTrue("Method is missing from ServiceDescriptor: " + methodName, - definedMethods.containsKey(methodName)); + Assertions.assertTrue(definedMethods.containsKey(methodName), + "Method is missing from ServerServiceDefinition: " + methodName); + Assertions.assertTrue(definedMethods.containsKey(methodName), + "Method is missing from ServiceDescriptor: " + methodName); assertEquals(descriptor.getSchemaDescriptor(), definedMethods.get(methodName).getSchemaDescriptor()); assertEquals(descriptor.getSchemaDescriptor(), serviceMethods.get(methodName).getSchemaDescriptor()); diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestTls.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestTls.java index c5cd871e2bead..a552f635b9cc6 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestTls.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/TestTls.java @@ -27,8 +27,8 @@ import org.apache.arrow.flight.FlightClient.Builder; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests for TLS in Flight. @@ -45,8 +45,8 @@ public void connectTls() { final FlightClient client = builder.trustedCertificates(roots).build()) { final Iterator responses = client.doAction(new Action("hello-world")); final byte[] response = responses.next().getBody(); - Assert.assertEquals("Hello, world!", new String(response, StandardCharsets.UTF_8)); - Assert.assertFalse(responses.hasNext()); + Assertions.assertEquals("Hello, world!", new String(response, StandardCharsets.UTF_8)); + Assertions.assertFalse(responses.hasNext()); } catch (InterruptedException | IOException e) { throw new RuntimeException(e); } @@ -94,8 +94,8 @@ public void connectTlsDisableServerVerification() { try (final FlightClient client = builder.verifyServer(false).build()) { final Iterator responses = client.doAction(new Action("hello-world")); final byte[] response = responses.next().getBody(); - Assert.assertEquals("Hello, world!", new String(response, StandardCharsets.UTF_8)); - Assert.assertFalse(responses.hasNext()); + Assertions.assertEquals("Hello, world!", new String(response, StandardCharsets.UTF_8)); + Assertions.assertFalse(responses.hasNext()); } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth/TestBasicAuth.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth/TestBasicAuth.java index c18f5709b54fb..6ec507b5906c4 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth/TestBasicAuth.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth/TestBasicAuth.java @@ -38,11 +38,11 @@ import org.apache.arrow.vector.types.Types; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.google.common.collect.ImmutableList; @@ -59,18 +59,18 @@ public class TestBasicAuth { @Test public void validAuth() { client.authenticateBasic(USERNAME, PASSWORD); - Assert.assertTrue(ImmutableList.copyOf(client.listFlights(Criteria.ALL)).size() == 0); + Assertions.assertTrue(ImmutableList.copyOf(client.listFlights(Criteria.ALL)).size() == 0); } // ARROW-7722: this test occasionally leaks memory - @Ignore + @Disabled @Test public void asyncCall() throws Exception { client.authenticateBasic(USERNAME, PASSWORD); client.listFlights(Criteria.ALL); try (final FlightStream s = client.getStream(new Ticket(new byte[1]))) { while (s.next()) { - Assert.assertEquals(4095, s.getRoot().getRowCount()); + Assertions.assertEquals(4095, s.getRoot().getRowCount()); } } } @@ -82,18 +82,18 @@ public void invalidAuth() { }); FlightTestUtil.assertCode(FlightStatusCode.UNAUTHENTICATED, () -> { - client.listFlights(Criteria.ALL).forEach(action -> Assert.fail()); + client.listFlights(Criteria.ALL).forEach(action -> Assertions.fail()); }); } @Test public void didntAuth() { FlightTestUtil.assertCode(FlightStatusCode.UNAUTHENTICATED, () -> { - client.listFlights(Criteria.ALL).forEach(action -> Assert.fail()); + client.listFlights(Criteria.ALL).forEach(action -> Assertions.fail()); }); } - @Before + @BeforeEach public void setup() throws IOException { allocator = new RootAllocator(Long.MAX_VALUE); final BasicServerAuthHandler.BasicAuthValidator validator = new BasicServerAuthHandler.BasicAuthValidator() { @@ -150,7 +150,7 @@ public void getStream(CallContext context, Ticket ticket, ServerStreamListener l client = FlightClient.builder(allocator, server.getLocation()).build(); } - @After + @AfterEach public void shutdown() throws Exception { AutoCloseables.close(client, server, allocator); } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth2/TestBasicAuth2.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth2/TestBasicAuth2.java index 9bec32f1b7217..310971ba958d2 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth2/TestBasicAuth2.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/auth2/TestBasicAuth2.java @@ -38,11 +38,11 @@ import org.apache.arrow.vector.types.Types; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; @@ -59,7 +59,7 @@ public class TestBasicAuth2 { private FlightClient client; private FlightClient client2; - @Before + @BeforeEach public void setup() throws Exception { allocator = new RootAllocator(Long.MAX_VALUE); startServerAndClient(); @@ -108,7 +108,7 @@ private void startServerAndClient() throws IOException { .build(); } - @After + @AfterEach public void shutdown() throws Exception { AutoCloseables.close(client, client2, server, allocator); client = null; @@ -155,7 +155,7 @@ public void validAuthWithMultipleClientsWithDifferentCredentialsWithBearerAuthSe } // ARROW-7722: this test occasionally leaks memory - @Ignore + @Disabled @Test public void asyncCall() throws Exception { final CredentialCallOption bearerToken = client @@ -163,7 +163,7 @@ public void asyncCall() throws Exception { client.listFlights(Criteria.ALL, bearerToken); try (final FlightStream s = client.getStream(new Ticket(new byte[1]))) { while (s.next()) { - Assert.assertEquals(4095, s.getRoot().getRowCount()); + Assertions.assertEquals(4095, s.getRoot().getRowCount()); } } } @@ -181,7 +181,7 @@ public void didntAuthWithBearerAuthServer() throws IOException { private void testValidAuth(FlightClient client) { final CredentialCallOption bearerToken = client .authenticateBasicToken(USERNAME_1, PASSWORD_1).get(); - Assert.assertTrue(ImmutableList.copyOf(client + Assertions.assertTrue(ImmutableList.copyOf(client .listFlights(Criteria.ALL, bearerToken)) .isEmpty()); } @@ -192,10 +192,10 @@ private void testValidAuthWithMultipleClientsWithSameCredentials( .authenticateBasicToken(USERNAME_1, PASSWORD_1).get(); final CredentialCallOption bearerToken2 = client2 .authenticateBasicToken(USERNAME_1, PASSWORD_1).get(); - Assert.assertTrue(ImmutableList.copyOf(client1 + Assertions.assertTrue(ImmutableList.copyOf(client1 .listFlights(Criteria.ALL, bearerToken1)) .isEmpty()); - Assert.assertTrue(ImmutableList.copyOf(client2 + Assertions.assertTrue(ImmutableList.copyOf(client2 .listFlights(Criteria.ALL, bearerToken2)) .isEmpty()); } @@ -206,10 +206,10 @@ private void testValidAuthWithMultipleClientsWithDifferentCredentials( .authenticateBasicToken(USERNAME_1, PASSWORD_1).get(); final CredentialCallOption bearerToken2 = client2 .authenticateBasicToken(USERNAME_2, PASSWORD_2).get(); - Assert.assertTrue(ImmutableList.copyOf(client1 + Assertions.assertTrue(ImmutableList.copyOf(client1 .listFlights(Criteria.ALL, bearerToken1)) .isEmpty()); - Assert.assertTrue(ImmutableList.copyOf(client2 + Assertions.assertTrue(ImmutableList.copyOf(client2 .listFlights(Criteria.ALL, bearerToken2)) .isEmpty()); } @@ -222,11 +222,11 @@ private void testInvalidAuth(FlightClient client) { client.authenticateBasicToken(NO_USERNAME, PASSWORD_1)); FlightTestUtil.assertCode(FlightStatusCode.UNAUTHENTICATED, () -> - client.listFlights(Criteria.ALL).forEach(action -> Assert.fail())); + client.listFlights(Criteria.ALL).forEach(action -> Assertions.fail())); } private void didntAuth(FlightClient client) { FlightTestUtil.assertCode(FlightStatusCode.UNAUTHENTICATED, () -> - client.listFlights(Criteria.ALL).forEach(action -> Assert.fail())); + client.listFlights(Criteria.ALL).forEach(action -> Assertions.fail())); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/TestCookieHandling.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/TestCookieHandling.java index f205f9a3b63de..235bcbadb3bd6 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/TestCookieHandling.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/client/TestCookieHandling.java @@ -36,11 +36,11 @@ import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.util.AutoCloseables; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * Tests for correct handling of cookies from the FlightClient using {@link ClientCookieMiddleware}. @@ -55,13 +55,13 @@ public class TestCookieHandling { private ClientCookieMiddlewareTestFactory testFactory = new ClientCookieMiddlewareTestFactory(); private ClientCookieMiddleware cookieMiddleware = new ClientCookieMiddleware(testFactory); - @Before + @BeforeEach public void setup() throws Exception { allocator = new RootAllocator(Long.MAX_VALUE); startServerAndClient(); } - @After + @AfterEach public void cleanup() throws Exception { testFactory = new ClientCookieMiddlewareTestFactory(); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); @@ -77,7 +77,7 @@ public void basicCookie() { headersToSend.insert(SET_COOKIE_HEADER, "k=v"); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); } @Test @@ -86,20 +86,20 @@ public void cookieStaysAfterMultipleRequests() { headersToSend.insert(SET_COOKIE_HEADER, "k=v"); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); headersToSend = new ErrorFlightMetadata(); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); headersToSend = new ErrorFlightMetadata(); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); } - @Ignore + @Disabled @Test public void cookieAutoExpires() { CallHeaders headersToSend = new ErrorFlightMetadata(); @@ -107,12 +107,12 @@ public void cookieAutoExpires() { cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); // Note: using max-age changes cookie version from 0->1, which quotes values. - Assert.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); headersToSend = new ErrorFlightMetadata(); cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); try { Thread.sleep(5000); @@ -120,7 +120,7 @@ public void cookieAutoExpires() { } // Verify that the k cookie was discarded because it expired. - Assert.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); + Assertions.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); } @Test @@ -130,7 +130,7 @@ public void cookieExplicitlyExpires() { cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); // Note: using max-age changes cookie version from 0->1, which quotes values. - Assert.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); // Note: The JDK treats Max-Age < 0 as not expired and treats 0 as expired. // This violates the RFC, which states that less than zero and zero should both be expired. @@ -140,10 +140,10 @@ public void cookieExplicitlyExpires() { cookieMiddleware.onHeadersReceived(headersToSend); // Verify that the k cookie was discarded because the server told the client it is expired. - Assert.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); + Assertions.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); } - @Ignore + @Disabled @Test public void cookieExplicitlyExpiresWithMaxAgeMinusOne() { CallHeaders headersToSend = new ErrorFlightMetadata(); @@ -151,7 +151,7 @@ public void cookieExplicitlyExpiresWithMaxAgeMinusOne() { cookieMiddleware = testFactory.onCallStarted(new CallInfo(FlightMethod.DO_ACTION)); cookieMiddleware.onHeadersReceived(headersToSend); // Note: using max-age changes cookie version from 0->1, which quotes values. - Assert.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=\"v\"", cookieMiddleware.getValidCookiesAsString()); headersToSend = new ErrorFlightMetadata(); @@ -162,7 +162,7 @@ public void cookieExplicitlyExpiresWithMaxAgeMinusOne() { cookieMiddleware.onHeadersReceived(headersToSend); // Verify that the k cookie was discarded because the server told the client it is expired. - Assert.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); + Assertions.assertTrue(cookieMiddleware.getValidCookiesAsString().isEmpty()); } @Test @@ -170,12 +170,12 @@ public void changeCookieValue() { CallHeaders headersToSend = new ErrorFlightMetadata(); headersToSend.insert(SET_COOKIE_HEADER, "k=v"); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", cookieMiddleware.getValidCookiesAsString()); headersToSend = new ErrorFlightMetadata(); headersToSend.insert(SET_COOKIE_HEADER, "k=v2"); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("k=v2", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v2", cookieMiddleware.getValidCookiesAsString()); } @Test @@ -184,17 +184,17 @@ public void multipleCookiesWithSetCookie() { headersToSend.insert(SET_COOKIE_HEADER, "firstKey=firstVal"); headersToSend.insert(SET_COOKIE_HEADER, "secondKey=secondVal"); cookieMiddleware.onHeadersReceived(headersToSend); - Assert.assertEquals("firstKey=firstVal; secondKey=secondVal", cookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("firstKey=firstVal; secondKey=secondVal", cookieMiddleware.getValidCookiesAsString()); } @Test public void cookieStaysAfterMultipleRequestsEndToEnd() { client.handshake(); - Assert.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); client.handshake(); - Assert.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); client.listFlights(Criteria.ALL); - Assert.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); + Assertions.assertEquals("k=v", testFactory.clientCookieMiddleware.getValidCookiesAsString()); } /** diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/grpc/TestStatusUtils.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/grpc/TestStatusUtils.java index 5d76e8ae14460..9912a26ea340a 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/grpc/TestStatusUtils.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/grpc/TestStatusUtils.java @@ -19,8 +19,8 @@ import org.apache.arrow.flight.CallStatus; import org.apache.arrow.flight.FlightStatusCode; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import io.grpc.Metadata; import io.grpc.Status; @@ -40,12 +40,12 @@ public void testParseTrailers() { CallStatus callStatus = StatusUtils.fromGrpcStatusAndTrailers(status, trailers); - Assert.assertEquals(FlightStatusCode.CANCELLED, callStatus.code()); - Assert.assertTrue(callStatus.metadata().containsKey(":status")); - Assert.assertEquals("502", callStatus.metadata().get(":status")); - Assert.assertTrue(callStatus.metadata().containsKey("date")); - Assert.assertEquals("Fri, 13 Sep 2015 11:23:58 GMT", callStatus.metadata().get("date")); - Assert.assertTrue(callStatus.metadata().containsKey("content-type")); - Assert.assertEquals("text/html", callStatus.metadata().get("content-type")); + Assertions.assertEquals(FlightStatusCode.CANCELLED, callStatus.code()); + Assertions.assertTrue(callStatus.metadata().containsKey(":status")); + Assertions.assertEquals("502", callStatus.metadata().get(":status")); + Assertions.assertTrue(callStatus.metadata().containsKey("date")); + Assertions.assertEquals("Fri, 13 Sep 2015 11:23:58 GMT", callStatus.metadata().get("date")); + Assertions.assertTrue(callStatus.metadata().containsKey("content-type")); + Assertions.assertEquals("text/html", callStatus.metadata().get("content-type")); } } diff --git a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/perf/TestPerf.java b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/perf/TestPerf.java index 9e2d7cc544f5c..bc9f9cba305c4 100644 --- a/java/flight/flight-core/src/test/java/org/apache/arrow/flight/perf/TestPerf.java +++ b/java/flight/flight-core/src/test/java/org/apache/arrow/flight/perf/TestPerf.java @@ -38,7 +38,8 @@ import org.apache.arrow.vector.types.Types.MinorType; import org.apache.arrow.vector.types.pojo.Field; import org.apache.arrow.vector.types.pojo.Schema; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import com.google.common.base.MoreObjects; import com.google.common.base.Stopwatch; @@ -49,7 +50,7 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.ByteString; -@org.junit.Ignore +@Disabled public class TestPerf { public static final boolean VALIDATE = false; diff --git a/java/flight/flight-grpc/src/test/java/org/apache/arrow/flight/TestFlightGrpcUtils.java b/java/flight/flight-grpc/src/test/java/org/apache/arrow/flight/TestFlightGrpcUtils.java index 142a0f93734c8..9010f2d4a98f0 100644 --- a/java/flight/flight-grpc/src/test/java/org/apache/arrow/flight/TestFlightGrpcUtils.java +++ b/java/flight/flight-grpc/src/test/java/org/apache/arrow/flight/TestFlightGrpcUtils.java @@ -26,10 +26,10 @@ import org.apache.arrow.flight.auth.ServerAuthHandler; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.memory.RootAllocator; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import com.google.protobuf.Empty; @@ -49,7 +49,7 @@ public class TestFlightGrpcUtils { private BufferAllocator allocator; private String serverName; - @Before + @BeforeEach public void setup() throws IOException { //Defines flight service allocator = new RootAllocator(Integer.MAX_VALUE); @@ -69,7 +69,7 @@ public void setup() throws IOException { server.start(); } - @After + @AfterEach public void cleanup() { server.shutdownNow(); } @@ -95,7 +95,7 @@ public void testMultipleGrpcServices() throws IOException { //Define Test client as a blocking stub and call test method which correctly returns an empty protobuf object final TestServiceGrpc.TestServiceBlockingStub blockingStub = TestServiceGrpc.newBlockingStub(managedChannel); - Assert.assertEquals(Empty.newBuilder().build(), blockingStub.test(Empty.newBuilder().build())); + Assertions.assertEquals(Empty.newBuilder().build(), blockingStub.test(Empty.newBuilder().build())); } @Test @@ -111,9 +111,9 @@ public void testShutdown() throws IOException, InterruptedException { // Should be a no-op. flightClient.close(); - Assert.assertFalse(managedChannel.isShutdown()); - Assert.assertFalse(managedChannel.isTerminated()); - Assert.assertEquals(ConnectivityState.IDLE, managedChannel.getState(false)); + Assertions.assertFalse(managedChannel.isShutdown()); + Assertions.assertFalse(managedChannel.isTerminated()); + Assertions.assertEquals(ConnectivityState.IDLE, managedChannel.getState(false)); managedChannel.shutdownNow(); } @@ -126,22 +126,22 @@ public void testProxyChannel() throws IOException, InterruptedException { final FlightGrpcUtils.NonClosingProxyManagedChannel proxyChannel = new FlightGrpcUtils.NonClosingProxyManagedChannel(managedChannel); - Assert.assertFalse(proxyChannel.isShutdown()); - Assert.assertFalse(proxyChannel.isTerminated()); + Assertions.assertFalse(proxyChannel.isShutdown()); + Assertions.assertFalse(proxyChannel.isTerminated()); proxyChannel.shutdown(); - Assert.assertTrue(proxyChannel.isShutdown()); - Assert.assertTrue(proxyChannel.isTerminated()); - Assert.assertEquals(ConnectivityState.SHUTDOWN, proxyChannel.getState(false)); + Assertions.assertTrue(proxyChannel.isShutdown()); + Assertions.assertTrue(proxyChannel.isTerminated()); + Assertions.assertEquals(ConnectivityState.SHUTDOWN, proxyChannel.getState(false)); try { proxyChannel.newCall(null, null); - Assert.fail(); + Assertions.fail(); } catch (IllegalStateException e) { // This is expected, since the proxy channel is shut down. } - Assert.assertFalse(managedChannel.isShutdown()); - Assert.assertFalse(managedChannel.isTerminated()); - Assert.assertEquals(ConnectivityState.IDLE, managedChannel.getState(false)); + Assertions.assertFalse(managedChannel.isShutdown()); + Assertions.assertFalse(managedChannel.isTerminated()); + Assertions.assertEquals(ConnectivityState.IDLE, managedChannel.getState(false)); managedChannel.shutdownNow(); } @@ -155,22 +155,22 @@ public void testProxyChannelWithClosedChannel() throws IOException, InterruptedE final FlightGrpcUtils.NonClosingProxyManagedChannel proxyChannel = new FlightGrpcUtils.NonClosingProxyManagedChannel(managedChannel); - Assert.assertFalse(proxyChannel.isShutdown()); - Assert.assertFalse(proxyChannel.isTerminated()); + Assertions.assertFalse(proxyChannel.isShutdown()); + Assertions.assertFalse(proxyChannel.isTerminated()); managedChannel.shutdownNow(); - Assert.assertTrue(proxyChannel.isShutdown()); - Assert.assertTrue(proxyChannel.isTerminated()); - Assert.assertEquals(ConnectivityState.SHUTDOWN, proxyChannel.getState(false)); + Assertions.assertTrue(proxyChannel.isShutdown()); + Assertions.assertTrue(proxyChannel.isTerminated()); + Assertions.assertEquals(ConnectivityState.SHUTDOWN, proxyChannel.getState(false)); try { proxyChannel.newCall(null, null); - Assert.fail(); + Assertions.fail(); } catch (IllegalStateException e) { // This is expected, since the proxy channel is shut down. } - Assert.assertTrue(managedChannel.isShutdown()); - Assert.assertTrue(managedChannel.isTerminated()); - Assert.assertEquals(ConnectivityState.SHUTDOWN, managedChannel.getState(false)); + Assertions.assertTrue(managedChannel.isShutdown()); + Assertions.assertTrue(managedChannel.isTerminated()); + Assertions.assertEquals(ConnectivityState.SHUTDOWN, managedChannel.getState(false)); } /** diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/TestFlightSql.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/TestFlightSql.java index 06b3c9dbe202b..54a2a184f6ff2 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/TestFlightSql.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/TestFlightSql.java @@ -67,12 +67,12 @@ import org.apache.arrow.vector.types.pojo.Schema; import org.apache.arrow.vector.util.Text; import org.hamcrest.Matcher; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import com.google.common.collect.ImmutableList; @@ -95,10 +95,8 @@ public class TestFlightSql { private static BufferAllocator allocator; private static FlightServer server; private static FlightSqlClient sqlClient; - @Rule - public final ErrorCollector collector = new ErrorCollector(); - @BeforeClass + @BeforeAll public static void setUp() throws Exception { allocator = new RootAllocator(Integer.MAX_VALUE); @@ -136,7 +134,7 @@ public static void setUp() throws Exception { Integer.toString(SqlSupportedCaseSensitivity.SQL_CASE_SENSITIVITY_CASE_INSENSITIVE_VALUE)); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { close(sqlClient, server, allocator); } @@ -177,13 +175,13 @@ private static List> getNonConformingResultsForGetSqlInfo( @Test public void testGetTablesSchema() { final FlightInfo info = sqlClient.getTables(null, null, null, null, true); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA)); } @Test public void testGetTablesSchemaExcludeSchema() { final FlightInfo info = sqlClient.getTables(null, null, null, null, false); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)); } @Test @@ -192,36 +190,42 @@ public void testGetTablesResultNoSchema() throws Exception { sqlClient.getStream( sqlClient.getTables(null, null, null, null, false) .getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)); - final List> results = getResults(stream); - final List> expectedResults = ImmutableList.of( - // catalog_name | schema_name | table_name | table_type | table_schema - asList(null /* TODO No catalog yet */, "SYS", "SYSALIASES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSCHECKS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSCOLPERMS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSCOLUMNS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSCONGLOMERATES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSCONSTRAINTS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSDEPENDS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSFILES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSFOREIGNKEYS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSKEYS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSPERMS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSROLES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSROUTINEPERMS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSSCHEMAS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSSEQUENCES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSSTATEMENTS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSSTATISTICS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSTABLEPERMS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSTABLES", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSTRIGGERS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSUSERS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYS", "SYSVIEWS", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "SYSIBM", "SYSDUMMY1", "SYSTEM TABLE"), - asList(null /* TODO No catalog yet */, "APP", "FOREIGNTABLE", "TABLE"), - asList(null /* TODO No catalog yet */, "APP", "INTTABLE", "TABLE")); - collector.checkThat(results, is(expectedResults)); + Assertions.assertAll( + () -> { + MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)); + }, + () -> { + final List> results = getResults(stream); + final List> expectedResults = ImmutableList.of( + // catalog_name | schema_name | table_name | table_type | table_schema + asList(null /* TODO No catalog yet */, "SYS", "SYSALIASES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSCHECKS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSCOLPERMS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSCOLUMNS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSCONGLOMERATES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSCONSTRAINTS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSDEPENDS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSFILES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSFOREIGNKEYS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSKEYS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSPERMS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSROLES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSROUTINEPERMS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSSCHEMAS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSSEQUENCES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSSTATEMENTS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSSTATISTICS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSTABLEPERMS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSTABLES", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSTRIGGERS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSUSERS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYS", "SYSVIEWS", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "SYSIBM", "SYSDUMMY1", "SYSTEM TABLE"), + asList(null /* TODO No catalog yet */, "APP", "FOREIGNTABLE", "TABLE"), + asList(null /* TODO No catalog yet */, "APP", "INTTABLE", "TABLE")); + MatcherAssert.assertThat(results, is(expectedResults)); + } + ); } } @@ -231,13 +235,18 @@ public void testGetTablesResultFilteredNoSchema() throws Exception { sqlClient.getStream( sqlClient.getTables(null, null, null, singletonList("TABLE"), false) .getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)); - final List> results = getResults(stream); - final List> expectedResults = ImmutableList.of( - // catalog_name | schema_name | table_name | table_type | table_schema - asList(null /* TODO No catalog yet */, "APP", "FOREIGNTABLE", "TABLE"), - asList(null /* TODO No catalog yet */, "APP", "INTTABLE", "TABLE")); - collector.checkThat(results, is(expectedResults)); + + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA_NO_SCHEMA)), + () -> { + final List> results = getResults(stream); + final List> expectedResults = ImmutableList.of( + // catalog_name | schema_name | table_name | table_type | table_schema + asList(null /* TODO No catalog yet */, "APP", "FOREIGNTABLE", "TABLE"), + asList(null /* TODO No catalog yet */, "APP", "INTTABLE", "TABLE")); + MatcherAssert.assertThat(results, is(expectedResults)); + } + ); } } @@ -247,97 +256,108 @@ public void testGetTablesResultFilteredWithSchema() throws Exception { sqlClient.getStream( sqlClient.getTables(null, null, null, singletonList("TABLE"), true) .getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA)); - final List> results = getResults(stream); - final List> expectedResults = ImmutableList.of( - // catalog_name | schema_name | table_name | table_type | table_schema - asList( - null /* TODO No catalog yet */, - "APP", - "FOREIGNTABLE", - "TABLE", - new Schema(asList( - new Field("ID", new FieldType(false, MinorType.INT.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("FOREIGNTABLE") - .precision(10) - .scale(0) - .isAutoIncrement(true) - .build().getMetadataMap()), null), - new Field("FOREIGNNAME", new FieldType(true, MinorType.VARCHAR.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("FOREIGNTABLE") - .precision(100) - .scale(0) - .isAutoIncrement(false) - .build().getMetadataMap()), null), - new Field("VALUE", new FieldType(true, MinorType.INT.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("FOREIGNTABLE") - .precision(10) - .scale(0) - .isAutoIncrement(false) - .build().getMetadataMap()), null))).toJson()), - asList( - null /* TODO No catalog yet */, - "APP", - "INTTABLE", - "TABLE", - new Schema(asList( - new Field("ID", new FieldType(false, MinorType.INT.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("INTTABLE") - .precision(10) - .scale(0) - .isAutoIncrement(true) - .build().getMetadataMap()), null), - new Field("KEYNAME", new FieldType(true, MinorType.VARCHAR.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("INTTABLE") - .precision(100) - .scale(0) - .isAutoIncrement(false) - .build().getMetadataMap()), null), - new Field("VALUE", new FieldType(true, MinorType.INT.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("INTTABLE") - .precision(10) - .scale(0) - .isAutoIncrement(false) - .build().getMetadataMap()), null), - new Field("FOREIGNID", new FieldType(true, MinorType.INT.getType(), null, - new FlightSqlColumnMetadata.Builder() - .catalogName("") - .schemaName("APP") - .tableName("INTTABLE") - .precision(10) - .scale(0) - .isAutoIncrement(false) - .build().getMetadataMap()), null))).toJson())); - collector.checkThat(results, is(expectedResults)); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLES_SCHEMA)), + () -> { + final List> results = getResults(stream); + + final List> expectedResults = ImmutableList.of( + // catalog_name | schema_name | table_name | table_type | table_schema + asList( + null /* TODO No catalog yet */, + "APP", + "FOREIGNTABLE", + "TABLE", + new Schema(asList( + new Field("ID", new FieldType(false, MinorType.INT.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("FOREIGNTABLE") + .precision(10) + .scale(0) + .isAutoIncrement(true) + .build().getMetadataMap()), null), + new Field("FOREIGNNAME", new FieldType(true, MinorType.VARCHAR.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("FOREIGNTABLE") + .precision(100) + .scale(0) + .isAutoIncrement(false) + .build().getMetadataMap()), null), + new Field("VALUE", new FieldType(true, MinorType.INT.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("FOREIGNTABLE") + .precision(10) + .scale(0) + .isAutoIncrement(false) + .build().getMetadataMap()), null))).toJson()), + asList( + null /* TODO No catalog yet */, + "APP", + "INTTABLE", + "TABLE", + new Schema(asList( + new Field("ID", new FieldType(false, MinorType.INT.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("INTTABLE") + .precision(10) + .scale(0) + .isAutoIncrement(true) + .build().getMetadataMap()), null), + new Field("KEYNAME", new FieldType(true, MinorType.VARCHAR.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("INTTABLE") + .precision(100) + .scale(0) + .isAutoIncrement(false) + .build().getMetadataMap()), null), + new Field("VALUE", new FieldType(true, MinorType.INT.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("INTTABLE") + .precision(10) + .scale(0) + .isAutoIncrement(false) + .build().getMetadataMap()), null), + new Field("FOREIGNID", new FieldType(true, MinorType.INT.getType(), null, + new FlightSqlColumnMetadata.Builder() + .catalogName("") + .schemaName("APP") + .tableName("INTTABLE") + .precision(10) + .scale(0) + .isAutoIncrement(false) + .build().getMetadataMap()), null))).toJson())); + MatcherAssert.assertThat(results, is(expectedResults)); + } + ); } } @Test public void testSimplePreparedStatementSchema() throws Exception { try (final PreparedStatement preparedStatement = sqlClient.prepare("SELECT * FROM intTable")) { - final Schema actualSchema = preparedStatement.getResultSetSchema(); - collector.checkThat(actualSchema, is(SCHEMA_INT_TABLE)); - - final FlightInfo info = preparedStatement.execute(); - collector.checkThat(info.getSchema(), is(SCHEMA_INT_TABLE)); + Assertions.assertAll( + () -> { + final Schema actualSchema = preparedStatement.getResultSetSchema(); + MatcherAssert.assertThat(actualSchema, is(SCHEMA_INT_TABLE)); + + }, + () -> { + final FlightInfo info = preparedStatement.execute(); + MatcherAssert.assertThat(info.getSchema(), is(SCHEMA_INT_TABLE)); + } + ); } } @@ -346,8 +366,10 @@ public void testSimplePreparedStatementResults() throws Exception { try (final PreparedStatement preparedStatement = sqlClient.prepare("SELECT * FROM intTable"); final FlightStream stream = sqlClient.getStream( preparedStatement.execute().getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(SCHEMA_INT_TABLE)); - collector.checkThat(getResults(stream), is(EXPECTED_RESULTS_FOR_STAR_SELECT_QUERY)); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(SCHEMA_INT_TABLE)), + () -> MatcherAssert.assertThat(getResults(stream), is(EXPECTED_RESULTS_FOR_STAR_SELECT_QUERY)) + ); } } @@ -369,8 +391,10 @@ public void testSimplePreparedStatementResultsWithParameterBinding() throws Exce .getEndpoints() .get(0).getTicket()); - collector.checkThat(stream.getSchema(), is(SCHEMA_INT_TABLE)); - collector.checkThat(getResults(stream), is(EXPECTED_RESULTS_FOR_PARAMETER_BINDING)); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(SCHEMA_INT_TABLE)), + () -> MatcherAssert.assertThat(getResults(stream), is(EXPECTED_RESULTS_FOR_PARAMETER_BINDING)) + ); } } } @@ -403,9 +427,10 @@ public void testSimplePreparedStatementUpdateResults() throws SQLException { deletePrepare.setParameters(deleteRoot); deletedRows = deletePrepare.executeUpdate(); } - - collector.checkThat(updatedRows, is(10L)); - collector.checkThat(deletedRows, is(10L)); + Assertions.assertAll( + () -> MatcherAssert.assertThat(updatedRows, is(10L)), + () -> MatcherAssert.assertThat(deletedRows, is(10L)) + ); } } } @@ -419,84 +444,108 @@ public void testSimplePreparedStatementUpdateResultsWithoutParameters() throws S final long deletedRows = deletePrepare.executeUpdate(); - collector.checkThat(updatedRows, is(1L)); - collector.checkThat(deletedRows, is(1L)); + Assertions.assertAll( + () -> MatcherAssert.assertThat(updatedRows, is(1L)), + () -> MatcherAssert.assertThat(deletedRows, is(1L)) + ); } } @Test public void testSimplePreparedStatementClosesProperly() { final PreparedStatement preparedStatement = sqlClient.prepare("SELECT * FROM intTable"); - collector.checkThat(preparedStatement.isClosed(), is(false)); - preparedStatement.close(); - collector.checkThat(preparedStatement.isClosed(), is(true)); + Assertions.assertAll( + () -> { + MatcherAssert.assertThat(preparedStatement.isClosed(), is(false)); + }, + () -> { + preparedStatement.close(); + MatcherAssert.assertThat(preparedStatement.isClosed(), is(true)); + } + ); } @Test public void testGetCatalogsSchema() { final FlightInfo info = sqlClient.getCatalogs(); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_CATALOGS_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_CATALOGS_SCHEMA)); } @Test public void testGetCatalogsResults() throws Exception { try (final FlightStream stream = sqlClient.getStream(sqlClient.getCatalogs().getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_CATALOGS_SCHEMA)); - List> catalogs = getResults(stream); - collector.checkThat(catalogs, is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_CATALOGS_SCHEMA)), + () -> { + List> catalogs = getResults(stream); + MatcherAssert.assertThat(catalogs, is(emptyList())); + } + ); } } @Test public void testGetTableTypesSchema() { final FlightInfo info = sqlClient.getTableTypes(); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLE_TYPES_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLE_TYPES_SCHEMA)); } @Test public void testGetTableTypesResult() throws Exception { try (final FlightStream stream = sqlClient.getStream(sqlClient.getTableTypes().getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLE_TYPES_SCHEMA)); - final List> tableTypes = getResults(stream); - final List> expectedTableTypes = ImmutableList.of( - // table_type - singletonList("SYNONYM"), - singletonList("SYSTEM TABLE"), - singletonList("TABLE"), - singletonList("VIEW") + Assertions.assertAll( + () -> { + MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_TABLE_TYPES_SCHEMA)); + }, + () -> { + final List> tableTypes = getResults(stream); + final List> expectedTableTypes = ImmutableList.of( + // table_type + singletonList("SYNONYM"), + singletonList("SYSTEM TABLE"), + singletonList("TABLE"), + singletonList("VIEW") + ); + MatcherAssert.assertThat(tableTypes, is(expectedTableTypes)); + } ); - collector.checkThat(tableTypes, is(expectedTableTypes)); } } @Test public void testGetSchemasSchema() { final FlightInfo info = sqlClient.getSchemas(null, null); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_SCHEMAS_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_SCHEMAS_SCHEMA)); } @Test public void testGetSchemasResult() throws Exception { try (final FlightStream stream = sqlClient.getStream(sqlClient.getSchemas(null, null).getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SCHEMAS_SCHEMA)); - final List> schemas = getResults(stream); - final List> expectedSchemas = ImmutableList.of( - // catalog_name | schema_name - asList(null /* TODO Add catalog. */, "APP"), - asList(null /* TODO Add catalog. */, "NULLID"), - asList(null /* TODO Add catalog. */, "SQLJ"), - asList(null /* TODO Add catalog. */, "SYS"), - asList(null /* TODO Add catalog. */, "SYSCAT"), - asList(null /* TODO Add catalog. */, "SYSCS_DIAG"), - asList(null /* TODO Add catalog. */, "SYSCS_UTIL"), - asList(null /* TODO Add catalog. */, "SYSFUN"), - asList(null /* TODO Add catalog. */, "SYSIBM"), - asList(null /* TODO Add catalog. */, "SYSPROC"), - asList(null /* TODO Add catalog. */, "SYSSTAT")); - collector.checkThat(schemas, is(expectedSchemas)); + Assertions.assertAll( + () -> { + MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SCHEMAS_SCHEMA)); + }, + () -> { + final List> schemas = getResults(stream); + final List> expectedSchemas = ImmutableList.of( + // catalog_name | schema_name + asList(null /* TODO Add catalog. */, "APP"), + asList(null /* TODO Add catalog. */, "NULLID"), + asList(null /* TODO Add catalog. */, "SQLJ"), + asList(null /* TODO Add catalog. */, "SYS"), + asList(null /* TODO Add catalog. */, "SYSCAT"), + asList(null /* TODO Add catalog. */, "SYSCS_DIAG"), + asList(null /* TODO Add catalog. */, "SYSCS_UTIL"), + asList(null /* TODO Add catalog. */, "SYSFUN"), + asList(null /* TODO Add catalog. */, "SYSIBM"), + asList(null /* TODO Add catalog. */, "SYSPROC"), + asList(null /* TODO Add catalog. */, "SYSSTAT")); + MatcherAssert.assertThat(schemas, is(expectedSchemas)); + } + ); } } @@ -506,30 +555,37 @@ public void testGetPrimaryKey() { final FlightStream stream = sqlClient.getStream(flightInfo.getEndpoints().get(0).getTicket()); final List> results = getResults(stream); - collector.checkThat(results.size(), is(1)); - final List result = results.get(0); - - collector.checkThat(result.get(0), is("")); - collector.checkThat(result.get(1), is("APP")); - collector.checkThat(result.get(2), is("INTTABLE")); - collector.checkThat(result.get(3), is("ID")); - collector.checkThat(result.get(4), is("1")); - collector.checkThat(result.get(5), notNullValue()); + Assertions.assertAll( + () -> MatcherAssert.assertThat(results.size(), is(1)), + () -> { + final List result = results.get(0); + Assertions.assertAll( + () -> MatcherAssert.assertThat(result.get(0), is("")), + () -> MatcherAssert.assertThat(result.get(1), is("APP")), + () -> MatcherAssert.assertThat(result.get(2), is("INTTABLE")), + () -> MatcherAssert.assertThat(result.get(3), is("ID")), + () -> MatcherAssert.assertThat(result.get(4), is("1")), + () -> MatcherAssert.assertThat(result.get(5), notNullValue()) + ); + } + ); } @Test public void testGetSqlInfoSchema() { final FlightInfo info = sqlClient.getSqlInfo(); - collector.checkThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); + MatcherAssert.assertThat(info.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); } @Test public void testGetSqlInfoResults() throws Exception { final FlightInfo info = sqlClient.getSqlInfo(); try (final FlightStream stream = sqlClient.getStream(info.getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); - collector.checkThat(getNonConformingResultsForGetSqlInfo(getResults(stream)), is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)), + () -> MatcherAssert.assertThat(getNonConformingResultsForGetSqlInfo(getResults(stream)), is(emptyList())) + ); } } @@ -538,8 +594,10 @@ public void testGetSqlInfoResultsWithSingleArg() throws Exception { final FlightSql.SqlInfo arg = FlightSql.SqlInfo.FLIGHT_SQL_SERVER_NAME; final FlightInfo info = sqlClient.getSqlInfo(arg); try (final FlightStream stream = sqlClient.getStream(info.getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); - collector.checkThat(getNonConformingResultsForGetSqlInfo(getResults(stream), arg), is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)), + () -> MatcherAssert.assertThat(getNonConformingResultsForGetSqlInfo(getResults(stream), arg), is(emptyList())) + ); } } @@ -550,8 +608,16 @@ public void testGetSqlInfoResultsWithTwoArgs() throws Exception { FlightSql.SqlInfo.FLIGHT_SQL_SERVER_VERSION}; final FlightInfo info = sqlClient.getSqlInfo(args); try (final FlightStream stream = sqlClient.getStream(info.getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); - collector.checkThat(getNonConformingResultsForGetSqlInfo(getResults(stream), args), is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat( + stream.getSchema(), + is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA) + ), + () -> MatcherAssert.assertThat( + getNonConformingResultsForGetSqlInfo(getResults(stream), args), + is(emptyList()) + ) + ); } } @@ -563,8 +629,16 @@ public void testGetSqlInfoResultsWithThreeArgs() throws Exception { FlightSql.SqlInfo.SQL_IDENTIFIER_QUOTE_CHAR}; final FlightInfo info = sqlClient.getSqlInfo(args); try (final FlightStream stream = sqlClient.getStream(info.getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA)); - collector.checkThat(getNonConformingResultsForGetSqlInfo(getResults(stream), args), is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat( + stream.getSchema(), + is(FlightSqlProducer.Schemas.GET_SQL_INFO_SCHEMA) + ), + () -> MatcherAssert.assertThat( + getNonConformingResultsForGetSqlInfo(getResults(stream), args), + is(emptyList()) + ) + ); } } @@ -592,10 +666,14 @@ public void testGetCommandExportedKeys() { is("3"), // update_rule is("3")); // delete_rule - Assert.assertEquals(1, results.size()); + final List assertions = new ArrayList<>(); + Assertions.assertEquals(1, results.size()); for (int i = 0; i < matchers.size(); i++) { - collector.checkThat(results.get(0).get(i), matchers.get(i)); + final String actual = results.get(0).get(i); + final Matcher expected = matchers.get(i); + assertions.add(() -> MatcherAssert.assertThat(actual, expected)); } + Assertions.assertAll(assertions); } @Test @@ -622,10 +700,14 @@ public void testGetCommandImportedKeys() { is("3"), // update_rule is("3")); // delete_rule - Assert.assertEquals(1, results.size()); + Assertions.assertEquals(1, results.size()); + final List assertions = new ArrayList<>(); for (int i = 0; i < matchers.size(); i++) { - collector.checkThat(results.get(0).get(i), matchers.get(i)); + final String actual = results.get(0).get(i); + final Matcher expected = matchers.get(i); + assertions.add(() -> MatcherAssert.assertThat(actual, expected)); } + Assertions.assertAll(assertions); } @Test @@ -703,7 +785,7 @@ public void testGetTypeInfo() { asList("XML", "2009", null, null, null, emptyList().toString(), "1", "true", "0", "false", "false", "false", "XML", null, null, null, null, null, null)); - collector.checkThat(results, is(matchers)); + MatcherAssert.assertThat(results, is(matchers)); } @Test @@ -718,7 +800,7 @@ public void testGetTypeInfoWithFiltering() { asList("BIGINT", "-5", "19", null, null, emptyList().toString(), "1", "false", "2", "false", "false", "true", "BIGINT", "0", "0", null, null, "10", null)); - collector.checkThat(results, is(matchers)); + MatcherAssert.assertThat(results, is(matchers)); } @Test @@ -744,16 +826,20 @@ public void testGetCommandCrossReference() { is("3"), // update_rule is("3")); // delete_rule - Assert.assertEquals(1, results.size()); + Assertions.assertEquals(1, results.size()); + final List assertions = new ArrayList<>(); for (int i = 0; i < matchers.size(); i++) { - collector.checkThat(results.get(0).get(i), matchers.get(i)); + final String actual = results.get(0).get(i); + final Matcher expected = matchers.get(i); + assertions.add(() -> MatcherAssert.assertThat(actual, expected)); } + Assertions.assertAll(assertions); } @Test public void testCreateStatementSchema() throws Exception { final FlightInfo info = sqlClient.execute("SELECT * FROM intTable"); - collector.checkThat(info.getSchema(), is(SCHEMA_INT_TABLE)); + MatcherAssert.assertThat(info.getSchema(), is(SCHEMA_INT_TABLE)); // Consume statement to close connection before cache eviction try (FlightStream stream = sqlClient.getStream(info.getEndpoints().get(0).getTicket())) { @@ -767,8 +853,14 @@ public void testCreateStatementSchema() throws Exception { public void testCreateStatementResults() throws Exception { try (final FlightStream stream = sqlClient .getStream(sqlClient.execute("SELECT * FROM intTable").getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(SCHEMA_INT_TABLE)); - collector.checkThat(getResults(stream), is(EXPECTED_RESULTS_FOR_STAR_SELECT_QUERY)); + Assertions.assertAll( + () -> { + MatcherAssert.assertThat(stream.getSchema(), is(SCHEMA_INT_TABLE)); + }, + () -> { + MatcherAssert.assertThat(getResults(stream), is(EXPECTED_RESULTS_FOR_STAR_SELECT_QUERY)); + } + ); } } @@ -858,16 +950,24 @@ List> getResults(FlightStream stream) { @Test public void testExecuteUpdate() { - long insertedCount = sqlClient.executeUpdate("INSERT INTO INTTABLE (keyName, value) VALUES " + - "('KEYNAME1', 1001), ('KEYNAME2', 1002), ('KEYNAME3', 1003)"); - collector.checkThat(insertedCount, is(3L)); - - long updatedCount = sqlClient.executeUpdate("UPDATE INTTABLE SET keyName = 'KEYNAME1' " + - "WHERE keyName = 'KEYNAME2' OR keyName = 'KEYNAME3'"); - collector.checkThat(updatedCount, is(2L)); - - long deletedCount = sqlClient.executeUpdate("DELETE FROM INTTABLE WHERE keyName = 'KEYNAME1'"); - collector.checkThat(deletedCount, is(3L)); + Assertions.assertAll( + () -> { + long insertedCount = sqlClient.executeUpdate("INSERT INTO INTTABLE (keyName, value) VALUES " + + "('KEYNAME1', 1001), ('KEYNAME2', 1002), ('KEYNAME3', 1003)"); + MatcherAssert.assertThat(insertedCount, is(3L)); + + }, + () -> { + long updatedCount = sqlClient.executeUpdate("UPDATE INTTABLE SET keyName = 'KEYNAME1' " + + "WHERE keyName = 'KEYNAME2' OR keyName = 'KEYNAME3'"); + MatcherAssert.assertThat(updatedCount, is(2L)); + + }, + () -> { + long deletedCount = sqlClient.executeUpdate("DELETE FROM INTTABLE WHERE keyName = 'KEYNAME1'"); + MatcherAssert.assertThat(deletedCount, is(3L)); + } + ); } @Test @@ -875,10 +975,13 @@ public void testQueryWithNoResultsShouldNotHang() throws Exception { try (final PreparedStatement preparedStatement = sqlClient.prepare("SELECT * FROM intTable WHERE 1 = 0"); final FlightStream stream = sqlClient .getStream(preparedStatement.execute().getEndpoints().get(0).getTicket())) { - collector.checkThat(stream.getSchema(), is(SCHEMA_INT_TABLE)); - - final List> result = getResults(stream); - collector.checkThat(result, is(emptyList())); + Assertions.assertAll( + () -> MatcherAssert.assertThat(stream.getSchema(), is(SCHEMA_INT_TABLE)), + () -> { + final List> result = getResults(stream); + MatcherAssert.assertThat(result, is(emptyList())); + } + ); } } } diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskCreationTest.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskCreationTest.java index 6f2b66646bb20..dfb1b9da3e249 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskCreationTest.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskCreationTest.java @@ -22,29 +22,15 @@ import static org.apache.arrow.flight.sql.util.AdhocTestOption.OPTION_B; import static org.apache.arrow.flight.sql.util.AdhocTestOption.OPTION_C; import static org.apache.arrow.flight.sql.util.SqlInfoOptionsUtils.createBitmaskFromEnums; -import static org.hamcrest.CoreMatchers.is; import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public final class SqlInfoOptionsUtilsBitmaskCreationTest { - @Parameter - public AdhocTestOption[] adhocTestOptions; - @Parameter(value = 1) - public long expectedBitmask; - @Rule - public final ErrorCollector collector = new ErrorCollector(); - - @Parameters public static List provideParameters() { return asList( new Object[][]{ @@ -59,8 +45,11 @@ public static List provideParameters() { }); } - @Test - public void testShouldBuildBitmaskFromEnums() { - collector.checkThat(createBitmaskFromEnums(adhocTestOptions), is(expectedBitmask)); + @ParameterizedTest + @MethodSource("provideParameters") + public void testShouldBuildBitmaskFromEnums( + AdhocTestOption[] adhocTestOptions, long expectedBitmask + ) { + Assertions.assertEquals(createBitmaskFromEnums(adhocTestOptions), expectedBitmask); } } diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskParsingTest.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskParsingTest.java index decee38ee0a18..818326a582da8 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskParsingTest.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/util/SqlInfoOptionsUtilsBitmaskParsingTest.java @@ -24,31 +24,17 @@ import static org.apache.arrow.flight.sql.util.AdhocTestOption.OPTION_B; import static org.apache.arrow.flight.sql.util.AdhocTestOption.OPTION_C; import static org.apache.arrow.flight.sql.util.SqlInfoOptionsUtils.doesBitmaskTranslateToEnum; -import static org.hamcrest.CoreMatchers.is; import java.util.EnumSet; import java.util.List; import java.util.Set; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ErrorCollector; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public final class SqlInfoOptionsUtilsBitmaskParsingTest { - @Parameter - public long bitmask; - @Parameter(value = 1) - public Set expectedOptions; - @Rule - public final ErrorCollector collector = new ErrorCollector(); - - @Parameters public static List provideParameters() { return asList( new Object[][]{ @@ -63,12 +49,13 @@ public static List provideParameters() { }); } - @Test - public void testShouldFilterOutEnumsBasedOnBitmask() { + @ParameterizedTest + @MethodSource("provideParameters") + public void testShouldFilterOutEnumsBasedOnBitmask(long bitmask, Set expectedOptions) { final Set actualOptions = stream(AdhocTestOption.values()) .filter(enumInstance -> doesBitmaskTranslateToEnum(enumInstance, bitmask)) .collect(toCollection(() -> EnumSet.noneOf(AdhocTestOption.class))); - collector.checkThat(actualOptions, is(expectedOptions)); + Assertions.assertEquals(actualOptions, expectedOptions); } } diff --git a/java/pom.xml b/java/pom.xml index 0d123977fc634..b9089a8ccf79f 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -29,8 +29,8 @@ ${project.build.directory}/generated-sources - 1.4.0 - 5.4.0 + 1.9.0 + 5.9.0 1.7.25 30.1.1-jre 4.1.78.Final @@ -398,7 +398,14 @@ maven-surefire-plugin - 3.0.0-M7 + 2.22.2 + + + org.junit.jupiter + junit-jupiter-engine + ${dep.junit.jupiter.version} + + true true @@ -638,6 +645,12 @@ ${dep.junit.jupiter.version} test + + org.junit.jupiter + junit-jupiter-params + ${dep.junit.jupiter.version} + test + junit