use of org.pentaho.platform.plugin.services.importer.IPlatformImporter in project data-access by pentaho.
the class MetadataServiceTest method testImportMetadataDatasourceMaxFileSize.
@Test(expected = PlatformImportException.class)
public void testImportMetadataDatasourceMaxFileSize() throws Exception {
// test should work in case max-file-limit is set
int fileDefaultSize = 10000000;
String maxFileLimit = PentahoSystem.getSystemSetting("file-upload-defaults/max-file-limit", // $NON-NLS-1$
String.valueOf(fileDefaultSize));
assertEquals(fileDefaultSize, Integer.parseInt(maxFileLimit));
// fileDefaultSize will be exceeded
byte[] bytes = new byte[fileDefaultSize + 1];
InputStream metadataFile = new ByteArrayInputStream(bytes);
FileResource mockFileResource = mock(FileResource.class);
Response mockResponse = mock(Response.class);
IPlatformImporter mockIPlatformImporter = mock(IPlatformImporter.class);
doNothing().when(metadataService).accessValidation();
doReturn(mockFileResource).when(metadataService).createNewFileResource();
doReturn(mockResponse).when(mockFileResource).doGetReservedChars();
doReturn(mockIPlatformImporter).when(metadataService).getImporter();
metadataService.importMetadataDatasource("test_file", metadataFile, null, false, null, null, null);
}
Aggregations