List of usage examples for org.apache.commons.lang3 RandomUtils nextInt
public static int nextInt(final int startInclusive, final int endExclusive)
Returns a random integer within the specified range.
From source file:example.client.CamelMongoJmsStockClient.java
@SuppressWarnings("resource") public static void main(final String[] args) throws Exception { systemProps = loadProperties();/*from w w w .j ava 2s.c o m*/ AbstractApplicationContext context = new ClassPathXmlApplicationContext("camel-client.xml"); ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class); List<Map<String, Object>> stocks = readJsonsFromMongoDB(); for (Map<String, Object> stock : stocks) { stock.remove("_id"); stock.remove("Earnings Date"); camelTemplate.sendBody(String.format("jms:queue:%s", systemProps.getProperty("ticker.queue.name")), ExchangePattern.InOnly, stock); } new Timer().schedule(new TimerTask() { @Override public void run() { Map<String, Object> aRandomStock = stocks.get(RandomUtils.nextInt(0, stocks.size())); aRandomStock.put("Price", ((Double) aRandomStock.get("Price")) + RandomUtils.nextFloat(0.1f, 9.99f)); camelTemplate.sendBody(String.format("jms:queue:%s", systemProps.getProperty("ticker.queue.name")), ExchangePattern.InOnly, aRandomStock); } }, 1000, 2000); }
From source file:com.navercorp.pinpoint.web.test.util.DataSourceTestUtils.java
private static DataSourceBo createDataSourceBo(int id, int maxConnectionSize) { DataSourceBo dataSourceBo = new DataSourceBo(); dataSourceBo.setId(id);//from w w w.j a va2s . c om dataSourceBo.setActiveConnectionSize(RandomUtils.nextInt(1, maxConnectionSize)); dataSourceBo.setMaxConnectionSize(maxConnectionSize); return dataSourceBo; }
From source file:com.hazelcast.simulator.utils.GeneratorUtils.java
public static String[] generateStrings(int count, int minLength, int maxLength) { String[] keys = new String[count]; for (int i = 0; i < keys.length; i++) { int length = RandomUtils.nextInt(minLength, maxLength); keys[i] = generateString(length); }/*from ww w . ja va2 s . c o m*/ return keys; }
From source file:com.navercorp.pinpoint.common.server.bo.codec.stat.TestAgentStatFactory.java
public static List<JvmGcBo> createJvmGcBos(String agentId, long startTimestamp, long initialTimestamp) { final int numValues = RandomUtils.nextInt(1, MAX_NUM_TEST_VALUES); return createJvmGcBos(agentId, startTimestamp, initialTimestamp, numValues); }
From source file:net.ceos.project.poi.annotated.bean.ObjectNullBuilder.java
/** * Create a list of ObjectNull for tests. * /*from w ww. j av a 2s . com*/ * @return the {@link ObjectNull} */ public static List<ObjectNull> buildListOfObjectNull(int entryNumber) { List<ObjectNull> returnList = new ArrayList<>(); for (int i = 0; i < entryNumber; i++) { returnList.add(buildObjectNull(RandomUtils.nextInt(1, entryNumber))); } return returnList; }
From source file:com.yeetor.util.Util.java
/** * ???//from w w w . j a v a 2 s . c o m * @return */ public static int getFreePort() { ServerSocket tmp; int i = 10000; while (true) { try { i = RandomUtils.nextInt(10000, 65535); tmp = new ServerSocket(i); tmp.close(); tmp = null; return i; } catch (Exception e4) { continue; } } }
From source file:com.qwazr.cluster.manager.ClusterMasterThread.java
@Override public void run() { sleepMs(RandomUtils.nextInt(0, 5000)); super.run(); }
From source file:net.ceos.project.poi.annotated.bean.SimpleObjectBuilder.java
/** * Create a list of SimpleObject for tests. * //from w ww . j a v a 2 s.c o m * @return the {@link SimpleObject} */ public static List<SimpleObject> buildListOfSimpleObject(int entryNumber) { List<SimpleObject> returnList = new ArrayList<>(); for (int i = 0; i < entryNumber; i++) { returnList.add(buildSimpleObject(RandomUtils.nextInt(1, entryNumber))); } return returnList; }
From source file:com.qwazr.externalizor.AbstractCollection.java
public AbstractCollection() { this.abstractMap = new HashMap<>(); this.abstractSet = new HashSet<>(); this.abstractList = new ArrayList<>(); for (int i = 0; i < RandomUtils.nextInt(5, 10); i++) { abstractMap.put(RandomStringUtils.randomAlphanumeric(4), RandomStringUtils.randomAlphanumeric(5)); abstractSet.add(RandomStringUtils.randomAlphanumeric(6)); abstractList.add(RandomStringUtils.randomAlphanumeric(7)); }/* ww w. ja va 2 s.com*/ }
From source file:com.creactiviti.piper.core.taskhandler.random.RandomInt.java
@Override public Object handle(Task aTask) throws Exception { int startInclusive = aTask.getInteger("startInclusive", 0); int endInclusive = aTask.getInteger("endInclusive", 100); return RandomUtils.nextInt(startInclusive, endInclusive); }