-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial unit test for MemoRegenerator
Use the tubhiswt-2D OME-TIFF sample for the 2013-06 which requires the xalan library to be transformed to the 2016-06 version Without the dependency, the Bio-Formats reader should fall back to the basic TIFF reader and only detect one channel
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/test/java/com/glencoesoftware/omero/ms/image/region/MemoRegeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (C) 2024 Glencoe Software, Inc. All rights reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
package com.glencoesoftware.omero.ms.image.region; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import loci.formats.FormatException; | ||
import loci.formats.IFormatReader; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Test; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import ome.io.nio.BackOff; | ||
import ome.io.nio.ConfiguredTileSizes; | ||
import ome.io.nio.FilePathResolver; | ||
import ome.io.nio.PixelsService; | ||
import ome.io.nio.PixelBuffer; | ||
import ome.io.nio.SimpleBackOff; | ||
import ome.model.core.Pixels; | ||
import ome.model.enums.PixelsType; | ||
|
||
public class MemoRegeneratorTest { | ||
|
||
private PixelsService pixelsService; | ||
private FilePathResolver resolver; | ||
private BackOff backOff = new SimpleBackOff(); | ||
|
||
@Before | ||
public void setUp() throws IOException { | ||
Path tmpDir = Files.createTempDirectory("memo-test"); | ||
resolver = mock(FilePathResolver.class); | ||
ConfiguredTileSizes sizes = new ConfiguredTileSizes(256, 256, 3192, 3192); | ||
pixelsService = new PixelsService( | ||
tmpDir.toString(), resolver, backOff, sizes, null); | ||
} | ||
|
||
@Test | ||
public void testOMEXMLTranformation() throws FormatException, IOException{ | ||
|
||
// Sample OME-TIFF file using the 2013-06 schema which requires the | ||
// xalan library during the transformation to the 2016-06 model | ||
ClassLoader classLoader = getClass().getClassLoader(); | ||
String filePath = new File(classLoader | ||
.getResource("tubhiswt-2D/tubhiswt_C0.ome.tif").getFile()) | ||
.getAbsolutePath(); | ||
|
||
Pixels pixels = mock(Pixels.class); | ||
PixelsType pixelsType = new PixelsType("uint8"); | ||
when(pixels.getPixelsType()).thenReturn(pixelsType); | ||
when(pixels.getSizeX()).thenReturn(512); | ||
when(pixels.getSizeY()).thenReturn(512); | ||
when(resolver.getOriginalFilePath(pixelsService, pixels)).thenReturn(filePath); | ||
|
||
PixelBuffer buffer = pixelsService.getPixelBuffer(pixels, false); | ||
Assert.assertEquals(2, buffer.getSizeC()); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.