|
62 | 62 | import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName; |
63 | 63 | import org.apache.parquet.schema.Type; |
64 | 64 | import org.apache.parquet.schema.Types; |
| 65 | +import org.junit.After; |
65 | 66 | import org.junit.Assert; |
66 | 67 | import org.junit.Before; |
67 | 68 | import org.junit.BeforeClass; |
68 | 69 | import org.junit.Test; |
69 | | -import org.junit.runner.RunWith; |
| 70 | +import org.mockito.MockedStatic; |
70 | 71 | import org.mockito.Mockito; |
71 | | -import org.powermock.api.mockito.PowerMockito; |
72 | | -import org.powermock.core.classloader.annotations.PrepareForTest; |
73 | | -import org.powermock.modules.junit4.PowerMockRunner; |
74 | 72 |
|
75 | | -@RunWith(PowerMockRunner.class) |
76 | | -@PrepareForTest(AvroRecordConverter.class) |
77 | 73 | public class TestAvroSchemaConverter { |
78 | 74 |
|
79 | 75 | private static final Configuration NEW_BEHAVIOR = new Configuration(false); |
| 76 | + private MockedStatic<AvroRecordConverter> avroRecordConverterMock; |
80 | 77 |
|
81 | 78 | @Before |
82 | 79 | public void setupMockito() { |
83 | | - PowerMockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS); |
| 80 | + avroRecordConverterMock = Mockito.mockStatic(AvroRecordConverter.class, CALLS_REAL_METHODS); |
| 81 | + } |
| 82 | + |
| 83 | + @After |
| 84 | + public void tearDown() { |
| 85 | + avroRecordConverterMock.close(); |
84 | 86 | } |
85 | 87 |
|
86 | 88 | @BeforeClass |
@@ -706,7 +708,9 @@ public void testTimestampMillisType() throws Exception { |
706 | 708 |
|
707 | 709 | // Test that conversions for timestamp types only use APIs that are available in the user's Avro version |
708 | 710 | for (String avroVersion : ImmutableSet.of("1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.11.0")) { |
709 | | - Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn(avroVersion); |
| 711 | + avroRecordConverterMock |
| 712 | + .when(AvroRecordConverter::getRuntimeAvroVersion) |
| 713 | + .thenReturn(avroVersion); |
710 | 714 | final Schema converted = new AvroSchemaConverter() |
711 | 715 | .convert(Types.buildMessage() |
712 | 716 | .addField(Types.primitive(INT64, Type.Repetition.REQUIRED) |
@@ -792,7 +796,9 @@ public void testTimestampMicrosType() throws Exception { |
792 | 796 |
|
793 | 797 | // Test that conversions for timestamp types only use APIs that are available in the user's Avro version |
794 | 798 | for (String avroVersion : ImmutableSet.of("1.7.0", "1.8.0", "1.9.0", "1.10.0", "1.11.0")) { |
795 | | - Mockito.when(AvroRecordConverter.getRuntimeAvroVersion()).thenReturn(avroVersion); |
| 799 | + avroRecordConverterMock |
| 800 | + .when(AvroRecordConverter::getRuntimeAvroVersion) |
| 801 | + .thenReturn(avroVersion); |
796 | 802 | final Schema converted = new AvroSchemaConverter() |
797 | 803 | .convert(Types.buildMessage() |
798 | 804 | .addField(Types.primitive(INT64, Type.Repetition.REQUIRED) |
|
0 commit comments