List of usage examples for com.liferay.portal.kernel.util FileUtil getBytes
public static byte[] getBytes(InputStream is, int bufferSize) throws IOException
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCleanUpProcessorsOnUpdate() throws Exception { AtomicBoolean cleanUp = registerCleanUpDLProcessor(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);//from ww w .j a va 2s .c o m Assert.assertTrue(cleanUp.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCleanUpProcessorsOnUpdateAndCheckIn() throws Exception { AtomicBoolean cleanUp = registerCleanUpDLProcessor(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); byte[] bytes = FileUtil.getBytes(getClass(), "dependencies/test.pdf"); InputStream inputStream = new ByteArrayInputStream(bytes); DLAppServiceUtil.updateFileEntryAndCheckIn(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, inputStream, bytes.length, _serviceContext); Assert.assertTrue(cleanUp.get());/*from ww w . j a v a 2s . c o m*/ }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCopyPreviousPreviewOnCheckIn() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.checkInFileEntry(fileEntry.getFileEntryId(), true, StringUtil.randomString(), _serviceContext);//from ww w. j a v a2 s .c o m Assert.assertEquals(1, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCopyPreviousPreviewOnCheckOut() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext); Assert.assertEquals(1, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCopyPreviousPreviewOnRevert() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); String version = fileEntry.getVersion(); fileEntry = DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);//w ww . ja v a2 s . c o m Assert.assertNotEquals(version, fileEntry.getVersion()); DLAppServiceUtil.revertFileEntry(fileEntry.getFileEntryId(), version, _serviceContext); Assert.assertEquals(1, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCopyPreviousPreviewOnUpdateAndCheckInWithNoContent() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.updateFileEntryAndCheckIn(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, null, 0, _serviceContext); Assert.assertEquals(2, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCopyPreviousPreviewOnUpdateWithNoContent() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, new byte[0], _serviceContext); Assert.assertEquals(1, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCreateNewPreviewOnAdd() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.GENERATE_NEW); DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); Assert.assertEquals(1, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCreateNewPreviewOnCancelCheckOut() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.GENERATE_NEW); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext); DLAppServiceUtil.cancelCheckOut(fileEntry.getFileEntryId()); Assert.assertEquals(2, count.get()); }
From source file:com.liferay.document.library.service.test.PDFProcessorTest.java
License:Open Source License
@Test public void testShouldCreateNewPreviewOnUpdateAndCheckInWithContent() throws Exception { AtomicInteger count = registerPDFProcessorMessageListener(EventType.GENERATE_NEW); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext); byte[] bytes = FileUtil.getBytes(getClass(), "dependencies/test.pdf"); InputStream inputStream = new ByteArrayInputStream(bytes); DLAppServiceUtil.updateFileEntryAndCheckIn(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf", ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(), StringUtil.randomString(), true, inputStream, bytes.length, _serviceContext); Assert.assertEquals(2, count.get()); }