Java Code Examples for org.apache.commons.lang3.RandomStringUtils#randomNumeric()

The following examples show how to use org.apache.commons.lang3.RandomStringUtils#randomNumeric() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersonServiceTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testCreatePerson() throws Exception
{
    String userName  = RandomStringUtils.randomNumeric(6);
            
    // Create a new person
    JSONObject result = createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                            Status.STATUS_OK);        
    assertEquals(userName, result.get("userName"));
    assertEquals("myFirstName", result.get("firstName"));
    assertEquals("myLastName", result.get("lastName"));
    assertEquals("myOrganisation", result.get("organization"));
    assertEquals("myJobTitle", result.get("jobtitle"));
    assertEquals("[email protected]", result.get("email"));
    
    // Check for duplicate names
    createPerson(userName, "myTitle", "myFirstName", "mylastName", "myOrganisation",
            "myJobTitle", "myEmail", "myBio", "images/avatar.jpg", 0, 409);
}
 
Example 2
Source File: TestOzoneManagerHAMetadataOnly.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
private OzoneVolume createAndCheckVolume(String volumeName)
    throws Exception {
  String userName = "user" + RandomStringUtils.randomNumeric(5);
  String adminName = "admin" + RandomStringUtils.randomNumeric(5);
  VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
      .setOwner(userName)
      .setAdmin(adminName)
      .build();

  ObjectStore objectStore = getObjectStore();
  objectStore.createVolume(volumeName, createVolumeArgs);

  OzoneVolume retVolume = objectStore.getVolume(volumeName);

  Assert.assertTrue(retVolume.getName().equals(volumeName));
  Assert.assertTrue(retVolume.getOwner().equals(userName));
  Assert.assertTrue(retVolume.getAdmin().equals(adminName));

  return retVolume;
}
 
Example 3
Source File: PersonServiceTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testDisableEnablePerson() throws Exception
{
    String userName = RandomStringUtils.randomNumeric(6);

    // Create a new person
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation", "myJobTitle", "[email protected]", "myBio",
            "images/avatar.jpg", 0, Status.STATUS_OK);

    String currentUser = this.authenticationComponent.getCurrentUserName();
    String adminUser = this.authenticationComponent.getSystemUserName();
    this.authenticationComponent.setCurrentUser(adminUser);

    // Check if user is enabled
    assertTrue("User isn't enabled", personService.isEnabled(userName));

    this.authenticationComponent.setCurrentUser(adminUser);
    // Disable user
    authenticationService.setAuthenticationEnabled(userName, false);

    this.authenticationComponent.setCurrentUser(adminUser);
    // Check user status
    assertFalse("User must be disabled", personService.isEnabled(userName));

    // Delete the person
    deletePerson(userName, Status.STATUS_OK);

    this.authenticationComponent.setCurrentUser(currentUser);
}
 
Example 4
Source File: TestOzoneRpcClientAbstract.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Test
public void testListBucketsOnEmptyVolume()
    throws IOException {
  String volume = "vol-" + RandomStringUtils.randomNumeric(5);
  store.createVolume(volume);
  OzoneVolume vol = store.getVolume(volume);
  Iterator<? extends OzoneBucket> buckets = vol.listBuckets("");
  while(buckets.hasNext()) {
    fail();
  }
}
 
Example 5
Source File: CaptchaController.java    From oauth2-server with MIT License 5 votes vote down vote up
/**
 * 短信证码
 *
 * @param phone   手机号
 * @param graphId 图形验证码id
 */
