📄 abstractjbpmdemomiscmethods1testcase.java
字号:
/** * $Source: /home/ws/rz65/CVS-Repository/WorkflowProjects/JBPM-Demo/src/test/testjbpmdemo/AbstractJBPMDemoMiscMethods1TestCase.java,v $ * $Revision: 1.1 $ * $Date: 2005/03/07 12:27:58 $ * $Author: rz65 $ * * Copyright (c) 2005 Universitaet Karlsruhe (TH) / Rechenzentrum (RZ-UNI-UKA) * * RZ-UNI-KA makes no representations or warranties about the suitability * of this software, either express or implied, including but not limited * to the implied warranties of merchantability, fitness for a particular * purpose, or non-infringement. RZ-UNI-KA shall not be liable for any * damages as a result of using, modifying or distributing this software * or its derivatives. */package testjbpmdemo;import java.util.Random;import org.apache.commons.lang.RandomStringUtils;/** * This class provides several methods. * * <p> * * @version $Revision: 1.1 $ * @author mailto:harald.meyer@rz.uni-karlsruhe.de */public abstract class AbstractJBPMDemoMiscMethods1TestCase extends AbstractJBPMDemoMiscMethods0TestCase { /** * Builds a test case instance. * * @param name * The name of the case. */ public AbstractJBPMDemoMiscMethods1TestCase(String name) { super(name); } private static Random random = new Random(); /** * returns the current time. * * @return The number of milliseconds since 1970/1/1 0:0 UTC. */ public static long currentTimeMillis() { return System.currentTimeMillis(); } /** * Returns a random int. * * @return A random number. */ public static int randomInt() { return random.nextInt(); } /** * Returns a random int. * * @param ub * The upper boundary for the value. * @return A random number. */ public static int randomInt(int ub) { return (random.nextInt() & Integer.MAX_VALUE) % ub; } /** * Returns a random long. * * @return A random number. */ public static long randomLong() { return random.nextLong(); } /** * Returns a random long. * * @param ub * The upper boundary for the value. * @return A random number. */ public static long randomLong(long ub) { return (random.nextLong() & Long.MAX_VALUE) % ub; } /** * Returns a random timestamp from the range now - 1 year ... now. * * @return A random timestamp in milliseconds since 1970/1/1 0:0 UTC. */ public static long randomTimeMillis() { return randomTimeMillis(1000L * 86400L * 365L); } /** * Returns a random timestamp in the past. * * @param ub * The maximum interval length towards the past. * @return A random timestamp in milliseconds since 1970/1/1 0:0 UTC. */ public static long randomTimeMillis(long ub) { return System.currentTimeMillis() - randomLong(ub); } /** * Returns a random double. * * @return A random number. */ public static double randomDouble() { return random.nextDouble(); } /** * Returns a random double. * * @param ub * The upper boundary for the value. * @return A random number. */ public static double randomDouble(double ub) { return ub * random.nextDouble(); } /** * Returns a random float. * * @return A random number. */ public static float randomFloat() { return random.nextFloat(); } /** * Returns a random float. * * @param ub * The upper boundary for the value. * @return A random number. */ public static float randomFloat(float ub) { return ub * random.nextFloat(); } /** * Returns a random upper case alphanumeric string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomUpperCaseAlphanumeric(int n) { String s = RandomStringUtils.randomAlphanumeric(n); return s.toUpperCase(); } /** * Returns a random lower case alphanumeric string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomLowerCaseAlphanumeric(int n) { String s = RandomStringUtils.randomAlphanumeric(n); return s.toLowerCase(); } /** * Returns a random mixed case alphanumeric string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomMixedCaseAlphanumeric(int n) { String s = RandomStringUtils.randomAlphanumeric(n); return mixedCase(s); } private static String mixedCase(String s) { StringBuffer sb = new StringBuffer(); int n = s.length(); for (int i = 0; i < n; i++) { char ch = s.charAt(i); if (random.nextBoolean()) { sb.append(Character.toUpperCase(ch)); } else { sb.append(Character.toLowerCase(ch)); } } return sb.toString(); } /** * Returns a random upper case alphabetic string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomUpperCaseAlphabetic(int n) { String s = RandomStringUtils.randomAlphabetic(n); return s.toUpperCase(); } /** * Returns a random lower case alphabetic string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomLowerCaseAlphabetic(int n) { String s = RandomStringUtils.randomAlphabetic(n); return s.toLowerCase(); } /** * Returns a random mixed case alphabetic string. * * @param n * The lenght of the string. * @return A random string. */ public static String randomMixedCaseAlphabetic(int n) { String s = RandomStringUtils.randomAlphabetic(n); return mixedCase(s); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -