Skip to content

Commit

Permalink
LPS-57476 Apply Usage 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mtambara authored and brianchandotcom committed Aug 20, 2015
1 parent 370e5d8 commit c39bddd
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.liferay.portal.model.User;
import com.liferay.portal.service.ImageLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portal.util.PropsValues;
Expand Down Expand Up @@ -240,7 +241,7 @@ protected void testMigrateAndCheckOldRepositoryFiles(Boolean delete)
FileEntry rootFileEntry = addFileEntry(
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
RandomTestUtil.randomString() + ".txt", ContentTypes.TEXT_PLAIN,
RandomTestUtil.randomBytes());
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE));

ServiceContext serviceContext =
ServiceContextTestUtil.getServiceContext(
Expand Down Expand Up @@ -288,7 +289,8 @@ protected void testMigrateAndCheckOldRepositoryFiles(Boolean delete)
protected void testMigrateDL(long folderId) throws Exception {
FileEntry fileEntry = addFileEntry(
folderId, RandomTestUtil.randomString() + ".txt",
ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes());
ContentTypes.TEXT_PLAIN,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE));

_convertProcess.convert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.liferay.portal.security.permission.PermissionThreadLocal;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
Expand Down Expand Up @@ -110,7 +111,8 @@ public void testRequestFileInTrash() throws Exception {
FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(
TestPropsValues.getUserId(), group.getGroupId(),
parentFolder.getFolderId(), "Test Trash.txt",
ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(),
ContentTypes.TEXT_PLAIN,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

MockHttpServletResponse mockHttpServletResponse = testRequestFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.asset.model.DDMFormValuesReader;
Expand Down Expand Up @@ -108,7 +109,7 @@ protected DLFileEntry addFileEntry() throws Exception {
ddmStructures.get(0));

ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
RandomTestUtil.randomBytes());
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE));