@ResponseBody
@RequestMapping(value = "/captcha/sms")
public Map<String, Object> captchaSms(@RequestParam(value = "signType", required = false, defaultValue = "signIn") String signType,
                                      @RequestParam(value = "phone") String phone,
                                      @RequestParam(value = "captcha") String inputCaptcha, @RequestParam(value = "graphId") String graphId) {
    Map<String, Object> resultMap = new HashMap<>(16);

    String captcha = captchaService.getCaptcha(CachesEnum.GraphCaptchaCache, graphId);

    if (StringUtils.equalsIgnoreCase(inputCaptcha, captcha)) {

        if (StringUtils.equalsIgnoreCase(signType, "signIn") && !userAccountService.existsByUsername(phone)) {
            resultMap.put("status", 0);
            resultMap.put("message", "账号不存在");
            return resultMap;
        }

        String uuid = UUID.randomUUID().toString();
        String smsCaptcha = RandomStringUtils.randomNumeric(4);

        captchaService.saveCaptcha(CachesEnum.SmsCaptchaCache, uuid, phone + "_" + smsCaptcha);

        log.info("smsCaptcha=" + smsCaptcha);
        // TODO send sms smsCaptcha

        resultMap.put("status", 1);
        resultMap.put("smsId", uuid);
        resultMap.put("ttl", CachesEnum.SmsCaptchaCache.getTtl());
        captchaService.removeCaptcha(CachesEnum.GraphCaptchaCache, graphId);
    } else {
        resultMap.put("status", 0);
        resultMap.put("message", "验证码错误!");
    }

    return resultMap;
}
 
Example 6
Source File: TestOzoneManagerHA.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
protected OzoneBucket setupBucket() throws Exception {
  String userName = "user" + RandomStringUtils.randomNumeric(5);
  String adminName = "admin" + RandomStringUtils.randomNumeric(5);
  String volumeName = "volume" + RandomStringUtils.randomNumeric(5);

  VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
      .setOwner(userName)
      .setAdmin(adminName)
      .build();

  objectStore.createVolume(volumeName, createVolumeArgs);
  OzoneVolume retVolumeinfo = objectStore.getVolume(volumeName);

  Assert.assertTrue(retVolumeinfo.getName().equals(volumeName));
  Assert.assertTrue(retVolumeinfo.getOwner().equals(userName));
  Assert.assertTrue(retVolumeinfo.getAdmin().equals(adminName));

  String bucketName = UUID.randomUUID().toString();
  retVolumeinfo.createBucket(bucketName);

  OzoneBucket ozoneBucket = retVolumeinfo.getBucket(bucketName);

  Assert.assertTrue(ozoneBucket.getName().equals(bucketName));
  Assert.assertTrue(ozoneBucket.getVolumeName().equals(volumeName));

  return ozoneBucket;
}
 
Example 7
Source File: TestOzoneManagerRestart.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Test
public void testRestartOMWithBucketOperation() throws Exception {
  String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
  String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);

  OzoneClient client = cluster.getClient();

  ObjectStore objectStore = client.getObjectStore();

  objectStore.createVolume(volumeName);

  OzoneVolume ozoneVolume = objectStore.getVolume(volumeName);
  Assert.assertTrue(ozoneVolume.getName().equals(volumeName));

  ozoneVolume.createBucket(bucketName);

  OzoneBucket ozoneBucket = ozoneVolume.getBucket(bucketName);
  Assert.assertTrue(ozoneBucket.getName().equals(bucketName));

  cluster.restartOzoneManager();
  cluster.restartStorageContainerManager(true);

  // After restart, try to create same bucket again, it should fail.
  try {
    ozoneVolume.createBucket(bucketName);
    fail("testRestartOMWithBucketOperation failed");
  } catch (IOException ex) {
    GenericTestUtils.assertExceptionContains("BUCKET_ALREADY_EXISTS", ex);
  }

  // Get bucket.
  ozoneBucket = ozoneVolume.getBucket(bucketName);
  Assert.assertTrue(ozoneBucket.getName().equals(bucketName));

}
 
Example 8
Source File: PersonServiceTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testDeletePerson() throws Exception
{
    // Create a new person
    String userName  = RandomStringUtils.randomNumeric(6);                
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
                            "myJobTitle", "[email protected]", "myBio", "images/avatar.jpg", 0,
                            Status.STATUS_OK);
    
    // Delete the person
    deletePerson(userName, Status.STATUS_OK);
    
    // Make sure that the person has been deleted and no longer exists
    deletePerson(userName, Status.STATUS_NOT_FOUND);
}
 
