Move RandomStringUtils

This commit is contained in:
Gabriele C
2016-10-04 19:16:06 +02:00
parent 42dbb27728
commit f3cd193d47
14 changed files with 35 additions and 33 deletions
@@ -1,5 +1,6 @@
package fr.xephi.authme.security;
import fr.xephi.authme.util.RandomStringUtils;
import org.junit.Test;
import java.util.regex.Pattern;
@@ -8,9 +9,9 @@ import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Test for {@link RandomString}.
* Test for {@link RandomStringUtils}.
*/
public class RandomStringTest {
public class RandomStringUtilsTest {
@Test
public void shouldGenerateRandomStrings() {
@@ -20,7 +21,7 @@ public class RandomStringTest {
// when / then
for (int length : lengths) {
String result = RandomString.generate(length);
String result = RandomStringUtils.generate(length);
assertThat("Result '" + result + "' should have length " + length,
result.length(), equalTo(length));
assertThat("Result '" + result + "' should only have characters a-z, 0-9",
@@ -36,7 +37,7 @@ public class RandomStringTest {
// when / then
for (int length : lengths) {
String result = RandomString.generateHex(length);
String result = RandomStringUtils.generateHex(length);
assertThat("Result '" + result + "' should have length " + length,
result.length(), equalTo(length));
assertThat("Result '" + result + "' should only have characters a-f, 0-9",
@@ -52,7 +53,7 @@ public class RandomStringTest {
// when / then
for (int length : lengths) {
String result = RandomString.generateHex(length);
String result = RandomStringUtils.generateHex(length);
assertThat("Result '" + result + "' should have length " + length,
result.length(), equalTo(length));
assertThat("Result '" + result + "' should only have characters a-z, A-Z, 0-9",
@@ -63,7 +64,7 @@ public class RandomStringTest {
@Test(expected = IllegalArgumentException.class)
public void shouldThrowForInvalidLength() {
// given/when
RandomString.generate(-3);
RandomStringUtils.generate(-3);
// then - throw exception
}