From 8ab50a05eda5fe75d0fd92ffebb4198a681e065f Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Tue, 4 Apr 2017 16:23:26 -0400 Subject: [PATCH 1/2] Get the tests working in intellij with junit --- .idea/compiler.xml | 22 + .idea/copyright/profiles_settings.xml | 3 + .idea/libraries/lib.xml | 11 + .idea/misc.xml | 73 ++ .idea/modules.xml | 8 + .idea/uiDesigner.xml | 124 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 1154 +++++++++++++++++ karyotyper.iml | 33 + src/characterization/ChromosomeBand.java | 12 +- src/idiogram/IdiogramMap.java | 14 +- test/basic_objects/AroundPixelTest.java | 19 +- test/basic_objects/IdiogramMapTest.java | 29 +- test/basic_objects/PointListTest.java | 17 +- test/basic_objects/RadialVectorsTest.java | 35 +- test/basic_objects/VectorTest.java | 56 +- test/basic_objects/VertexTest.java | 38 +- .../blackbox}/RegressionLibTest.java | 20 +- .../characterize/CharacterizerTest.java | 20 +- test/chromosome/GeneticSlideImageTest.java | 16 +- test/color/PixelColorTest.java | 9 +- test/extraction/ClusterSplitterTest.java | 31 +- test/extraction/ExtractorTest.java | 27 +- test/extraction/MirrorSplitTest.java | 40 +- test/medial_axis/MedialAxisGraphTest.java | 42 +- test/medial_axis/MedialAxisTest.java | 12 - test/medial_axis/SkeletonListTest.java | 23 +- test/symmetry/DetectSymmetryTest.java | 31 +- 28 files changed, 1650 insertions(+), 275 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/libraries/lib.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 karyotyper.iml rename {src/testing => test/blackbox}/RegressionLibTest.java (77%) rename {src => test}/characterize/CharacterizerTest.java (98%) delete mode 100644 test/medial_axis/MedialAxisTest.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 0000000..e71c7de --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..acb45ed --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4bdd032 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..ff60b59 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,1154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1491333853242 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/test/characterize/CharacterizerTest.java + 199 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/karyotyper.iml b/karyotyper.iml new file mode 100644 index 0000000..076a646 --- /dev/null +++ b/karyotyper.iml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/characterization/ChromosomeBand.java b/src/characterization/ChromosomeBand.java index c5ef831..ce5ab4d 100644 --- a/src/characterization/ChromosomeBand.java +++ b/src/characterization/ChromosomeBand.java @@ -1,15 +1,15 @@ package characterization; public class ChromosomeBand { - public static enum Type { + public enum BandType { BLACK, WHITE, GREY, CENTROMERE - }; + } - private final Type type; + private final BandType type; private final int length; - public ChromosomeBand(Type type, int length) { - if (type == this.type.CENTROMERE && length == 0) { + public ChromosomeBand(BandType type, int length) { + if (type == BandType.CENTROMERE && length == 0) { throw new IllegalArgumentException("Length of a centromere band cannot be non-zero."); } @@ -17,7 +17,7 @@ public ChromosomeBand(Type type, int length) { this.length = length; } - public Type type() { + public BandType type() { return type; } diff --git a/src/idiogram/IdiogramMap.java b/src/idiogram/IdiogramMap.java index a9c9866..0a24115 100644 --- a/src/idiogram/IdiogramMap.java +++ b/src/idiogram/IdiogramMap.java @@ -8,7 +8,7 @@ import java.util.regex.Pattern; import characterization.ChromosomeBand; -import characterization.ChromosomeBand.Type; +import characterization.ChromosomeBand.BandType; /** * Wrapper for a Java HashMap that maps an idiogram to a chromosome number. @@ -60,7 +60,7 @@ private void idiogramSheetParser(File file) { String token = null; int chromosomeNumber = 0; - ChromosomeBand.Type bandType; + ChromosomeBand.BandType bandType; int bandLength = 0; ChromosomeBand band = null; int resolution = 0; @@ -85,22 +85,22 @@ private void idiogramSheetParser(File file) { // End debug if (token.toLowerCase().equals("white")) { - bandType = Type.WHITE; + bandType = BandType.WHITE; bandLength = lineReader.nextInt(); band = new ChromosomeBand(bandType, bandLength); newIdiogram.add(band); } else if (token.toLowerCase().equals("black")) { - bandType = Type.BLACK; + bandType = BandType.BLACK; bandLength = lineReader.nextInt(); band = new ChromosomeBand(bandType, bandLength); newIdiogram.add(band); } else if (token.toLowerCase().equals("grey")) { - bandType = Type.GREY; + bandType = BandType.GREY; bandLength = lineReader.nextInt(); band = new ChromosomeBand(bandType, bandLength); newIdiogram.add(band); } else if (token.toLowerCase().equals("centromere")) { - bandType = Type.CENTROMERE; + bandType = BandType.CENTROMERE; bandLength = lineReader.nextInt(); band = new ChromosomeBand(bandType, bandLength); newIdiogram.add(band); @@ -123,7 +123,7 @@ private void idiogramSheetParser(File file) { * Gets the chromosome number that the requested idiogram maps to. If the idiogram requested is * not in the list of keys then null is returned. * - * @param i + * @param index * Requested idiogram * @return Chromosome number mapped to or null if the requested idiogram doesn't exist. */ diff --git a/test/basic_objects/AroundPixelTest.java b/test/basic_objects/AroundPixelTest.java index 1e3fe48..1925697 100644 --- a/test/basic_objects/AroundPixelTest.java +++ b/test/basic_objects/AroundPixelTest.java @@ -1,16 +1,15 @@ package basic_objects; import java.util.LinkedList; +import org.junit.Test; -import basic_objects.AroundPixel; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -public class AroundPixelTest extends TestCase { - protected void setUp() throws Exception { - super.setUp(); - - } +public class AroundPixelTest { + @Test public void testGetPositionsBetweenNeg() { LinkedList posList = AroundPixel.getPositionsBetweenNeg(0, 4); assertEquals(posList.size(), 3); @@ -24,7 +23,7 @@ public void testGetPositionsBetweenNeg() { assertFalse(posList.contains(0)); } - + @Test public void testGetPositionsBetweenPlus() { LinkedList posList = AroundPixel.getPositionsBetweenPlus(0, 4); assertEquals(posList.size(), 3); @@ -38,7 +37,7 @@ public void testGetPositionsBetweenPlus() { assertFalse(posList.contains(0)); } - + @Test public void testGetOppisitPos() { assertEquals(4, AroundPixel.getOppisitePos(0)); assertEquals(5, AroundPixel.getOppisitePos(1)); @@ -50,7 +49,7 @@ public void testGetOppisitPos() { assertEquals(3, AroundPixel.getOppisitePos(7)); } - + @Test public void testHandleLoop() { assertEquals(7, AroundPixel.handleLoop(-1)); assertEquals(6, AroundPixel.handleLoop(-2)); diff --git a/test/basic_objects/IdiogramMapTest.java b/test/basic_objects/IdiogramMapTest.java index 6abd565..67dc0e0 100644 --- a/test/basic_objects/IdiogramMapTest.java +++ b/test/basic_objects/IdiogramMapTest.java @@ -4,44 +4,33 @@ package basic_objects; import java.io.File; - -import characterization.ChromosomeBand; import idiogram.IdiogramMap; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.fail; /** * @author Robert * */ -public class IdiogramMapTest extends TestCase { +public class IdiogramMapTest { private IdiogramMap map; - - /** - * @param name - */ - public IdiogramMapTest(String name) { - super(name); - map = new IdiogramMap(new File(".\\ChromosomeIdiogramSheet.csv")); - } /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - } + @Before + public void setUp() throws Exception { + map = new IdiogramMap(new File(".\\ChromosomeIdiogramSheet.csv")); - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); } /** * Test method for {@link idiogram.IdiogramMap#get(Idiogram)}. */ + @Test public void testGet() { // Chromosome chromosome = new Chromosome(10); // chromosome.add(new ChromosomeBand(ChromosomeBand.Type.WHITE, 21)); diff --git a/test/basic_objects/PointListTest.java b/test/basic_objects/PointListTest.java index ea88e2a..27f284b 100644 --- a/test/basic_objects/PointListTest.java +++ b/test/basic_objects/PointListTest.java @@ -1,17 +1,14 @@ package basic_objects; import java.awt.Point; +import org.junit.Test; -import basic_objects.PointList; - -import junit.framework.TestCase; - -public class PointListTest extends TestCase { - - protected void setUp() throws Exception { - super.setUp(); - } +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +public class PointListTest{ + @Test public void testSetList() { PointList tempList = new PointList(new Point(10, 2), 2); tempList.addPoint(new Point(3, 2), 2); @@ -27,7 +24,7 @@ public void testSetList() { assertFalse(pointList.getList().contains(new Point(6, 10))); } - + @Test public void testAddPoint() { PointList tempList = new PointList(new Point(10, 2), 2); assertTrue(tempList.addPoint(new Point(3, 2), 2)); diff --git a/test/basic_objects/RadialVectorsTest.java b/test/basic_objects/RadialVectorsTest.java index c68126b..8c1b4d1 100644 --- a/test/basic_objects/RadialVectorsTest.java +++ b/test/basic_objects/RadialVectorsTest.java @@ -6,7 +6,9 @@ import java.awt.Point; import java.util.ArrayList; -import org.apache.commons.math3.analysis.function.Ceil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import junit.framework.TestCase; @@ -21,31 +23,15 @@ public class RadialVectorsTest extends TestCase { private final int NUM_VECTORS = 8; private final double DISTANCE = 10; - /** - * @param name - */ - public RadialVectorsTest(String name) { - super(name); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { radialVectors = new RadialVectors(CENTER_POINT, NUM_VECTORS, DISTANCE); - super.setUp(); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); } /** * Test method for {@link basic_objects.RadialVectors#getVectors()}. */ + @Test public void testGetVectors() { ArrayList vectorList = radialVectors.getVectors(); @@ -81,6 +67,7 @@ public void testGetVectors() { /** * Test method for {@link basic_objects.RadialVectors#getTheta()}. */ + @Test public void testGetTheta() { double expectedTheta = 2 * Math.PI / NUM_VECTORS; assertEquals(expectedTheta, radialVectors.getTheta()); @@ -89,6 +76,7 @@ public void testGetTheta() { /** * Test method for {@link basic_objects.RadialVectors#getCenterPoint()}. */ + @Test public void testGetCenterPoint() { assertEquals(CENTER_POINT, radialVectors.getCenterPoint()); } @@ -96,6 +84,7 @@ public void testGetCenterPoint() { /** * Test method for {@link basic_objects.RadialVectors#getVectorsAsPointsOnImage()}. */ + @Test public void testGetVectorsAsPointsOnImage() { ArrayList pointList = radialVectors.getVectorsAsPointsOnImage(); @@ -114,6 +103,7 @@ public void testGetVectorsAsPointsOnImage() { /** * Test method for {@link basic_objects.RadialVectors#getPointsInRange(java.awt.Point, double, int)}. */ + @Test public void testGetRange() { ArrayList range = radialVectors.getPointsInRange(new Point(3,4), Math.PI/2, 5); @@ -140,6 +130,7 @@ public void testGetRange() { /** * Test method for {@link basic_objects.RadialVectors#getOpposite(java.awt.Point)}. */ + @Test public void testGetOpposite() { Point oppPoint = radialVectors.getOpposite(new Point(CENTER_POINT.x + 1, CENTER_POINT.y)); @@ -154,6 +145,7 @@ public void testGetOpposite() { /** * Test method for {@link basic_objects.RadialVectors#getPointAtIndex(int)}. */ + @Test public void testGetPointAtIndex() { Point pointAtIndex = radialVectors.getPointAtIndex(2); Point testPoint = new Point(CENTER_POINT.x, CENTER_POINT.y + 10); @@ -164,11 +156,12 @@ public void testGetPointAtIndex() { /** * Test method for {@link basic_objects.RadialVectors#multiplyRadius(double)}. */ + @Test public void testMultiplyRadius() { radialVectors.multiplyRadius(2); assertEquals(20.0, radialVectors.getDistance()); } - + @Test public void testToString() { radialVectors.normalize(); System.out.println(radialVectors.toString()); diff --git a/test/basic_objects/VectorTest.java b/test/basic_objects/VectorTest.java index 920a3b7..1722a8b 100644 --- a/test/basic_objects/VectorTest.java +++ b/test/basic_objects/VectorTest.java @@ -3,58 +3,46 @@ */ package basic_objects; +import org.junit.Before; +import org.junit.Test; import java.awt.Point; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; /** * @author Robert * */ -public class VectorTest extends TestCase { +public class VectorTest{ private Vector vector; - - /** - * @param name - */ - public VectorTest(String name) { - super(name); - } - /* * (non-Javadoc) * * @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { + @Before + public void setUp()throws Exception { vector = new Vector(1, 0); - super.setUp(); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); } /** * Test method for {@link basic_objects.Vector#Vector(double, double)}. */ + @Test public void testVector() { double xComp = vector.x; double yComp = vector.y; - assertEquals(1.0, xComp); - assertEquals(0.0, yComp); + assertEquals(1.0, xComp,.001); + assertEquals(0.0, yComp,.001); } /** * Test method for {@link basic_objects.Vector#rotateVector(double)}. */ + @Test public void testRotateVectorDouble() { vector.rotateVector(Math.PI / 4); double testX = Math.sqrt(2) / 2; @@ -72,6 +60,7 @@ public void testRotateVectorDouble() { /** * Test method for {@link basic_objects.Vector#rotateVector(basic_objects.Vector, double)}. */ + @Test public void testRotateVectorVectorDouble() { Vector v1 = Vector.rotateVector(vector, Math.PI / 4); long actualX = Math.round(v1.x * 100000); @@ -86,19 +75,21 @@ public void testRotateVectorVectorDouble() { /** * Test method for {@link basic_objects.Vector#normalize(basic_objects.Vector)}. */ + @Test public void testNormalize() { Vector testVector = new Vector(3, 3); testVector = Vector.normalize(testVector); double newX = Math.sqrt(2) / 2; double newY = Math.sqrt(2) / 2; - assertEquals(testVector.x, newX); - assertEquals(testVector.y, newY); + assertEquals(testVector.x, newX,.001); + assertEquals(testVector.y, newY,.001); } /** * Test method for {@link basic_objects.Vector#add(basic_objects.Vector, basic_objects.Vector)}. */ + @Test public void testAdd() { Vector v1 = new Vector(2, 5); Vector v2 = new Vector(-4, 9); @@ -106,9 +97,10 @@ public void testAdd() { double newX = 2 - 4; double newY = 5 + 9; - assertEquals(v1.x, newX); - assertEquals(v1.y, newY); + assertEquals(v1.x, newX,.001); + assertEquals(v1.y, newY,.001); } + @Test public void testAngleBetween(){ Vector v1 = new Vector(3, 0); Vector v2 = new Vector(0, 4); @@ -143,26 +135,29 @@ public void testAngleBetween(){ /** * Test method for {@link basic_objects.Vector#getVectorBetweenTwoPoints(Point, Point)} */ + @Test public void testMagnitude() { Vector v1 = new Vector(1,0); - assertEquals(1.0, Vector.magnitude(v1)); + assertEquals(1.0, Vector.magnitude(v1),.001); } /** * Test method for {@link basic_objects.Vector#dotProduct(Vector, Vector) */ + @Test public void testDotProduct() { Vector v1 = new Vector(1,2); Vector v2 = new Vector(3,2); double testProduct = 7; double actualProduct = Vector.dotProduct(v1, v2); - assertEquals(testProduct, actualProduct); + assertEquals(testProduct, actualProduct,.001); } /** * Test method for * {@link basic_objects.Vector#getVectorBetweenTwoPoints(java.awt.Point, java.awt.Point)}. */ + @Test public void testGetVectorBetweenTwoPoints() { Point p1 = new Point(1, 2); Point p2 = new Point(3, 4); @@ -175,6 +170,7 @@ public void testGetVectorBetweenTwoPoints() { /** * Test method for {@link basic_objects.Vector#getDirectionalAngle(Vector, Vector)}. */ + @Test public void testGetAngle() { Vector v1 = new Vector(2, 1); double testAngle = Math.PI / 4; @@ -190,7 +186,7 @@ public void testGetAngle() { testAngle = 5 * Math.PI / 4; Vector v3 = Vector.rotateVector(v1, testAngle); actualAngle = Vector.getDirectionalAngle(v1, v3); - assertEquals(testAngle, actualAngle); + assertEquals(testAngle, actualAngle,.001); } diff --git a/test/basic_objects/VertexTest.java b/test/basic_objects/VertexTest.java index 9e3732c..5d0acd4 100644 --- a/test/basic_objects/VertexTest.java +++ b/test/basic_objects/VertexTest.java @@ -5,46 +5,28 @@ import java.awt.Point; import java.util.LinkedList; - import medial_axis.DistanceMap; import medial_axis.MedialAxisGraph; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.*; /** * @author Robert * */ -public class VertexTest extends TestCase { +public class VertexTest{ private Vertex vertex; /** Points ordered in breadth-first ordering from vertex */ private LinkedList pointList; - - /** - * @param name - */ - public VertexTest(String name) { - super(name); - - } /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - buildAxisGraph(); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - private void buildAxisGraph() { + @Before + public void setUp()throws Exception { buildPointList(); MedialAxisGraph graph = new MedialAxisGraph(); graph.buildGraph(pointList, new DistanceMap(100, 100)); @@ -70,6 +52,7 @@ private void buildPointList() { /** * Test method for {@link basic_objects.Vertex#calculateTangentLine(double, double)}. */ + @Test public void testCalculateTangentLine() { double[] tangentLine = null; try { @@ -91,6 +74,7 @@ public void testCalculateTangentLine() { /** * Test method for {@link basic_objects.Vertex#calculateOrthogonalLine(double, double)}. */ + @Test public void testCalculateOrthogonalLine() { double[] orthoLine = null; try { @@ -105,12 +89,13 @@ public void testCalculateOrthogonalLine() { assertEquals(vertex.getPoint(), new Point(20,20)); assertTrue(slope == -1 * (19.0 - 20.0)/(17.0 - 20.0) || slope == -1 * (23.0 - 20.0)/(22.0 - 20.0)); - assertEquals(intercept, 20.0 - 20.0*slope); + assertEquals(intercept, 20.0 - 20.0*slope,.001); } /** * Test method for {@link basic_objects.Vertex#hasBeenChecked()}. */ + @Test public void testHasBeenChecked() { assertFalse(vertex.hasBeenChecked()); } @@ -118,6 +103,7 @@ public void testHasBeenChecked() { /** * Test method for {@link basic_objects.Vertex#setHasBeenChecked(boolean)}. */ + @Test public void testSetHasBeenChecked() { vertex.setHasBeenChecked(true); assertTrue(vertex.hasBeenChecked()); @@ -126,6 +112,7 @@ public void testSetHasBeenChecked() { /** * Test method for {@link basic_objects.Vertex#tangentLine(int)}. */ + @Test public void testTangentLine() { double[] tangent = null; try { @@ -157,6 +144,7 @@ public void testTangentLine() { /** * Test method for {@link basic_objects.Vertex#orthogonalLine(int)}. */ + @Test public void testOrthogonalLine() { double[] orthogonal = null; try { diff --git a/src/testing/RegressionLibTest.java b/test/blackbox/RegressionLibTest.java similarity index 77% rename from src/testing/RegressionLibTest.java rename to test/blackbox/RegressionLibTest.java index b16aafb..566383a 100644 --- a/src/testing/RegressionLibTest.java +++ b/test/blackbox/RegressionLibTest.java @@ -1,17 +1,17 @@ -package testing; +package blackbox; import java.awt.Point; import java.util.ArrayList; import java.util.Arrays; - import medial_axis.RegressionLib; - import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction; +import org.junit.Test; -import junit.framework.TestCase; - -public class RegressionLibTest extends TestCase { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +public class RegressionLibTest { + @Test public void testApproxByPolynomial() { RegressionLib testObj = new RegressionLib(); double testVal = 0; @@ -19,14 +19,14 @@ public void testApproxByPolynomial() { ArrayList linearInput = new ArrayList(Arrays.asList(new Point(0, 0), new Point(1, 1))); DifferentiableUnivariateFunction linearFunc = testObj.approxByPolynomial(1, linearInput); - assertEquals(2.0, linearFunc.value(2)); - assertEquals(0.0, testObj.getFitError()); + assertEquals(2.0, linearFunc.value(2),.001); + assertEquals(0.0, testObj.getFitError(),.001); ArrayList cubicInput = new ArrayList(Arrays.asList(new Point(-2, -8), new Point(-1, -1), new Point(0, 0), new Point(2, 8))); DifferentiableUnivariateFunction cubicFunc = testObj.approxByPolynomial(3, cubicInput); - assertEquals(-27.0, cubicFunc.value(-3)); - assertEquals(0.0, testObj.getFitError()); + assertEquals(-27.0, cubicFunc.value(-3),.001); + assertEquals(0.0, testObj.getFitError(),.001); ArrayList dirtyInput = new ArrayList(Arrays.asList(new Point(-200, -10), new Point(-1, -100), new Point(0, 30), new Point(10, 9))); diff --git a/src/characterize/CharacterizerTest.java b/test/characterize/CharacterizerTest.java similarity index 98% rename from src/characterize/CharacterizerTest.java rename to test/characterize/CharacterizerTest.java index bef2191..e2fa7d5 100644 --- a/src/characterize/CharacterizerTest.java +++ b/test/characterize/CharacterizerTest.java @@ -1,7 +1,6 @@ package characterize; import java.awt.Color; -import java.awt.Graphics2D; import java.awt.Point; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; @@ -9,15 +8,16 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; - import javax.imageio.ImageIO; - -import junit.framework.TestCase; import color.PixelColor; +import org.junit.Test; -public class CharacterizerTest extends TestCase { - private final double fpThreshold = 0.0001; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +public class CharacterizerTest { + private final double fpThreshold = 0.0001; + @Test public void testPolygonalArea() { ArrayList rightTriangle = new ArrayList(Arrays.asList(new Point(0, 0), new Point(0, 2), new Point(2, 0))); @@ -76,7 +76,7 @@ public void testPolygonalArea() { pentagonExpected, pentagonArea), pentagonArea < pentagonExpected + fpThreshold && pentagonArea > pentagonExpected - fpThreshold); } - + @Test public void testBuildSlopeBufferVertical() { /******** Test a basic linear buffer vertically ************************************ */ @@ -134,7 +134,7 @@ public void testBuildSlopeBufferVertical() { } } } - + @Test public void testBuildSlopeBufferHorizontal() { /******** Test a basic linear buffer horizontally *********************************** */ @@ -194,7 +194,7 @@ public void testBuildSlopeBufferHorizontal() { } } } - + @Test public void testLinearizeChromosome() throws IOException { String currentPath = (new File(".")).getCanonicalPath(); String chromFile = currentPath + File.separator + "testData" + File.separator @@ -272,7 +272,7 @@ public void testLinearizeChromosome() throws IOException { } } } - + @Test public void testCalculateBandFunction() throws IOException { String currentPath = (new File(".")).getCanonicalPath(); String linearChromFile = currentPath + File.separator + "testData" + File.separator diff --git a/test/chromosome/GeneticSlideImageTest.java b/test/chromosome/GeneticSlideImageTest.java index bb701f8..f1a2832 100644 --- a/test/chromosome/GeneticSlideImageTest.java +++ b/test/chromosome/GeneticSlideImageTest.java @@ -1,29 +1,29 @@ package chromosome; +import org.junit.Before; +import org.junit.Test; import java.io.File; import java.io.IOException; -import chromosome.GeneticSlideImage; +import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; - -public class GeneticSlideImageTest extends TestCase { +public class GeneticSlideImageTest{ GeneticSlideImage slide; - @Override - protected void setUp() throws Exception { + @Before + public void setUp()throws Exception { String currentPath = (new File(".")).getCanonicalPath(); String gradientImageFile = currentPath + File.separator + "testData" + File.separator + "GradientSwatch.png"; slide = new GeneticSlideImage(gradientImageFile); } - + @Test public void testGetBackgroundThreshold() { // Note that this test checks "proper behavior", however, it is very far from a "real world" // test as we shouldn't see gradient images for slides. assertEquals(139, slide.getBackgroundThreshold()); } - + @Test public void testComputeHistogram() throws IOException { int[] expected = { 3, 3, 3, 1, 5, 5, 1, 7, 7, 1, 9, 9, 1, 11, 11, 3, 11, 13, 5, 11, 15, 7, 11, 17, 9, 11, 19, 11, 12, 20, 13, 14, 20, 15, 16, 20, 17, 18, 20, 19, 20, 21, 20, diff --git a/test/color/PixelColorTest.java b/test/color/PixelColorTest.java index fa75f3b..2cd385c 100644 --- a/test/color/PixelColorTest.java +++ b/test/color/PixelColorTest.java @@ -1,13 +1,14 @@ package color; import java.awt.Color; - import color.PixelColor; +import org.junit.Test; -import junit.framework.TestCase; - -public class PixelColorTest extends TestCase { +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +public class PixelColorTest { + @Test public void testIsAboveThreshold() { // Test for expected exception boolean exceptionFlag = false; diff --git a/test/extraction/ClusterSplitterTest.java b/test/extraction/ClusterSplitterTest.java index d465887..8ac5007 100644 --- a/test/extraction/ClusterSplitterTest.java +++ b/test/extraction/ClusterSplitterTest.java @@ -2,24 +2,21 @@ import java.awt.Point; import java.util.LinkedList; - import chromosome.ChromosomeCluster; -import extraction.ClusterSplitter; - import basic_objects.PointList; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -public class ClusterSplitterTest extends TestCase { +public class ClusterSplitterTest{ private ChromosomeCluster myCluster; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp()throws Exception { myCluster = new ChromosomeCluster(new Point(40, 40)); - initCluster(); - } - - public void initCluster() { // create vertical chromosome for (int i = 8; i < 16; i++) { for (int j = 0; j < 28; j++) { @@ -45,9 +42,9 @@ public void initCluster() { myCluster.setPixel(new Point(19, 28), true); myCluster.setPixel(new Point(18, 29), true); myCluster.setSize(40, 40); - } + @Test public void testGetCutPoints() { int directions[] = { 3, 3, 3, 3, 6, 6, 6, 6 }; PointList tempList = ClusterSplitter.getCutPoints(new Point(14, 14), 1, 4, directions); @@ -64,7 +61,7 @@ public void testGetCutPoints() { assertTrue(tempList.getList().contains(new Point(14, 20))); } - + @Test public void testGet4Lowest() { int directions[] = { 3, 2, 10, 3, 9, 6, 9, 6 }; LinkedList tempList = ClusterSplitter.get4Lowest(directions); @@ -75,7 +72,7 @@ public void testGet4Lowest() { assertEquals(tempList.get(3).intValue(), 5); } - + @Test public void testGetLowestOppisiteSide() { int directions[] = { 3, 2, 10, 3, 9, 6, 9, 6 }; assertEquals(ClusterSplitter.getLowestOppisiteSide(0, directions), 3); @@ -84,7 +81,7 @@ public void testGetLowestOppisiteSide() { assertEquals(ClusterSplitter.getLowestOppisiteSide(7, directions), 3); } - + @Test public void testIsCrossSectionPartOfCluster() { int directions[] = { 3, 2, 10, 3, 9, 6, 9, 6 }; assertTrue(ClusterSplitter.isCrossSectionPartOfCluster(0, 3, directions, 5)); @@ -94,7 +91,7 @@ public void testIsCrossSectionPartOfCluster() { assertFalse(ClusterSplitter.isCrossSectionPartOfCluster(0, 3, directions2, 5)); } - + @Test public void testGetQueenMoveLength() { assertEquals(7, 12 - ClusterSplitter.getQueenMoveLength(myCluster, new Point(8, 27), 6, 12)); assertEquals(0, 12 - ClusterSplitter.getQueenMoveLength(myCluster, new Point(8, 27), 1, 12)); @@ -118,7 +115,7 @@ public void testGetQueenMoveLength() { 12 - ClusterSplitter.getQueenMoveLength(myCluster, new Point(8, 29), 0, 12)); } - + @Test public void testCheckForSplit() { PointList tempList = ClusterSplitter.checkForSplit(myCluster, new Point(8, 29), 7); assertEquals(tempList.getList().size(), 2); diff --git a/test/extraction/ExtractorTest.java b/test/extraction/ExtractorTest.java index 60793e9..ec1ac6e 100644 --- a/test/extraction/ExtractorTest.java +++ b/test/extraction/ExtractorTest.java @@ -6,23 +6,19 @@ import java.awt.image.BufferedImage; import java.io.File; import java.util.LinkedList; - import javax.imageio.ImageIO; -import javax.imageio.ImageWriter; - import chromosome.ChromosomeCluster; import chromosome.GeneticSlideImage; +import basic_objects.SearchArea; +import org.junit.Test; -import extraction.Extractor; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import basic_objects.SearchArea; -import junit.framework.TestCase; +public class ExtractorTest{ -public class ExtractorTest extends TestCase { - protected void setUp() throws Exception { - super.setUp(); - } public SearchArea cutInHalf(SearchArea searchArea){ int middle=(int)Math.round(searchArea.getHeight()/2); for(int i=0;i horizantolLine; private LinkedList straightLine; private DistanceMap distanceMap; private DistanceMap distanceMapHorz; private MedialAxisGraph testGraph; private MirrorSplit mirror; - protected void setUp() throws Exception { - super.setUp(); + + @Before + public void setUp()throws Exception { generateVertical(); generateHorizantal(); testGraph=new MedialAxisGraph(); @@ -53,6 +56,7 @@ protected void setUp() throws Exception { horizantolLine.add(new Point(11, 7)); } + public void generateVertical(){ distanceMap = new DistanceMap(15, 15); for (int i = 0; i < distanceMap.getWidth(); i++) { @@ -78,6 +82,7 @@ public void generateHorizantal(){ } } + @Test public void testGetShortestDistance() { MedialAxis tempAxis = new MedialAxis(); @@ -95,7 +100,7 @@ public void testGetShortestDistance() { System.out.println(e); } - assertEquals(tempOrtho.getlength(), 8.0); + assertEquals(tempOrtho.getlength(), 8.0,.001); assertEquals(tempOrtho.getUpperPoint(), new Point(3, 5)); assertEquals(tempOrtho.getLowerPoint(), new Point(11, 5)); @@ -116,7 +121,7 @@ public void testGetShortestDistance() { System.out.println(e); } - assertEquals(tempOrtho.getlength(), 8.0); + assertEquals(tempOrtho.getlength(), 8.0,.001); assertEquals(tempOrtho.getUpperPoint(), new Point(5, 3)); assertEquals(tempOrtho.getLowerPoint(), new Point(5, 11)); @@ -134,11 +139,12 @@ public void testGetShortestDistance() { assertEquals(testGraph.getDistanceMap().getDistanceFromEdge(new Point(5, 3)), 0); tempOrtho = mirror.getShortestDistance(bounds, new Point(-1, -1), new Point(5, 5), testGraph.getChromoWidth(), distanceMapHorz); - assertEquals(tempOrtho.getlength(), 8.0); + assertEquals(tempOrtho.getlength(), 8.0,.001); assertEquals(tempOrtho.getUpperPoint(), new Point(5, 3)); assertEquals(tempOrtho.getLowerPoint(), new Point(5, 11)); } + @Test public void testgetPathOrtho() { MedialAxis tempAxis = new MedialAxis(); @@ -157,7 +163,7 @@ public void testgetPathOrtho() { } assertTrue(tempOrtho.isTwoLines()); - assertEquals(tempOrtho.getlength(), 8.0); + assertEquals(tempOrtho.getlength(), 8.0,.001); assertEquals(tempOrtho.getUpperPoint(), new Point(3, 5)); assertEquals(tempOrtho.getLowerPoint(), new Point(11, 5)); @@ -280,7 +286,7 @@ public void testgetPathOrtho() { assertEquals(tempOrtho.getLowerPoint(), new Point(5, 5)); - } + } @Test public void testGetAllDistances() { MedialAxis tempAxis = new MedialAxis(); tempAxis.setDistanceMap(distanceMap); @@ -326,7 +332,7 @@ public void testGetAllDistances() { - } + } @Test public void testIsProjectionEnd(){ //test only one side oppisite previos touches distance map zero generateHorizantal(); @@ -338,7 +344,7 @@ public void testIsProjectionEnd(){ assertTrue(mirror.isProjectionEnd(bounds, distanceMapHorz,new Vertex(new Point(5,7),5),new Vector(1,1))); assertTrue(mirror.isProjectionEnd(bounds, distanceMapHorz,new Vertex(new Point(5,7),5),new Vector(-1,-1))); - } + } @Test public void testGetNextPoint(){ assertEquals(new Point(6,5), (mirror.getNextPoint(new Point(5,5), new Point(5,3), new Point(5,7), new Vector(1,0))).getPoint()); @@ -353,7 +359,7 @@ public void testGetNextPoint(){ assertEquals(new Point(6,8), (mirror.getNextPoint(new Point(5,8), new Point(5,4), new Point(5,10), new Vector(1,1))).getPoint()); assertEquals(new Point(7,9), (mirror.getNextPoint(new Point(5,8), new Point(5,4), new Point(5,10), new Vector(1,1))).getChildren().get(0).getPoint()); - } + } @Test public void testGetNextVector(){ OrthogonalLine tempOrtho = new OrthogonalLine(); Vertex currPoint; @@ -387,7 +393,7 @@ public void testGetNextVector(){ assertTrue(vect.x>-2&&vect.x<-1); - } + } @Test public void testRecenterForUpper(){ OrthogonalLine tempOrtho = new OrthogonalLine(); @@ -401,7 +407,7 @@ public void testRecenterForUpper(){ assertEquals(new Point(5,8),newPoint); - } + } @Test public void testRecenterForLower(){ OrthogonalLine tempOrtho = new OrthogonalLine(); Point newPoint; @@ -413,7 +419,7 @@ public void testRecenterForLower(){ newPoint=mirror.recenterForLower(tempOrtho, 8); assertEquals(new Point(9,1),newPoint); - } + } @Test public void testAngleBetween(){ OrthogonalLine tempOrtho = new OrthogonalLine(); diff --git a/test/medial_axis/MedialAxisGraphTest.java b/test/medial_axis/MedialAxisGraphTest.java index a06512c..99a6fac 100644 --- a/test/medial_axis/MedialAxisGraphTest.java +++ b/test/medial_axis/MedialAxisGraphTest.java @@ -3,13 +3,15 @@ import java.awt.Point; import java.util.ArrayList; import java.util.LinkedList; - -import junit.framework.TestCase; -import medial_axis.DistanceMap; -import medial_axis.MedialAxisGraph; import basic_objects.Vertex; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -public class MedialAxisGraphTest extends TestCase { +public class MedialAxisGraphTest{ private LinkedList straightLine; private LinkedList diagonalLine; private LinkedList curvedLine; @@ -19,8 +21,8 @@ public class MedialAxisGraphTest extends TestCase { private LinkedList chunk4TrimWith3brances; private DistanceMap distanceMap; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp()throws Exception { distanceMap = new DistanceMap(15, 15); for (int i = 0; i < distanceMap.getWidth(); i++) { for (int j = 0; j < distanceMap.getHeight(); j++) { @@ -167,7 +169,7 @@ protected void setUp() throws Exception { this.chunk4TrimWith3brances.add(new Point(11, 12)); } - + @Test public void testBuildGraph() { MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -189,7 +191,7 @@ public void testBuildGraph() { assertEquals(testGraph.getSegmentCount(), 3); } - + @Test public void testRemoveSegments() { LinkedList pointList; @@ -205,7 +207,7 @@ public void testRemoveSegments() { assertEquals(this.oneIntersection4branches.size() - 4, pointList.size()); } - + @Test public void testRemoveUnconnectedSegments() { LinkedList pointList; @@ -244,7 +246,7 @@ public void testRemoveUnconnectedSegments() { .getMySegement(), 0); } - + @Test public void testAddVertex() { LinkedList pointList; MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -257,7 +259,7 @@ public void testAddVertex() { assertEquals(testGraph.getSegmentCount(), 1); assertEquals(testGraph.getIntersectionCount(testGraph.getAxisGraph()), 1); - } + } @Test public void testRemoveVertex(){ LinkedList pointList; MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -273,7 +275,7 @@ public void testRemoveVertex(){ } - + @Test public void testGetSegment() { LinkedList pointList; @@ -323,7 +325,7 @@ public void testGetSegment() { assertEquals(orderedList.get(9).getPoint(), new Point(9,9)); assertEquals(orderedList.get(10).getPoint(), new Point(10,10)); } - + @Test public void testCheckTinyLoop() { MedialAxisGraph testGraph = new MedialAxisGraph(); testGraph.buildGraph(this.oneIntersection4branches, distanceMap); @@ -338,7 +340,7 @@ public void testCheckTinyLoop() { assertEquals(new Point(4, 4), tempVertex.getPoint()); } - + @Test public void testFillInSkeleton() { LinkedList pointList; MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -356,7 +358,7 @@ public void testFillInSkeleton() { System.out.print(testGraph.getAxisGraph().get(i).getPoint().toString() + "--"); } } - + @Test public void testGetBridgePoint() { MedialAxisGraph testGraph = new MedialAxisGraph(); testGraph.buildGraph(this.threeSegmentGraph, distanceMap); @@ -367,7 +369,7 @@ public void testGetBridgePoint() { assertEquals(new Point(10, 11), testGraph.getBridgePoint(6, new Point(9, 11))); assertEquals(new Point(10, 11), testGraph.getBridgePoint(6, new Point(9, 11))); } - + @Test public void testCheckForMostNewConnection() { MedialAxisGraph testGraph = new MedialAxisGraph(); testGraph.buildGraph(this.threeSegmentGraph, distanceMap); @@ -378,7 +380,7 @@ public void testCheckForMostNewConnection() { assertEquals(1, testGraph.checkForMostNewConnection(6, new Point(9, 11))); assertEquals(1, testGraph.checkForMostNewConnection(6, new Point(9, 11))); } - + @Test public void testSameSegment() { LinkedList pointList; MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -391,7 +393,7 @@ public void testSameSegment() { assertFalse(testGraph.sameSegment(new Point(9, 11), new Point(11, 11))); } - + @Test public void testTrimGraph(){ LinkedList pointList; MedialAxisGraph testGraph = new MedialAxisGraph(); @@ -409,7 +411,7 @@ public void testTrimGraph(){ assertFalse(pointList.contains(new Point(12, 11))); assertTrue(pointList.contains(new Point(10, 10))); - } + } @Test public void testGetOrderedMedialAxis(){ MedialAxisGraph testGraph = new MedialAxisGraph(); diff --git a/test/medial_axis/MedialAxisTest.java b/test/medial_axis/MedialAxisTest.java deleted file mode 100644 index 126def3..0000000 --- a/test/medial_axis/MedialAxisTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package medial_axis; - -import junit.framework.TestCase; - -public class MedialAxisTest extends TestCase { - - protected void setUp() throws Exception { - super.setUp(); - - } - -} diff --git a/test/medial_axis/SkeletonListTest.java b/test/medial_axis/SkeletonListTest.java index 7e9d24f..09fdcb5 100644 --- a/test/medial_axis/SkeletonListTest.java +++ b/test/medial_axis/SkeletonListTest.java @@ -2,19 +2,20 @@ import java.awt.Point; import java.util.LinkedList; - -import medial_axis.SkeletonList; - import basic_objects.PointList; import basic_objects.Vertex; +import org.junit.Before; +import org.junit.Test; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -public class SkeletonListTest extends TestCase { +public class SkeletonListTest{ private LinkedList vertList; - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp()throws Exception { vertList = new LinkedList(); vertList.add(new Vertex(new Point(3, 1), 4)); vertList.add(new Vertex(new Point(2, 1), 5)); @@ -24,7 +25,7 @@ protected void setUp() throws Exception { vertList.add(new Vertex(new Point(5, 1), 10)); } - + @Test public void testBuildFromVertexList() { SkeletonList skelList = new SkeletonList(); @@ -41,7 +42,7 @@ public void testBuildFromVertexList() { assertTrue(tempList2.getList().contains(new Point(5, 1))); assertEquals(tempList2.getList().size(), 1); } - + @Test public void testAdd() { SkeletonList skelList = new SkeletonList(); skelList.add(new Point(4, 4), 6); @@ -66,7 +67,7 @@ public void testAdd() { assertEquals(skelList.getListAtDistance(6).getList().size(), 3); } - + @Test public void testGetListAtDistance() { SkeletonList skelList = new SkeletonList(); skelList.add(new Point(4, 4), 6); @@ -82,7 +83,7 @@ public void testGetListAtDistance() { assertTrue(tempList.getList().contains(new Point(7, 7))); } - + @Test public void testGetOneList() { SkeletonList skelList = new SkeletonList(); skelList.add(new Point(4, 4), 6); diff --git a/test/symmetry/DetectSymmetryTest.java b/test/symmetry/DetectSymmetryTest.java index 62a4cb3..c2991cf 100644 --- a/test/symmetry/DetectSymmetryTest.java +++ b/test/symmetry/DetectSymmetryTest.java @@ -5,37 +5,32 @@ import java.util.LinkedList; +import org.junit.Before; +import org.junit.Test; import testing.TestShape; import medial_axis.MedialAxisGraph; import chromosome.ChromosomeCluster; -import chromosome.ChromosomeList; import chromosome.GeneticSlideImage; -import junit.framework.TestCase; + +import static org.junit.Assert.fail; /** * @author Robert * */ -public class DetectSymmetryTest extends TestCase { +public class DetectSymmetryTest{ private GeneticSlideImage image; private ChromosomeCluster cluster; private MedialAxisGraph axisGraph; - /** - * @param name - */ - public DetectSymmetryTest(String name) { - super(name); - } - /* * (non-Javadoc) * * @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setUp()throws Exception { String imagePath = ".\\testImages\\testImage1.png"; cluster = TestShape.getCluster(imagePath); image = TestShape.getGeneticSlideImage(); @@ -44,20 +39,12 @@ protected void setUp() throws Exception { axisGraph.generateOrthogonals(3, 5); } - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - /** * Test method for - * {@link symmetry.DetectSymmetryTest#detectWidthSymmetry(medial_axis.MedialAxisGraph, chromosome.GeneticSlideImage)} + * {@link symmetry.DetectSymmetryTest(medial_axis.MedialAxisGraph, chromosome.GeneticSlideImage)} * . */ + @Test public void testDetectWidthSymmetry() { DetectSymmetry.detectWidthSymmetry(axisGraph, image); fail("Not yet implemented. DetectSymmetry may be obsolete (11/11/2012)"); From c635b338fdaa42fa4a881cab3e96813bd852a636 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Tue, 4 Apr 2017 19:16:27 -0400 Subject: [PATCH 2/2] fixed untracked files --- .idea/compiler.xml | 22 - .idea/copyright/profiles_settings.xml | 3 - .idea/libraries/lib.xml | 11 - .idea/misc.xml | 73 -- .idea/modules.xml | 8 - .idea/uiDesigner.xml | 124 --- .idea/vcs.xml | 6 - .idea/workspace.xml | 1154 ----------------------- karyotyper.iml | 33 - src/{color => Color}/ISOClineColor.java | 0 src/{color => Color}/PixelColor.java | 0 src/testing/TestShape.java | 136 +-- 12 files changed, 68 insertions(+), 1502 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/libraries/lib.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/uiDesigner.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml delete mode 100644 karyotyper.iml rename src/{color => Color}/ISOClineColor.java (100%) rename src/{color => Color}/PixelColor.java (100%) diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml deleted file mode 100644 index e71c7de..0000000 --- a/.idea/libraries/lib.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index acb45ed..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.8 - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 4bdd032..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index ff60b59..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,1154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1491333853242 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/test/characterize/CharacterizerTest.java - 199 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/karyotyper.iml b/karyotyper.iml deleted file mode 100644 index 076a646..0000000 --- a/karyotyper.iml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/color/ISOClineColor.java b/src/Color/ISOClineColor.java similarity index 100% rename from src/color/ISOClineColor.java rename to src/Color/ISOClineColor.java diff --git a/src/color/PixelColor.java b/src/Color/PixelColor.java similarity index 100% rename from src/color/PixelColor.java rename to src/Color/PixelColor.java diff --git a/src/testing/TestShape.java b/src/testing/TestShape.java index 9a4b725..19f7257 100644 --- a/src/testing/TestShape.java +++ b/src/testing/TestShape.java @@ -1,68 +1,68 @@ -package testing; - -import runner.ImageQueue; -import chromosome.ChromosomeCluster; -import chromosome.GeneticSlideImage; -import extraction.Extractor; - -public class TestShape { - private static GeneticSlideImage image = null; - private static ChromosomeCluster cluster = null; - - /** - * @param args - */ - public static void main(String[] args) { - String filename; - ImageQueue images = new ImageQueue(); - // put new images in the queue and return the next image from the folder - // args - filename = images.getNextFile(args[0]); - // create a slideImage from the filename - GeneticSlideImage image = new GeneticSlideImage(filename); - Extractor extractor = new Extractor(); - if (filename != null) { - // extract the background from the image - int shapeNum = extractor.removeBackground(image); - // extract the clusters from the image - shapeNum = extractor.findClusters(image); - // pass on the list of clusters - ChromosomeCluster testCluster = extractor.getClusterList().get(0); - // print out the first cluster in the list - extractor.getClusterList().get(0).clusterOut(); - } - } - - /** - * Returns the chromosome cluster object from an image. - * - * @param filename - * File containing cluster - * @return The chromosome cluster object - */ - public static ChromosomeCluster getCluster(String filename) { - image = new GeneticSlideImage(filename); - Extractor extractor = new Extractor(); - ChromosomeCluster testCluster = null; - if (filename != null) { - // extract the background from the image - int shapeNum = extractor.removeBackground(image); - // extract the clusters from the image - shapeNum = extractor.findClusters(image); - // pass on the list of clusters - testCluster = extractor.getClusterList().get(0); - // print out the first cluster in the list - extractor.getClusterList().get(0).clusterOut(); - } - return testCluster; - } - - public static GeneticSlideImage getGeneticSlideImage() { - return image; - } - - public static ChromosomeCluster getCluster() { - return cluster; - } - -} +package testing; + +import runner.ImageQueue; +import chromosome.ChromosomeCluster; +import chromosome.GeneticSlideImage; +import extraction.Extractor; + +public class TestShape { + private static GeneticSlideImage image = null; + private static ChromosomeCluster cluster = null; + + /** + * @param args + */ + public static void main(String[] args) { + String filename; + ImageQueue images = new ImageQueue(); + // put new images in the queue and return the next image from the folder + // args + filename = images.getNextFile(args[0]); + // create a slideImage from the filename + GeneticSlideImage image = new GeneticSlideImage(filename); + Extractor extractor = new Extractor(); + if (filename != null) { + // extract the background from the image + int shapeNum = extractor.removeBackground(image); + // extract the clusters from the image + shapeNum = extractor.findClusters(image); + // pass on the list of clusters + ChromosomeCluster testCluster = extractor.getClusterList().get(0); + // print out the first cluster in the list + extractor.getClusterList().get(0).clusterOut(); + } + } + + /** + * Returns the chromosome cluster object from an image. + * + * @param filename + * File containing cluster + * @return The chromosome cluster object + */ + public static ChromosomeCluster getCluster(String filename) { + image = new GeneticSlideImage(filename); + Extractor extractor = new Extractor(); + ChromosomeCluster testCluster = null; + if (filename != null) { + // extract the background from the image + int shapeNum = extractor.removeBackground(image); + // extract the clusters from the image + shapeNum = extractor.findClusters(image); + // pass on the list of clusters + testCluster = extractor.getClusterList().get(0); + // print out the first cluster in the list + extractor.getClusterList().get(0).clusterOut(); + } + return testCluster; + } + + public static GeneticSlideImage getGeneticSlideImage() { + return image; + } + + public static ChromosomeCluster getCluster() { + return cluster; + } + +}