Example 9
Source File: SecurityCodeServiceImpl.java    From mblog with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional
public String generateCode(String key, int type, String target) {
    SecurityCode po = securityCodeRepository.findByKey(key);

    String code = RandomStringUtils.randomNumeric(6);
    Date now = new Date();

    if (po == null) {
        po = new SecurityCode();
        po.setKey(key);
        po.setCreated(now);
        po.setExpired(DateUtils.addMinutes(now, survivalTime));
        po.setCode(code);
        po.setType(type);
        po.setTarget(target);
    } else {

        long interval = ( now.getTime() - po.getCreated().getTime() ) / 1000;

        if (interval <= 60) {
            throw new MtonsException("发送间隔时间不能少于1分钟");
        }

        // 把 验证位 置0
        po.setStatus(EntityStatus.ENABLED);
        po.setCreated(now);
        po.setExpired(DateUtils.addMinutes(now, survivalTime));
        po.setCode(code);
        po.setType(type);
        po.setTarget(target);
    }

    securityCodeRepository.save(po);

    return code;
}
 
Example 10
Source File: TestContainerReportWithKeys.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Test
public void testContainerReportKeyWrite() throws Exception {
  final String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
  final String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
  final String keyName = "key" + RandomStringUtils.randomNumeric(5);
  final int keySize = 100;

  OzoneClient client = OzoneClientFactory.getRpcClient(conf);
  ObjectStore objectStore = client.getObjectStore();
  objectStore.createVolume(volumeName);
  objectStore.getVolume(volumeName).createBucket(bucketName);
  OzoneOutputStream key =
      objectStore.getVolume(volumeName).getBucket(bucketName)
          .createKey(keyName, keySize, ReplicationType.STAND_ALONE,
              ReplicationFactor.ONE, new HashMap<>());
  String dataString = RandomStringUtils.randomAlphabetic(keySize);
  key.write(dataString.getBytes());
  key.close();

  OmKeyArgs keyArgs = new OmKeyArgs.Builder()
      .setVolumeName(volumeName)
      .setBucketName(bucketName)
      .setKeyName(keyName)
      .setType(HddsProtos.ReplicationType.STAND_ALONE)
      .setFactor(HddsProtos.ReplicationFactor.ONE).setDataSize(keySize)
      .setRefreshPipeline(true)
      .build();


  OmKeyLocationInfo keyInfo =
      cluster.getOzoneManager().lookupKey(keyArgs).getKeyLocationVersions()
          .get(0).getBlocksLatestVersionOnly().get(0);


  ContainerInfo cinfo = scm.getContainerInfo(keyInfo.getContainerID());

  LOG.info("SCM Container Info keyCount: {} usedBytes: {}",
      cinfo.getNumberOfKeys(), cinfo.getUsedBytes());
}
 
