Commit 521e6431 authored by gonciarz's avatar gonciarz

old test removed completely

parent 77e2f169
......@@ -24,16 +24,3 @@ then
exit 1
fi
cd $FIJI_MOSAIC_PLUGIN_PATH/../..
# During build log4j.properties file is copied to bin directory.
./ImageJ-linux64 -Dlog4j.configuration=file:"$MOSAIC_PLUGIN_PATH/bin/log4j.properties" -- --system -batch test.ijm "username=jenkins"
# check if tmp/test has succeful file
if [ ! -e "/tmp/test/succeful" ]
then
echo "Error in the tests"
exit 1
fi
package mosaic.core.test;
/**
* Class that store a plugin test
*
* @author Pietro Incardona
*/
public class ImgTest {
public String base;
public String img[];
public String options;
public int setup_return;
public String setup_files[];
public String result_imgs[];
public String result_imgs_rel[];
public String csv_results[];
public String csv_results_rel[];
}
This diff is collapsed.
package mosaic.core.test;
import ij.plugin.filter.PlugInFilter;
/**
*
* It is just the ImageJ PlugInFilter with an extended functionality
*
* @author Pietro Incardona
*
*/
public interface PlugInFilterExt extends PlugInFilter
{
/**
*
* This function close all the images processed and the visualized result produced by the plugins.
* It is a function useful in case of unit tests. When the test is terminated all the images are
* closed
*
*/
void closeAll();
/**
*
* Set if that the plugin is on test
*
* @param test test mode
*
*/
void setIsOnTest(boolean test);
/**
*
* Check if the plugin is running under Junit
*
*/
boolean isOnTest();
}
\ No newline at end of file
......@@ -515,68 +515,6 @@ public class MosaicUtils {
return padded_is;
}
/**
* Does the same as padImageStack3D but does not create a new image. It
* recreates the edge of the cube (frame).
*
* @see padImageStack3D, cropImageStack3D
* @param aIS
*/
public static void repadImageStack3D(ImageStack aIS, int padSize) {
if (aIS.getSize() > 1) { // only in the 3D case
for (int s = 1; s <= padSize; s++) {
aIS.deleteSlice(1);
aIS.deleteLastSlice();
}
}
for (int s = 1; s <= aIS.getSize(); s++) {
final float[] pixels = (float[]) aIS.getProcessor(s).getPixels();
final int width = aIS.getWidth();
final int height = aIS.getHeight();
for (int i = 0; i < pixels.length; i++) {
final int xcoord = i % width;
final int ycoord = i / width;
if (xcoord < padSize && ycoord < padSize) {
pixels[i] = pixels[padSize * width + padSize];
continue;
}
if (xcoord < padSize && ycoord >= height - padSize) {
pixels[i] = pixels[(height - padSize - 1) * width + padSize];
continue;
}
if (xcoord >= width - padSize && ycoord < padSize) {
pixels[i] = pixels[(padSize + 1) * width - padSize - 1];
continue;
}
if (xcoord >= width - padSize && ycoord >= height - padSize) {
pixels[i] = pixels[(height - padSize) * width - padSize - 1];
continue;
}
if (xcoord < padSize) {
pixels[i] = pixels[ycoord * width + padSize];
continue;
}
if (xcoord >= width - padSize) {
pixels[i] = pixels[(ycoord + 1) * width - padSize - 1];
continue;
}
if (ycoord < padSize) {
pixels[i] = pixels[padSize * width + xcoord];
continue;
}
if (ycoord >= height - padSize) {
pixels[i] = pixels[(height - padSize - 1) * width + xcoord];
}
}
}
if (aIS.getSize() > 1) {
for (int s = 1; s <= padSize; s++) { // only in 3D case
aIS.addSlice("", aIS.getProcessor(1).duplicate(), 1);
aIS.addSlice("", aIS.getProcessor(aIS.getSize()).duplicate());
}
}
}
public static ImageStack GetSubStackInFloat(ImageStack is, int startPos, int endPos) {
final ImageStack res = new ImageStack(is.getWidth(), is.getHeight());
if (startPos > endPos || startPos < 0 || endPos < 0) {
......@@ -1160,20 +1098,6 @@ public class MosaicUtils {
return true;
}
/**
* This function check if the Fiji respect all the requirement to run the
* MosaicToolSuite
*
* @return true if respect the requirement
*/
static public boolean checkRequirement() {
if (IJ.versionLessThan("1.48")) {
IJ.error("Your Fiji or ImageJ version is too old to run the MosaicToolSuite please update it");
return false;
}
return true;
}
/**
* Calculate the sum of all pixels
*
......
......@@ -2,7 +2,7 @@ package mosaic.core.utils;
import ij.ImagePlus;
import mosaic.core.test.PlugInFilterExt;
import ij.plugin.filter.PlugInFilter;
/**
......@@ -12,7 +12,7 @@ import mosaic.core.test.PlugInFilterExt;
* @author Pietro Incardona
*/
public interface Segmentation extends PlugInFilterExt {
public interface Segmentation extends PlugInFilter {
/**
* Get Mask images name output
......
......@@ -23,11 +23,12 @@ import net.imglib2.type.numeric.real.DoubleType;
public class BregmanGLM_Batch implements Segmentation {
private static final Logger logger = Logger.getLogger(BregmanGLM_Batch.class);
private ImagePlus OriginalImagePlus = null;
private String savedSettings;
private GenericGUI window;
private boolean gui_use_cluster = false;
public static boolean test_mode = false;
private enum outputF {
MASK(2), OBJECT(0);
......@@ -44,10 +45,6 @@ public class BregmanGLM_Batch implements Segmentation {
@Override
public int setup(String arg0, ImagePlus active_img) {
if (MosaicUtils.checkRequirement() == false) {
return DONE;
}
// init basic structure
Analysis.init();
......@@ -83,8 +80,6 @@ public class BregmanGLM_Batch implements Segmentation {
// Initialize CSV format
CSVOutput.initCSV(Analysis.p.oc_s);
this.OriginalImagePlus = active_img;
// Check the argument
final boolean batch = GraphicsEnvironment.isHeadless();
......@@ -153,31 +148,6 @@ public class BregmanGLM_Batch implements Segmentation {
gui_use_cluster = bl;
}
// =================== Implementation of PlugInFilterExt interface
public static boolean test_mode;
/**
* Close all the file
*/
@Override
public void closeAll() {
if (OriginalImagePlus != null) {
OriginalImagePlus.close();
}
window.closeAll();
}
@Override
public void setIsOnTest(boolean test) {
test_mode = test;
}
@Override
public boolean isOnTest() {
return test_mode;
}
// =================== Implementation of Segmentation interface
/**
......
......@@ -248,8 +248,8 @@ public class BregmanGLM_BatchTest extends CommonBase {
// Create tested plugIn
Interpreter.batchMode = true;
final BregmanGLM_Batch plugin = new BregmanGLM_Batch();
BregmanGLM_Batch.test_mode = true;
plugin.bypass_GUI();
plugin.setIsOnTest(true);
plugin.setUseCluster(true);
copyTestResources("spb_settings.dat", SystemOperations.getTestDataPath() + tcDirName, "/tmp");
copyTestResources("droplet_1.tif", SystemOperations.getTestDataPath() + tcDirName, tmpPath);
......
package mosaic.core.test;
package mosaic.plugins;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import org.apache.log4j.Logger;
import org.scijava.util.FileUtils;
import org.junit.Test;
import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
import mosaic.core.utils.ShellCommand;
import mosaic.plugins.MergeJobs;
import mosaic.plugins.utils.TimeMeasurement;
import mosaic.test.framework.CommonBase;
import mosaic.test.framework.SystemOperations;
/**
* This is the set of test
*
* @author Pietro Incardona
*/
public class Jtest implements PlugInFilter {
private static final Logger logger = Logger.getLogger(Jtest.class);
/**
* Run JTest filter
*/
@Override
public void run(ImageProcessor arg0) {}
@Override
public int setup(String arg0, ImagePlus arg1) {
// Get the User home directory
final String test = SystemOperations.getTestTmpPath();
final File s_file = new File(test + File.separator + "succeful");
FileUtils.deleteRecursively(s_file);
final TimeMeasurement tm = new TimeMeasurement();
// -----------------------------------------------------------------------------------
logger.info("========================== TestSuite: core.cluster.Jtest ===================================");
mergetest();
tm.logLapTimeSec("========================== core.cluster.Jtest");
// -----------------------------------------------------------------------------------
tm.logTimeSec("All tests SUCCESSFULLY completed");
// Create a file that notify all test has been completed suceffuly
try {
final PrintWriter succeful = new PrintWriter(test + File.separator + "succeful");
succeful.write(1);
succeful.close();
}
catch (final FileNotFoundException e) {
e.printStackTrace();
}
return DONE;
}
public class MergeJobsTest extends CommonBase {
private static final Logger logger = Logger.getLogger(MergeJobsTest.class);
/**
* Recursively take all the tree structure of a directory
*
* @param set
* @param dir
*/
private static void populate(HashSet<File> set, File dir) {
set.add(dir);
logger.info("A: " + dir);
if (dir.isDirectory()) {
logger.info("D: " + dir);
for (final File t : dir.listFiles()) {
populate(set, t);
}
}
}
/**
* Compare if two directories are the same as dir and file structure
*
* @param a1 dir1
* @param a2 dir3
* @return true if they match, false otherwise
*/
private static boolean compare(File a1, File a2) {
final HashSet<File> seta1 = new HashSet<File>();
populate(seta1, a1);
final HashSet<File> seta2 = new HashSet<File>();
populate(seta2, a2);
// Check if the two HashSet match
return seta1.containsAll(seta2);
}
private void mergetest() {
@Test
public void testMerge() {
/**
* TODO: This test must be rewritten. It is just moved here from "old test system". It does not do what it is intend.
*/
final MergeJobs mj = new MergeJobs();
final String dir = MosaicTest.getTestDir();
final String dir = SystemOperations.getTestDataPath();
final String dirOutTest = SystemOperations.getCleanTestTmpPath();
final String dir_test = dirOutTest + File.separator + "merge_jobs" + File.separator + "Test";
final String dir_sample = dir + File.separator + "merge_jobs" + File.separator + "Sample";
......@@ -143,4 +64,38 @@ public class Jtest implements PlugInFilter {
throw new RuntimeException("Error: Merging jobs differs");
}
}
/**
* Recursively take all the tree structure of a directory
*
* @param set
* @param dir
*/
private static void populate(HashSet<File> set, File dir) {
set.add(dir);
logger.info("A: " + dir);
if (dir.isDirectory()) {
logger.info("D: " + dir);
for (final File t : dir.listFiles()) {
populate(set, t);
}
}
}
/**
* Compare if two directories are the same as dir and file structure
*
* @param a1 dir1
* @param a2 dir3
* @return true if they match, false otherwise
*/
private static boolean compare(File a1, File a2) {
final HashSet<File> seta1 = new HashSet<File>();
populate(seta1, a1);
final HashSet<File> seta2 = new HashSet<File>();
populate(seta2, a2);
// Check if the two HashSet match
return seta1.containsAll(seta2);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment