Example usage for com.liferay.portal.kernel.util FileUtil getBytes

List of usage examples for com.liferay.portal.kernel.util FileUtil getBytes

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util FileUtil getBytes.

Prototype

public static byte[] getBytes(InputStream is, int bufferSize) throws IOException 

Source Link

Usage

From source file:com.liferay.adaptive.media.blogs.internal.exportimport.data.handler.test.AMBlogsEntryStagedModelDataHandlerTest.java

License:Open Source License

private FileEntry _addImageFileEntry(ServiceContext serviceContext) throws Exception {

    return _dlAppLocalService.addFileEntry(TestPropsValues.getUserId(), stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString(), ContentTypes.IMAGE_JPEG,
            FileUtil.getBytes(getClass(), "image.jpg"), serviceContext);
}

From source file:com.liferay.adaptive.media.blogs.web.internal.counter.test.BlogsAMImageCounterTest.java

License:Open Source License

private byte[] _getImageBytes() throws Exception {
    return FileUtil.getBytes(BlogsAMImageCounterTest.class,
            "/com/liferay/adaptive/media/blogs/web/internal/counter/test" + "/dependencies/image.jpg");
}

From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.test.BlogsAMImageOptimizerTest.java

License:Open Source License

private byte[] _getImageBytes() throws Exception {
    return FileUtil.getBytes(BlogsAMImageOptimizerTest.class,
            "/com/liferay/adaptive/media/blogs/web/internal/optimizer/test" + "/dependencies/image.jpg");
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.commands.test.AdaptiveMediaThumbnailsOSGiCommandsTest.java

License:Open Source License

private byte[] _getFileContents(String fileName) throws Exception {
    return FileUtil.getBytes(AdaptiveMediaThumbnailsOSGiCommandsTest.class,
            "/com/liferay/adaptive/media/document/library/thumbnails/internal" + "/commands/test/dependencies/"
                    + fileName);// w  w  w.j  a  v  a 2s.c  om
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.osgi.commands.test.AMThumbnailsOSGiCommandsTest.java

License:Open Source License

private byte[] _getFileContents(String fileName) throws Exception {
    return FileUtil.getBytes(AMThumbnailsOSGiCommandsTest.class,
            "/com/liferay/adaptive/media/document/library/thumbnails/internal"
                    + "/osgi/commands/test/dependencies/" + fileName);
}

From source file:com.liferay.adaptive.media.document.library.web.internal.counter.test.DLAMImageCounterTest.java

License:Open Source License

private byte[] _getImageBytes() throws Exception {
    return FileUtil.getBytes(DLAMImageCounterTest.class,
            "/com/liferay/adaptive/media/document/library/web/internal"
                    + "/counter/test/dependencies/image.jpg");
}

From source file:com.liferay.adaptive.media.document.library.web.internal.optimizer.test.DLAMImageOptimizerTest.java

License:Open Source License

private byte[] _getImageBytes() throws Exception {
    return FileUtil.getBytes(DLAMImageOptimizerTest.class,
            "/com/liferay/adaptive/media/document/library/web/internal"
                    + "/optimizer/test/dependencies/image.jpg");
}

From source file:com.liferay.adaptive.media.image.internal.configuration.test.AMImageDeleteConfigurationTest.java

License:Open Source License

private FileEntry _addFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".jpg",
            ContentTypes.IMAGE_JPEG,/*from   w  w  w. j  a v a2 s  .  c o  m*/
            FileUtil.getBytes(AMImageDeleteConfigurationTest.class, _JPG_IMAGE_FILE_PATH),
            new ServiceContext());
}

From source file:com.liferay.adaptive.media.image.internal.scaler.test.AMGIFImageScalerTest.java

License:Open Source License

@Test
public void testAMGIFImageScaler() throws Exception {
    Map<String, String> properties = new HashMap<>();

    properties.put("max-height", "100");
    properties.put("max-width", "100");

    FileEntry fileEntry = _addFileEntry();

    AMImageScaledImage amImageScaledImage = _amImageScaler.scaleImage(fileEntry.getFileVersion(),
            _amImageConfigurationEntry);

    Assert.assertEquals(25, amImageScaledImage.getHeight());
    Assert.assertEquals(100, amImageScaledImage.getWidth());

    Assert.assertArrayEquals(FileUtil.getBytes(AMGIFImageScalerTest.class, _FILE_PATH_SCALED_IMAGE),
            FileUtil.getBytes(amImageScaledImage.getInputStream()));
}

From source file:com.liferay.adaptive.media.image.internal.scaler.test.AMGIFImageScalerTest.java

License:Open Source License

private FileEntry _addFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".gif",
            ContentTypes.IMAGE_GIF, FileUtil.getBytes(AMGIFImageScalerTest.class, _FILE_PATH_GIF_IMAGE),
            new ServiceContext());
}