Example 11
Source File: TestOMRatisSnapshots.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Test
public void testInstallSnapshot() throws Exception {
  // Get the leader OM
  String leaderOMNodeId = OmFailoverProxyUtil
      .getFailoverProxyProvider(objectStore.getClientProxy())
      .getCurrentProxyOMNodeId();

  OzoneManager leaderOM = cluster.getOzoneManager(leaderOMNodeId);
  OzoneManagerRatisServer leaderRatisServer = leaderOM.getOmRatisServer();

  // Find the inactive OM
  String followerNodeId = leaderOM.getPeerNodes().get(0).getOMNodeId();
  if (cluster.isOMActive(followerNodeId)) {
    followerNodeId = leaderOM.getPeerNodes().get(1).getOMNodeId();
  }
  OzoneManager followerOM = cluster.getOzoneManager(followerNodeId);

  // Do some transactions so that the log index increases
  String userName = "user" + RandomStringUtils.randomNumeric(5);
  String adminName = "admin" + RandomStringUtils.randomNumeric(5);
  String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
  String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);

  VolumeArgs createVolumeArgs = VolumeArgs.newBuilder()
      .setOwner(userName)
      .setAdmin(adminName)
      .build();

  objectStore.createVolume(volumeName, createVolumeArgs);
  OzoneVolume retVolumeinfo = objectStore.getVolume(volumeName);

  retVolumeinfo.createBucket(bucketName);
  OzoneBucket ozoneBucket = retVolumeinfo.getBucket(bucketName);

  long leaderOMappliedLogIndex =
      leaderRatisServer.getLastAppliedTermIndex().getIndex();

  List<String> keys = new ArrayList<>();
  while (leaderOMappliedLogIndex < 2000) {
    keys.add(createKey(ozoneBucket));
    leaderOMappliedLogIndex =
        leaderRatisServer.getLastAppliedTermIndex().getIndex();
  }

  // Get the latest db checkpoint from the leader OM.
  OMTransactionInfo omTransactionInfo =
      OMTransactionInfo.readTransactionInfo(leaderOM.getMetadataManager());
  TermIndex leaderOMTermIndex =
      TermIndex.newTermIndex(omTransactionInfo.getCurrentTerm(),
          omTransactionInfo.getTransactionIndex());
  long leaderOMSnaphsotIndex = leaderOMTermIndex.getIndex();
  long leaderOMSnapshotTermIndex = leaderOMTermIndex.getTerm();

  DBCheckpoint leaderDbCheckpoint =
      leaderOM.getMetadataManager().getStore().getCheckpoint(false);

  // Start the inactive OM
  cluster.startInactiveOM(followerNodeId);

  // The recently started OM should be lagging behind the leader OM.
  long followerOMLastAppliedIndex =
      followerOM.getOmRatisServer().getLastAppliedTermIndex().getIndex();
  Assert.assertTrue(
      followerOMLastAppliedIndex < leaderOMSnaphsotIndex);

  // Install leader OM's db checkpoint on the lagging OM.
  File oldDbLocation = followerOM.getMetadataManager().getStore()
      .getDbLocation();
  followerOM.getOmRatisServer().getOmStateMachine().pause();
  followerOM.getMetadataManager().getStore().close();
  followerOM.replaceOMDBWithCheckpoint(leaderOMSnaphsotIndex, oldDbLocation,
      leaderDbCheckpoint.getCheckpointLocation());

  // Reload the follower OM with new DB checkpoint from the leader OM.
  followerOM.reloadOMState(leaderOMSnaphsotIndex, leaderOMSnapshotTermIndex);
  followerOM.getOmRatisServer().getOmStateMachine().unpause(
      leaderOMSnaphsotIndex, leaderOMSnapshotTermIndex);

  // After the new checkpoint is loaded and state machine is unpaused, the
  // follower OM lastAppliedIndex must match the snapshot index of the
  // checkpoint.
  followerOMLastAppliedIndex = followerOM.getOmRatisServer()
      .getLastAppliedTermIndex().getIndex();
  Assert.assertEquals(leaderOMSnaphsotIndex, followerOMLastAppliedIndex);
  Assert.assertEquals(leaderOMSnapshotTermIndex,
      followerOM.getOmRatisServer().getLastAppliedTermIndex().getTerm());

  // Verify that the follower OM's DB contains the transactions which were
  // made while it was inactive.
  OMMetadataManager followerOMMetaMngr = followerOM.getMetadataManager();
  Assert.assertNotNull(followerOMMetaMngr.getVolumeTable().get(
      followerOMMetaMngr.getVolumeKey(volumeName)));
  Assert.assertNotNull(followerOMMetaMngr.getBucketTable().get(
      followerOMMetaMngr.getBucketKey(volumeName, bucketName)));
  for (String key : keys) {
    Assert.assertNotNull(followerOMMetaMngr.getKeyTable().get(
        followerOMMetaMngr.getOzoneKey(volumeName, bucketName, key)));
  }
}
 