return DLFileEntryLocalServiceUtil.addFileEntry(
TestPropsValues.getUserId(), _group.getGroupId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextThreadLocal;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
Expand Down Expand Up @@ -94,7 +95,8 @@ public void testExportImportFileExtension() throws Exception {
FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(
TestPropsValues.getUserId(), stagingGroup.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, sourceFileName,
ContentTypes.APPLICATION_PDF, RandomTestUtil.randomBytes(),
ContentTypes.APPLICATION_PDF,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

exportImportStagedModel(fileEntry);
Expand Down Expand Up @@ -236,7 +238,8 @@ protected StagedModel addStagedModel(
return DLAppLocalServiceUtil.addFileEntry(
TestPropsValues.getUserId(), group.getGroupId(),
folder.getFolderId(), RandomTestUtil.randomString() + ".txt",
ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(),
ContentTypes.TEXT_PLAIN,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.liferay.portal.model.Group;
import com.liferay.portal.model.StagedModel;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.asset.model.AssetEntry;
Expand Down Expand Up @@ -83,7 +84,8 @@ protected Map<String, List<StagedModel>> addDependentStagedModelsMap(
TestPropsValues.getUserId(), group.getGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
RandomTestUtil.randomString() + ".txt", ContentTypes.TEXT_PLAIN,
RandomTestUtil.randomBytes(), serviceContext);
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

addDependentStagedModel(
dependentStagedModelsMap, DLFileEntry.class, fileEntry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.liferay.portal.service.ClassNameLocalServiceUtil;
import com.liferay.portal.service.RepositoryLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.asset.model.AssetEntry;
Expand Down Expand Up @@ -403,7 +404,8 @@ protected static FileEntry addFileEntry(ServiceContext serviceContext)
TestPropsValues.getUserId(), serviceContext.getScopeGroupId(),
DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
RandomTestUtil.randomString(), ContentTypes.TEXT_PLAIN, "Old Title",
RandomTestUtil.randomString(), null, RandomTestUtil.randomBytes(),
RandomTestUtil.randomString(), null,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);
}

Expand Down Expand Up @@ -491,7 +493,8 @@ protected static FileEntry updateFileEntry(
TestPropsValues.getUserId(), fileEntry.getFileEntryId(),
RandomTestUtil.randomString(), ContentTypes.TEXT_PLAIN, "New Title",
RandomTestUtil.randomString(), null, true,
RandomTestUtil.randomBytes(), serviceContext);
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.liferay.portal.security.permission.DoAsUserThread;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.test.ServiceTestUtil;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.ExpectedLog;
import com.liferay.portal.test.rule.ExpectedLogs;
import com.liferay.portal.test.rule.ExpectedType;
Expand Down Expand Up @@ -1214,7 +1215,8 @@ public void shouldFailIfSizeLimitExceeded() throws Exception {
new PrefsPropsTemporarySwapper(
PropsKeys.DL_FILE_MAX_SIZE, 1L)) {

byte[] bytes = RandomTestUtil.randomBytes();
byte[] bytes = RandomTestUtil.randomBytes(
TikaSafeRandomizerBumper.INSTANCE);

DLAppServiceUtil.updateFileEntry(
fileEntry.getFileEntryId(), fileName,
Expand Down Expand Up @@ -1562,7 +1564,8 @@ protected static FileEntry updateFileEntry(
return DLAppServiceUtil.updateFileEntry(
fileEntryId, fileName, ContentTypes.TEXT_PLAIN, fileName,
StringPool.BLANK, StringPool.BLANK, majorVersion,
RandomTestUtil.randomBytes(), serviceContext);
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);
}

private static final String _FILE_NAME = "Title.txt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.test.randomizerbumpers.TikaSafeRandomizerBumper;
import com.liferay.portal.test.rule.LiferayIntegrationTestRule;
import com.liferay.portal.test.rule.MainServletTestRule;
import com.liferay.portlet.documentlibrary.DuplicateFileException;
Expand Down Expand Up @@ -304,7 +305,8 @@ public void testAddFileEntryWithExtension() throws Exception {
DLAppServiceUtil.updateFileEntry(
tempFileEntry.getFileEntryId(), _FILE_NAME,
ContentTypes.TEXT_PLAIN, _STRIPPED_FILE_NAME, StringPool.BLANK,
StringPool.BLANK, false, RandomTestUtil.randomBytes(),
StringPool.BLANK, false,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

Assert.fail("Renamed" + _FAIL_DUPLICATE_MESSAGE_SUFFIX);
Expand Down Expand Up @@ -332,7 +334,8 @@ public void testAddFileEntryWithExtension() throws Exception {
DLAppServiceUtil.updateFileEntry(
tempFileEntry.getFileEntryId(), _FILE_NAME,
ContentTypes.TEXT_PLAIN, StringPool.BLANK, StringPool.BLANK,
StringPool.BLANK, false, RandomTestUtil.randomBytes(),
StringPool.BLANK, false,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

Assert.fail("Renamed" + _FAIL_DUPLICATE_MESSAGE_SUFFIX);
Expand Down Expand Up @@ -360,7 +363,8 @@ public void testAddFileEntryWithExtension() throws Exception {
DLAppServiceUtil.updateFileEntry(
tempFileEntry.getFileEntryId(), _STRIPPED_FILE_NAME,
ContentTypes.TEXT_PLAIN, _FILE_NAME, StringPool.BLANK,
StringPool.BLANK, false, RandomTestUtil.randomBytes(),
StringPool.BLANK, false,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

Assert.fail("Renamed" + _FAIL_DUPLICATE_MESSAGE_SUFFIX);
Expand Down Expand Up @@ -427,7 +431,8 @@ public void testAddFileEntryWithoutExtension() throws Exception {
DLAppServiceUtil.updateFileEntry(
tempFileEntry.getFileEntryId(), _STRIPPED_FILE_NAME,
ContentTypes.TEXT_PLAIN, StringPool.BLANK, StringPool.BLANK,
StringPool.BLANK, false, RandomTestUtil.randomBytes(),
StringPool.BLANK, false,
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);

Assert.fail("Renamed" + _FAIL_DUPLICATE_MESSAGE_SUFFIX);
Expand Down Expand Up @@ -480,7 +485,8 @@ protected FileEntry addFileEntry(String sourceFileName, String title)
TestPropsValues.getUserId(), group.getGroupId(),
parentFolder.getFolderId(), sourceFileName, ContentTypes.TEXT_PLAIN,
title, StringPool.BLANK, StringPool.BLANK,
RandomTestUtil.randomBytes(), serviceContext);
RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
serviceContext);
}

protected void testAddFileEntryBasic(
Expand Down

0 comments on commit c39bddd

Please sign in to comment.