|
27 | 27 | import java.io.IOException; |
28 | 28 | import java.io.PrintStream; |
29 | 29 | import java.nio.charset.StandardCharsets; |
| 30 | +import java.util.Collections; |
30 | 31 | import java.util.HashMap; |
31 | 32 | import java.util.Map; |
| 33 | +import java.util.Set; |
32 | 34 | import org.apache.hadoop.conf.Configuration; |
33 | 35 | import org.apache.hadoop.fs.Path; |
34 | 36 | import org.apache.parquet.ParquetReadOptions; |
|
47 | 49 | import org.apache.parquet.hadoop.example.GroupWriteSupport; |
48 | 50 | import org.apache.parquet.hadoop.metadata.ColumnPath; |
49 | 51 | import org.apache.parquet.hadoop.metadata.CompressionCodecName; |
| 52 | +import org.apache.parquet.hadoop.metadata.ParquetMetadata; |
| 53 | +import org.apache.parquet.hadoop.metadata.ParquetMetadataConverter; |
50 | 54 | import org.apache.parquet.hadoop.util.HadoopInputFile; |
51 | 55 | import org.apache.parquet.io.InputFile; |
52 | 56 | import org.apache.parquet.schema.MessageType; |
@@ -246,22 +250,19 @@ public void testCommandExists() { |
246 | 250 | public void testColumnEncryptedFileWithKeys() throws IOException { |
247 | 251 | assertTrue(columnEncryptedFile.exists()); |
248 | 252 |
|
249 | | - ByteArrayOutputStream out = new ByteArrayOutputStream(); |
250 | | - PrintStream ps = new PrintStream(out, true, StandardCharsets.UTF_8); |
251 | | - Logger logger = createLogger(ps); |
252 | | - |
253 | | - EncryptionInfoCommand cmd = new EncryptionInfoCommand(logger); |
| 253 | + EncryptionInfoCommand cmd = new EncryptionInfoCommand(createLogger()); |
254 | 254 | cmd.targets = java.util.Arrays.asList(columnEncryptedFile.getAbsolutePath()); |
255 | 255 | cmd.setConf(new Configuration()); |
256 | 256 |
|
257 | 257 | int rc = cmd.run(); |
258 | 258 | assertEquals(0, rc); |
259 | 259 |
|
260 | | - String output = out.toString(StandardCharsets.UTF_8); |
261 | | - |
262 | | - assertTrue(output.contains("Encryption type: PLAINTEXT_FOOTER")); |
263 | | - assertTrue(output.contains("ssn ENCRYPTED")); |
264 | | - assertTrue(output.contains("id -")); |
| 260 | + ParquetMetadata footer = ParquetFileReader.readFooter( |
| 261 | + new Configuration(), |
| 262 | + new Path(columnEncryptedFile.getAbsolutePath()), |
| 263 | + ParquetMetadataConverter.NO_FILTER); |
| 264 | + Set<String> encrypted = EncryptionInfoCommand.findEncryptedColumns(footer); |
| 265 | + assertEquals(Collections.singleton("ssn"), encrypted); |
265 | 266 | } |
266 | 267 |
|
267 | 268 | @Test |
|
0 commit comments