List of usage examples for org.apache.commons.lang RandomStringUtils RandomStringUtils
public RandomStringUtils()
RandomStringUtils
instances should NOT be constructed in standard programming.
From source file:com.sjsu.crawler.util.RandomStringUtilsTest.java
@Test public void testConstructor() { assertNotNull(new RandomStringUtils()); final Constructor<?>[] cons = RandomStringUtils.class.getDeclaredConstructors(); assertEquals(1, cons.length);/* w w w . j a va 2 s . co m*/ assertTrue(Modifier.isPublic(cons[0].getModifiers())); assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers())); assertFalse(Modifier.isFinal(RandomStringUtils.class.getModifiers())); }
From source file:co.cask.cdap.filetailer.tailer.BaseTailerTest.java
@Test public void baseReadingLogDirTest() throws ConfigurationLoadingException, InterruptedException { FileTailerQueue queue = new FileTailerQueue(1); PipeConfiguration flowConfig = TailerLogUtils.loadConfig(); LogTailer tailer = TailerLogUtils.createTailer(queue, flowConfig); String filePath = flowConfig.getSourceConfiguration().getWorkDir().getAbsolutePath() + "/" + flowConfig.getSourceConfiguration().getFileName(); Logger logger = TailerLogUtils.getSizeLogger(filePath, LOG_FILE_SIZE); RandomStringUtils randomUtils = new RandomStringUtils(); List<String> logList = new ArrayList<String>(ENTRY_NUMBER); for (int i = 0; i < ENTRY_NUMBER; i++) { String currLine = randomUtils.randomAlphanumeric(LINE_SIZE); logger.debug(currLine);/*from w w w .j av a 2 s . c o m*/ logList.add(currLine); } tailer.startAsync(); Thread.currentThread().sleep(SLEEP_TIME); for (String str : logList) { Assert.assertEquals(true, queue.take().getEventData().contains(str)); } tailer.stopAsync(); Thread.currentThread().sleep(1000); }
From source file:co.cask.cdap.filetailer.tailer.SizeBasedRotationTest.java
@Test public void fileRotationTest() throws ConfigurationLoadingException, InterruptedException { FileTailerQueue queue = new FileTailerQueue(QUEUE_SIZE); PipeConfiguration flowConfig = TailerLogUtils.loadConfig(); FileTailerStateProcessor stateProcessor = new FileTailerStateProcessorImpl(flowConfig.getDaemonDir(), flowConfig.getStateFile());/*from w w w. j av a2 s .c om*/ FileTailerMetricsProcessor metricsProcessor = new FileTailerMetricsProcessor(flowConfig.getDaemonDir(), flowConfig.getStatisticsFile(), flowConfig.getStatisticsSleepInterval(), flowConfig.getPipeName(), flowConfig.getSourceConfiguration().getFileName()); LogTailer tailer = new LogTailer(TailerLogUtils.loadConfig(), queue, stateProcessor, metricsProcessor, null); String filePath = flowConfig.getSourceConfiguration().getWorkDir().getAbsolutePath() + "/" + flowConfig.getSourceConfiguration().getFileName(); List<String> logList = new ArrayList<String>(ENTRY_WRITE_NUMBER); RandomStringUtils randomUtils = new RandomStringUtils(); Logger logger = TailerLogUtils.getSizeLogger(filePath, LOG_FILE_SIZE); tailer.startAsync(); for (int i = 0; i < ENTRY_WRITE_NUMBER; i++) { String currLine = randomUtils.randomAlphanumeric(LINE_SIZE); logger.debug(currLine); logList.add(currLine); if (i % 50 == 0) { Thread.currentThread().sleep(300); } } Thread.currentThread().sleep(SLEEP_TIME); for (int i = 0; i < logList.size(); i++) { Assert.assertEquals(true, queue.take().getEventData().contains(logList.get(i))); } tailer.stopAsync(); }
From source file:co.cask.cdap.filetailer.tailer.BaseTailerTest.java
@Test public void fileTimeRotationTest() throws ConfigurationLoadingException, InterruptedException { FileTailerQueue queue = new FileTailerQueue(QUEUE_SIZE); PipeConfiguration flowConfig = TailerLogUtils.loadConfig(); LogTailer tailer = TailerLogUtils.createTailer(queue, flowConfig); String filePath = flowConfig.getSourceConfiguration().getWorkDir().getAbsolutePath() + "/" + flowConfig.getSourceConfiguration().getFileName(); Logger logger = TailerLogUtils.getTimeLogger(filePath); RandomStringUtils randomUtils = new RandomStringUtils(); List<String> logList = new ArrayList<String>(ENTRY_NUMBER); tailer.startAsync();//from ww w . j ava2 s .c o m for (int i = 0; i < ENTRY_NUMBER; i++) { String currLine = randomUtils.randomAlphanumeric(LINE_SIZE); logger.debug(currLine); logList.add(currLine); Thread.currentThread().sleep(WRITING_INTERVAL); } Thread.currentThread().sleep(SLEEP_TIME); tailer.stopAsync(); for (String str : logList) { Assert.assertEquals(true, queue.take().getEventData().contains(str)); } }
From source file:co.cask.cdap.filetailer.tailer.RunFromSaveStateTest.java
private void write_log(int entryNumber, Logger logger, List<String> logList) { for (int i = 0; i < entryNumber; i++) { RandomStringUtils randomUtils = new RandomStringUtils(); String currLine = randomUtils.randomAlphanumeric(LINE_SIZE); logger.debug(currLine);/*from w w w . java2s .c o m*/ logList.add(currLine); } }