@Test(dependsOnMethods = {"testMetadataLevel"}) public void testMetadataLevelEquivilentDimensions() { assertEquals(wrapper.getSeriesCount(), minimalWrapper.getSeriesCount()); for (int i = 0; i < minimalWrapper.getSeriesCount(); i++) { wrapper.setSeries(i); minimalWrapper.setSeries(i); assertEquals(wrapper.getSizeX(), minimalWrapper.getSizeX()); assertEquals(wrapper.getSizeY(), minimalWrapper.getSizeY()); assertEquals(wrapper.getSizeZ(), minimalWrapper.getSizeZ()); assertEquals(wrapper.getSizeC(), minimalWrapper.getSizeC()); assertEquals(wrapper.getSizeT(), minimalWrapper.getSizeT()); assertEquals(wrapper.getPixelType(), minimalWrapper.getPixelType()); assertEquals(wrapper.isLittleEndian(), minimalWrapper.isLittleEndian()); } }
@Test(dependsOnMethods = {"testMetadataLevel"}) public void testEquivilentBlockRetrievalPlaneData() throws FormatException, IOException { String fileName = wrapper.getCurrentFile(); int sizeX = wrapper.getSizeX(); int sizeY = wrapper.getSizeY(); int sizeZ = wrapper.getSizeZ(); int sizeC = wrapper.getSizeC(); int sizeT = wrapper.getSizeT(); int bytesPerPixel = wrapper.getBitsPerPixel() / 8; int planeSize = sizeX * sizeY * bytesPerPixel; byte[] planar = new byte[planeSize]; byte[] block = new byte[planeSize]; int planeNumber = 0; String planarDigest; String blockDigest; for (int t = 0; t < sizeT; t++) { for (int c = 0; c < sizeC; c++) { for (int z = 0; z < sizeZ; z++) { planeNumber = wrapper.getIndex(z, c, t); wrapper.openPlane2D(fileName, planeNumber, planar); planarDigest = sha1(planar); wrapper.openPlane2D(fileName, planeNumber, block, 0, 0, sizeX, sizeY); blockDigest = sha1(block); assertEquals(planarDigest, blockDigest); } } } }
/** * Parse the binary data to generate min/max values and allow an md to be calculated. * * @param series * @return The SHA1 message digest for the binary data. */ public MessageDigest parseData(String fileName, int series, ImportSize size) throws FormatException, IOException, ServerError { reader.setSeries(series); int maxPlaneSize = sizes.getMaxPlaneWidth() * sizes.getMaxPlaneHeight(); if (((long) reader.getSizeX() * (long) reader.getSizeY()) > maxPlaneSize) { return null; } int bytesPerPixel = getBytesPerPixel(reader.getPixelType()); MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Required SHA-1 message digest algorithm unavailable."); } int planeNo = 1; for (int t = 0; t < size.sizeT; t++) { for (int c = 0; c < size.sizeC; c++) { for (int z = 0; z < size.sizeZ; z++) { parseDataByPlane(size, z, c, t, bytesPerPixel, fileName, md); notifyObservers(new ImportEvent.IMPORT_STEP(planeNo, series, reader.getSeriesCount())); planeNo++; } } } return md; }