use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.
the class SimpleFlatFileSummarizerTest method testArgs.
@Test
public void testArgs() throws Exception {
String[] argv = { "-e extractor.json", "-o out.ser", "-l log4j", "-i input.csv", "-p 2", "-b 128", "-q" };
Configuration config = new Configuration();
String[] otherArgs = new GenericOptionsParser(config, argv).getRemainingArgs();
CommandLine cli = SummarizeOptions.parse(new PosixParser(), otherArgs);
Assert.assertEquals("extractor.json", SummarizeOptions.EXTRACTOR_CONFIG.get(cli).trim());
Assert.assertEquals("input.csv", SummarizeOptions.INPUT.get(cli).trim());
Assert.assertEquals("log4j", SummarizeOptions.LOG4J_PROPERTIES.get(cli).trim());
Assert.assertEquals("2", SummarizeOptions.NUM_THREADS.get(cli).trim());
Assert.assertEquals("128", SummarizeOptions.BATCH_SIZE.get(cli).trim());
}
use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.
the class GeoEnrichmentLoaderTest method testLoadGeoIpDatabase.
@Test
public void testLoadGeoIpDatabase() throws Exception {
File dbFile = new File(remoteDir.getAbsolutePath() + "/GeoEnrichmentLoaderTest.mmdb");
dbFile.createNewFile();
String[] argv = { "--geo_url", "file://" + dbFile.getAbsolutePath(), "--remote_dir", remoteDir.getAbsolutePath(), "--tmp_dir", tmpDir.getAbsolutePath(), "--zk_quorum", "test:2181" };
String[] otherArgs = new GenericOptionsParser(argv).getRemainingArgs();
CommandLine cli = GeoEnrichmentLoader.GeoEnrichmentOptions.parse(new PosixParser(), otherArgs);
GeoEnrichmentLoader loader = new MockGeoEnrichmentLoader();
loader.loadGeoIpDatabase(cli);
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(config);
assertTrue(fs.exists(new Path(remoteDir + "/" + dbFile.getName())));
}
use of org.apache.hadoop.util.GenericOptionsParser in project metron by apache.
the class GeoEnrichmentLoaderTest method testCommandLineLongOpts.
@Test
public void testCommandLineLongOpts() throws Exception {
String[] argv = { "--geo_url", "testGeoUrl", "--remote_dir", "/test/remoteDir", "--tmp_dir", "/test/tmpDir", "--zk_quorum", "test:2181" };
String[] otherArgs = new GenericOptionsParser(argv).getRemainingArgs();
CommandLine cli = GeoEnrichmentLoader.GeoEnrichmentOptions.parse(new PosixParser(), otherArgs);
Assert.assertEquals("testGeoUrl", GeoEnrichmentLoader.GeoEnrichmentOptions.GEO_URL.get(cli).trim());
Assert.assertEquals("/test/remoteDir", GeoEnrichmentLoader.GeoEnrichmentOptions.REMOTE_DIR.get(cli).trim());
Assert.assertEquals("/test/tmpDir", GeoEnrichmentLoader.GeoEnrichmentOptions.TMP_DIR.get(cli).trim());
Assert.assertEquals("test:2181", GeoEnrichmentLoader.GeoEnrichmentOptions.ZK_QUORUM.get(cli).trim());
}
Aggregations