Example 12
Source File: Sms.java    From rqueue with Apache License 2.0 4 votes vote down vote up
public static Sms newInstance() {
  String txt = "Dear , Version 2.0 of Rqueue is released.";
  Sms sms = new Sms("+91" + RandomStringUtils.randomNumeric(10), txt);
  sms.setId(UUID.randomUUID().toString());
  return sms;
}
 
Example 13
Source File: ValidateController.java    From SpringAll with MIT License 4 votes vote down vote up
private SmsCode createSMSCode() {
    String code = RandomStringUtils.randomNumeric(6);
    return new SmsCode(code);
}
 
Example 14
Source File: SmokeTest.java    From codenjoy with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void test() throws IOException {
    // given
    List<String> messages = new LinkedList<>();

    LocalGameRunner.timeout = 0;
    LocalGameRunner.out = message -> {
        // System.out.println(message);
        messages.add(message);
    };
    LocalGameRunner.countIterations = 1000;
    LocalGameRunner.printConversions = false;
    LocalGameRunner.printBoardOnly = true;
    LocalGameRunner.printDice = false;
    LocalGameRunner.printTick = true;

    String soul = RandomStringUtils.randomNumeric(30);
    soul = "435874345435874365843564398";
    Dice dice = LocalGameRunner.getDice(LocalGameRunner.generateXorShift(soul, 100, 200));

    DefaultGameSettings.BOARD_SIZE = 11;
    DefaultGameSettings.BOMB_POWER = 3;
    DefaultGameSettings.BOMBS_COUNT = 1;
    DefaultGameSettings.DESTROY_WALL_COUNT = 14;
    DefaultGameSettings.MEAT_CHOPPERS_COUNT = 3;
    PerksSettingsWrapper.setDropRatio(20);
    PerksSettingsWrapper.setPerkSettings(Elements.BOMB_BLAST_RADIUS_INCREASE, 5, 10);
    PerksSettingsWrapper.setPerkSettings(Elements.BOMB_REMOTE_CONTROL, 5, 10);
    PerksSettingsWrapper.setPerkSettings(Elements.BOMB_IMMUNE, 5, 10);
    PerksSettingsWrapper.setPerkSettings(Elements.BOMB_COUNT_INCREASE, 5, 3);

    GameRunner gameType = new GameRunner() {
        @Override
        public Dice getDice() {
            return dice;
        }

        @Override
        protected GameSettings getGameSettings() {
            return new DefaultGameSettings(dice);
        }
    };

    // when
    LocalGameRunner.run(gameType,
            Arrays.asList(new AISolver(dice), new AIPerksHunterSolver(dice)),
            Arrays.asList(new Board(), new Board()));

    // then
    assertEquals(load("src/test/resources/SmokeTest.data"),
            String.join("\n", messages));

}
 
Example 15
Source File: ValidateController.java    From SpringAll with MIT License 4 votes vote down vote up
private SmsCode createSMSCode() {
    String code = RandomStringUtils.randomNumeric(6);
    return new SmsCode(code, 60);
}
 
Example 16
Source File: InviteServiceTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void testStartInviteWhenInviteeIsAlreadyMemberOfSite()
    throws Exception
{
    //
    // add invitee as member of site: SITE_SHORT_NAME_INVITE
    //

    String randomStr = RandomStringUtils.randomNumeric(6);
    final String inviteeUserName = "inviteeUserName" + randomStr;
    final String inviteeEmailAddr = INVITEE_EMAIL_PREFIX + randomStr
        + "@" + INVITEE_EMAIL_DOMAIN;

    // create person with invitee user name and invitee email address
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {
            createPerson(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeUserName, inviteeEmailAddr);
            return null;
        }

    }, AuthenticationUtil.getSystemUserName());

    // add invitee person to site: SITE_SHORT_NAME_INVITE
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {

            InviteServiceTest.this.siteService.setMembership(
                    SITE_SHORT_NAME_INVITE_1, inviteeUserName,
                    INVITEE_SITE_ROLE);
            return null;
        }

    }, USER_INVITER);

    /**
     * Should conflict
     */
    startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE,
            SITE_SHORT_NAME_INVITE_1, Status.STATUS_CONFLICT);

    // Should go through
    startInvite(INVITEE_FIRSTNAME, "Belzebub", inviteeEmailAddr, INVITEE_SITE_ROLE,
            SITE_SHORT_NAME_INVITE_1, Status.STATUS_CREATED);

    // Should go through
    startInvite("Lucifer", INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE,
            SITE_SHORT_NAME_INVITE_1, Status.STATUS_CREATED);
}
 
