Esempio n. 1
0
 @Test
 public void testSchemaStdout() throws Exception {
   command.samplePaths = Lists.newArrayList("target/users.csv");
   command.recordName = "User";
   int rc = command.run();
   Assert.assertEquals("Should return success code", 0, rc);
   verify(console).info(argThat(TestUtil.matchesSchema(schema)));
   verifyNoMoreInteractions(console);
 }
Esempio n. 2
0
 @Test
 public void testSchemaToFile() throws Exception {
   command.samplePaths = Lists.newArrayList("target/users.csv");
   command.recordName = "User";
   command.outputPath = "target/user.avsc";
   int rc = command.run();
   Assert.assertEquals("Should return success code", 0, rc);
   String fileContent = Files.toString(new File("target/user.avsc"), SchemaCommand.SCHEMA_CHARSET);
   Assert.assertTrue(
       "File should contain pretty printed schema",
       TestUtil.matchesSchema(schema).matches(fileContent));
   verifyNoMoreInteractions(console);
 }
Esempio n. 3
0
 @Test
 public void testMultipleSamplesFail() throws Exception {
   command.samplePaths = Lists.newArrayList(sample, "target/sample2.csv");
   TestHelpers.assertThrows(
       "Should reject saving multiple schemas in a file",
       IllegalArgumentException.class,
       new Callable<Void>() {
         @Override
         public Void call() throws Exception {
           command.run();
           return null;
         }
       });
   verifyNoMoreInteractions(console);
 }
Esempio n. 4
0
 @Before
 public void setup() throws Exception {
   this.console = mock(Logger.class);
   this.command = new CSVSchemaCommand(console);
   command.setConf(new Configuration());
 }