/*
 * Copyright 2016 ZJNU ACM.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.edu.zjnu.acm.judge.util;

import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 *
 * @author zhanhb
 */
@Slf4j
public class UtilityTest {

    /**
     * Test of getRandomString method, of class Utility.
     */
    @Test
    public void testGetRandomString() {
        log.info("getRandomString");
        int length = 0;
        String result = Utility.getRandomString(length);
        assertEquals(length, result.length());
        for (int i = 0; i < 10; ++i) {
            length = 20;
            final String t = Utility.getRandomString(length);
            assertEquals(length, t.length());
            t.chars().forEach(ch -> Assert.assertTrue(t, Character.isLetterOrDigit(ch)));
        }
    }

}

@@ -13,16 +13,21 @@
 ght 2016
+-2019
  ZJNU AC
@@ -29,16 +29,16 @@
 NU ACM.%0A
-
  *%0A * Li
@@ -629,16 +629,63 @@
 .util;%0A%0A
+import java.util.concurrent.ThreadLocalRandom;%0A
 import l
@@ -1050,17 +1050,17 @@
 ength = 
-0
+8
 ;%0A      
@@ -1187,16 +1187,17 @@
 ; i %3C 10
+0
 ; ++i) %7B
@@ -1218,18 +1218,59 @@
 ength = 
-20
+ThreadLocalRandom.current().nextInt(35) + 6
 ;%0A      

Test Utility. getRandomString