@Test public void loadLoaderFactoryMetaData() throws Exception { IMetadata meta = LoaderFactory.getMetadata(testFileFolder + file, null); assertEquals(meta.getMetaValue("MagicNumber"), "P5"); assertEquals(meta.getMetaValue("Width"), "1024"); assertEquals(meta.getMetaValue("Height"), "1024"); assertEquals(meta.getMetaValue("Maxval"), "65535"); }
@Test public void testMerlinDataLoaderU32() throws Exception { final String path = testFileFolder + "I13-20150210-101459-1.mib"; IDataHolder dataHolder = LoaderFactory.getData(path, null); IDataset data = dataHolder.getDataset(0); int[] shape = data.getShape(); assertEquals(515, shape[0], 0.0); assertEquals(515, shape[1], 0.0); }
@Test public void testMerlinDataLoader() throws Exception { final String path = testFileFolder + "default1.mib"; IDataHolder dataHolder = LoaderFactory.getData(path, null); IDataset data = dataHolder.getDataset(0); int[] shape = data.getShape(); assertEquals(512, shape[0], 0.0); assertEquals(512, shape[1], 0.0); assertEquals(4095, data.max().intValue(), 0.0); }
@Test public void loadLoaderFactory() throws Exception { IDataHolder dataHolder = LoaderFactory.getData(testFileFolder + file, null); IDataset data = dataHolder.getDataset("Portable Grey Map"); // Check the first data point assertEquals(data.getDouble(0, 0), 0.0, 0.0); // Check the middle data point assertEquals(data.getDouble(512, 511), 15104.0, 0.0); // Check the last data point assertEquals(data.getDouble(1023, 1023), 0.0, 0.0); }
@Test public void lazyLoadLoaderFactory() throws Exception { IDataHolder dataHolder = LoaderFactory.getData(testFileFolder + file, true, true, true, null); ILazyDataset lazy = dataHolder.getLazyDataset("Portable Grey Map"); assertArrayEquals(new int[] {1024, 1024}, lazy.getShape()); IDataset data = lazy.getSlice(); // Check the first data point assertEquals(data.getDouble(0, 0), 0.0, 0.0); // Check the middle data point assertEquals(data.getDouble(512, 511), 15104.0, 0.0); // Check the last data point assertEquals(data.getDouble(1023, 1023), 0.0, 0.0); }
/** * Method that determines the right Loader and the right Data Files for the "write output data" * functionality supported by the EasyTest Framework. * * @param testData an instance of {@link DataLoader} that helps in identifying the right {@link * Loader} to write the data back to the file. * @param testClass the class that the {@link TestInfo} object will be associated with * @return {@link TestInfo} an instance of {@link TestInfo} containing information about the * currently executing test. */ public static TestInfo determineLoader(DataLoader testData, TestClass testClass) { TestInfo result = new TestInfo(testClass); // String[] dataFiles = testData.filePaths(); String[] dataFiles = determineFilePaths(testData); LoaderType loaderType = determineLoaderType(testData, dataFiles); // Loader Loader dataLoader = null; if (LoaderType.CUSTOM.equals(loaderType) || dataFiles.length == 0) { dataLoader = getCustomLoaderInstance(testData); } else { // user has specified data files and the data fileType is also // not custom. if (loaderType != null) { dataLoader = LoaderFactory.getLoader(loaderType); } } result.setDataLoader(dataLoader); result.setFilePaths(dataFiles); result.setWriteData(testData.writeData()); return result; }
@Test public void testLoaderFactory() throws Exception { IDataHolder dh = LoaderFactory.getData(testfile1, null); if (dh == null || dh.getNames().length < 1) throw new Exception(); }
@Before public void setup() { // clear state left over from any previous tests LoaderFactory.clear(); }