List of usage examples for com.liferay.portal.kernel.util StringUtil randomString
public static String randomString(int length)
From source file:com.liferay.content.targeting.service.test.service.ServiceTestUtil.java
License:Open Source License
public static String randomString(int length) throws Exception { return StringUtil.randomString(length); }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test(expected = FileNameException.class) public void testAddFileEntry() throws Exception { String name = StringUtil.randomString(20) + PropsValues.DL_CHAR_BLACKLIST[0]; addFileEntry(name);/*from www . j a va 2 s . c om*/ }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test(expected = FolderNameException.class) public void testAddFolder() throws Exception { String name = StringUtil.randomString(20) + PropsValues.DL_CHAR_BLACKLIST[0]; ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); DLAppServiceUtil.addFolder(_group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, name, RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testFixNameBackSlash() { String random1 = StringUtil.randomString(10); String random2 = StringUtil.randomString(10); String name = random1 + StringPool.BACK_SLASH + random2; Assert.assertEquals(random1 + StringPool.UNDERLINE + random2, DLValidatorUtil.fixName(name)); }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testFixNameBlacklist() throws Exception { for (String blacklistName : PropsValues.DL_NAME_BLACKLIST) { String name = blacklistName; Assert.assertEquals(blacklistName + StringPool.UNDERLINE, DLValidatorUtil.fixName(name)); name = blacklistName + ".txt"; Assert.assertEquals(blacklistName + StringPool.UNDERLINE + ".txt", DLValidatorUtil.fixName(name)); name = blacklistName + StringUtil.randomString(10); Assert.assertEquals(name, DLValidatorUtil.fixName(name)); name = blacklistName + StringUtil.randomString(10) + " .txt"; Assert.assertEquals(name, DLValidatorUtil.fixName(name)); }/* w w w. j a v a 2 s.com*/ }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testFixNameBlacklistLastCharacter() throws Exception { for (String blacklistLastChar : _DL_CHAR_LAST_BLACKLIST) { String name = StringUtil.randomString(20); Assert.assertEquals(name, DLValidatorUtil.fixName(name + blacklistLastChar)); }/*from www .j av a2s . co m*/ }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testFixNameHiddenOSX() throws Exception { String name = "._" + StringUtil.randomString(20) + ".tmp"; Assert.assertEquals(name, DLValidatorUtil.fixName(name)); }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testFixNameRandom() throws Exception { for (String blacklistChar : PropsValues.DL_CHAR_BLACKLIST) { StringBuilder sb = new StringBuilder(4); sb.append(StringUtil.randomString(10)); sb.append(blacklistChar);/* w w w .ja v a 2 s .c om*/ sb.append(StringUtil.randomString(10)); String name = sb.toString(); Assert.assertEquals(name.replace(blacklistChar, StringPool.UNDERLINE), DLValidatorUtil.fixName(sb.toString())); sb.append(".txt"); Assert.assertEquals(sb.toString().replace(blacklistChar, StringPool.UNDERLINE), DLValidatorUtil.fixName(sb.toString())); } }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testIsValidNameBackSlash() { String name = StringUtil.randomString(10) + StringPool.BACK_SLASH + StringUtil.randomString(10); Assert.assertFalse(name, DLValidatorUtil.isValidName(name)); }
From source file:com.liferay.document.library.util.test.DLDirectoryNameAndFileNameTest.java
License:Open Source License
@Test public void testIsValidNameBlacklist() throws Exception { for (String blacklistName : PropsValues.DL_NAME_BLACKLIST) { String name = blacklistName; Assert.assertFalse(name, DLValidatorUtil.isValidName(name)); name = blacklistName + ".txt"; Assert.assertFalse(name, DLValidatorUtil.isValidName(name)); name = blacklistName + StringUtil.randomString(10); Assert.assertTrue(name, DLValidatorUtil.isValidName(name)); name = blacklistName + StringUtil.randomString(10) + " .txt"; Assert.assertTrue(name, DLValidatorUtil.isValidName(name)); }/*from w w w . ja va2s . c o m*/ }