Example 17
Source File: TestOmBlockVersioning.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Test
public void testReadLatestVersion() throws Exception {

  String userName = "user" + RandomStringUtils.randomNumeric(5);
  String adminName = "admin" + RandomStringUtils.randomNumeric(5);
  String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
  String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
  String keyName = "key" + RandomStringUtils.randomNumeric(5);

  OzoneBucket bucket =
      TestDataUtil.createVolumeAndBucket(cluster, volumeName, bucketName);

  OmKeyArgs omKeyArgs = new OmKeyArgs.Builder()
      .setVolumeName(volumeName)
      .setBucketName(bucketName)
      .setKeyName(keyName)
      .setDataSize(1000)
      .setRefreshPipeline(true)
      .build();

  String dataString = RandomStringUtils.randomAlphabetic(100);

  TestDataUtil.createKey(bucket, keyName, dataString);
  assertEquals(dataString, TestDataUtil.getKey(bucket, keyName));
  OmKeyInfo keyInfo = ozoneManager.lookupKey(omKeyArgs);
  assertEquals(0, keyInfo.getLatestVersionLocations().getVersion());
  assertEquals(1,
      keyInfo.getLatestVersionLocations().getLocationList().size());

  // this write will create 2nd version, 2nd version will contain block from
  // version 1, and add a new block
  TestDataUtil.createKey(bucket, keyName, dataString);


  keyInfo = ozoneManager.lookupKey(omKeyArgs);
  assertEquals(dataString, TestDataUtil.getKey(bucket, keyName));
  assertEquals(1, keyInfo.getLatestVersionLocations().getVersion());
  assertEquals(2,
      keyInfo.getLatestVersionLocations().getLocationList().size());

  dataString = RandomStringUtils.randomAlphabetic(200);
  TestDataUtil.createKey(bucket, keyName, dataString);

  keyInfo = ozoneManager.lookupKey(omKeyArgs);
  assertEquals(dataString, TestDataUtil.getKey(bucket, keyName));
  assertEquals(2, keyInfo.getLatestVersionLocations().getVersion());
  assertEquals(3,
      keyInfo.getLatestVersionLocations().getLocationList().size());
}
 
Example 18
Source File: RandomUtil.java    From jhipster-microservices-example with Apache License 2.0 2 votes vote down vote up
/**
* Generate a reset key.
*
* @return the generated reset key
*/
public static String generateResetKey() {
    return RandomStringUtils.randomNumeric(DEF_COUNT);
}
 
Example 19
Source File: Randoms.java    From basic-tools with MIT License 2 votes vote down vote up
/**
     * 随机一个包含[minLen, maxLen]个数字的串
     * @param minLen
     * @param maxLen
     * @return
     */
    public static String randomOfD(int minLen, int maxLen) {
        return RandomStringUtils.randomNumeric(minLen,maxLen);
//        return random(CHARS_D, minLen, maxLen);
    }
 
Example 20
Source File: Randoms.java    From basic-tools with MIT License 2 votes vote down vote up
/**
     * 随机一个包含n个数字的串
     * @param n
     * @return
     */
    public static String randomOfD(int n) {
        return RandomStringUtils.randomNumeric(n);
//        return random(CHARS_D, n, n);
    }