From eebd52174f19c699baf68312c792a6a5a976736d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 7 Oct 2011 04:20:16 -0400 Subject: [PATCH] Add two dev-java/fits patches and cleanup so tests all pass. --- dev-java/fits/Manifest | 6 +- ...to-access-CompressTest-data-for-unit.patch | 137 +++++++++++ ...pdate-ArrayFuncsTest.java-to-JUnit-4.patch | 223 ++++++++++++++++++ dev-java/fits/files/build.xml | 41 +++- dev-java/fits/fits-1.06.0.ebuild | 16 +- 5 files changed, 413 insertions(+), 10 deletions(-) create mode 100644 dev-java/fits/files/01-Use-getResource-to-access-CompressTest-data-for-unit.patch create mode 100644 dev-java/fits/files/02-Update-ArrayFuncsTest.java-to-JUnit-4.patch diff --git a/dev-java/fits/Manifest b/dev-java/fits/Manifest index d3784d3..5c96fa3 100644 --- a/dev-java/fits/Manifest +++ b/dev-java/fits/Manifest @@ -1,6 +1,8 @@ +AUX 01-Use-getResource-to-access-CompressTest-data-for-unit.patch 4661 RMD160 aaa090107ab67588ad0e13de7c43c2a4588441b4 SHA1 48b310f6e10c1e091b02ef94026f0bf4e31a75b5 SHA256 eb121342dfba55ec3bb7988c0b91074b581e89be87262aee3ced25ffd3d97cff +AUX 02-Update-ArrayFuncsTest.java-to-JUnit-4.patch 7206 RMD160 96a7f0b30a8f215e5895d9c4c6f7c6ed9ad61602 SHA1 5edfe76d0abb7f91335a953239ad4016c21a1f84 SHA256 3d62e65233b4893b96e806afb6a9141402ffacbd134c9766e80c8a3f5e66d6d3 AUX README.Gentoo 1872 RMD160 d1dd74e452a146eda2a7cbd2a77ebb56a553306e SHA1 a808f13153d79e45312981bdd1b70db9831cfecf SHA256 eff5ce2b235af399f751566aa395ca7b803b7314e3adb652f7ae395653ac8628 -AUX build.xml 1682 RMD160 1ee625d0c100404539c95a5b8969189a86af1ecb SHA1 6aa2e178ff42715fb2106865f1110380b8c9de33 SHA256 d7d8c497145f906165a7ba954c56482fad51b733ef3a2d186544fa3edabf343c +AUX build.xml 2912 RMD160 ce8ed7ab2d8581c31b55eebbaa770d371ec97682 SHA1 0854c8cd54eca889d590d9daf12eaddcffc80cf4 SHA256 8ecea978246d47b111a364ec1a7d081b15b15b10e717264ae8a433351b9dbf7d DIST fits-1.06.0_src.jar 174797 RMD160 af8bfea7039bc5ab9b3ad32be6d67f9145066005 SHA1 763c81042b8586ddba96e44a94fbd0d9e68217e4 SHA256 924c39f98114720917f2914e886d9f87050632a48769c289b0dffbbb646b7fcf -EBUILD fits-1.06.0.ebuild 1141 RMD160 0db36320be2cab8a537cd1b8b5233037048a170f SHA1 70a8b581d18ba5e2f9eb9d33144aa2a400ffdeb0 SHA256 4edc7d3ccc7b1d3a7482fe1416eddeeba20e72a156af37bc6de7347371fb91e4 +EBUILD fits-1.06.0.ebuild 1405 RMD160 da88ce48b3925f3fd32760addae381e2ceee05c7 SHA1 af8792b81ce9be49c215f99d7f3239884aa7b756 SHA256 ea6ab865055812b3a5db462d2e218221e697004df7165de1daf3dc83780c5fa4 MISC ChangeLog 287 RMD160 e7a8dcb5e8f68f96c07fee8473eed16f6df1cd31 SHA1 314dcbbf441e47feac4bedf7b38000e0d4852e6d SHA256 b15c9d486f5b3ddb5d991e78b1f82a59ca2658b30807e1908a57a6ec72a0eb01 MISC metadata.xml 247 RMD160 6735f3a5dd2d7a2b70589d1693f35d54291b7147 SHA1 c015969fe50967340dd050a44cb9f8a30b5e34a5 SHA256 9e65060e5f9d0a50d28c7a69d9c27fed6c3037fdd3e420cc276627fde2794f72 diff --git a/dev-java/fits/files/01-Use-getResource-to-access-CompressTest-data-for-unit.patch b/dev-java/fits/files/01-Use-getResource-to-access-CompressTest-data-for-unit.patch new file mode 100644 index 0000000..389c233 --- /dev/null +++ b/dev-java/fits/files/01-Use-getResource-to-access-CompressTest-data-for-unit.patch @@ -0,0 +1,137 @@ +diff --git a/src/nom/tam/fits/test/CompressTest.java b/src/nom/tam/fits/test/CompressTest.java +index dd3aad0..c6d953e 100644 +--- a/src/nom/tam/fits/test/CompressTest.java ++++ b/src/nom/tam/fits/test/CompressTest.java +@@ -54,58 +54,57 @@ public class CompressTest { + + @Test + public void testStream() throws Exception { +- InputStream is; ++ String is; + +- is = new FileInputStream("test.fits"); ++ is = "test.fits"; + assertEquals("Stream1", 300, streamRead(is, false, false)); + +- is = new FileInputStream("test.fits.Z"); ++ is = "test.fits.Z"; + assertEquals("Stream2", 300, streamRead(is, false, false)); + +- is = new FileInputStream("test.fits.gz"); ++ is = "test.fits.gz"; + assertEquals("Stream3", 300, streamRead(is, false, false)); + +- is = new FileInputStream("test.fits"); ++ is = "test.fits"; + assertEquals("Stream4", 300, streamRead(is, false, true)); + +- is = new FileInputStream("test.fits.Z"); ++ is = "test.fits.Z"; + assertEquals("Stream5", 300, streamRead(is, false, true)); + +- is = new FileInputStream("test.fits.gz"); ++ is = "test.fits.gz"; + assertEquals("Stream6", 300, streamRead(is, false, true)); + +- +- is = new FileInputStream("test.fits.Z"); ++ is = "test.fits.Z"; + assertEquals("Stream7", 300, streamRead(is, true, true)); + +- is = new FileInputStream("test.fits.gz"); ++ is = "test.fits.gz"; + assertEquals("Stream8", 300, streamRead(is, true, true)); + +- is = new FileInputStream("test.fits.bz2"); ++ is = "test.fits.bz2"; + assertEquals("Stream9", 300, streamRead(is, true, true)); + } + + @Test + public void testFile() throws Exception { +- File is = new File("test.fits"); ++ String is = "test.fits"; + assertEquals("File1", 300, fileRead(is, false, false)); + +- is = new File("test.fits.Z"); ++ is = "test.fits.Z"; + assertEquals("File2", 300, fileRead(is, false, false)); + +- is = new File("test.fits.gz"); ++ is = "test.fits.gz"; + assertEquals("File3", 300, fileRead(is, false, false)); + +- is = new File("test.fits"); ++ is = "test.fits"; + assertEquals("File4", 300, fileRead(is, false, true)); + +- is = new File("test.fits.Z"); ++ is = "test.fits.Z"; + assertEquals("File7", 300, fileRead(is, true, true)); + +- is = new File("test.fits.gz"); ++ is = "test.fits.gz"; + assertEquals("File8", 300, fileRead(is, true, true)); + +- is = new File("test.fits.bz2"); ++ is = "test.fits.bz2"; + assertEquals("File9", 300, fileRead(is, true, true)); + } + +@@ -131,7 +130,6 @@ public class CompressTest { + + is = "test.fits.bz2"; + assertEquals("String8", 300, stringRead(is, true, true)); +- + } + + @Test +@@ -158,13 +156,9 @@ public class CompressTest { + assertEquals("String8", 300, urlRead(is, true, true)); + } + +- int urlRead(String is, boolean comp, boolean useComp) ++ int urlRead(String filename, boolean comp, boolean useComp) + throws Exception { +- File fil = new File(is); +- +- String path = fil.getCanonicalPath(); +- URL u = new URL("file://" + path); +- ++ URL u = CompressTest.class.getResource(filename); + Fits f; + if (useComp) { + f = new Fits(u, comp); +@@ -176,8 +170,9 @@ public class CompressTest { + return total(data); + } + +- int streamRead(InputStream is, boolean comp, boolean useComp) ++ int streamRead(String filename, boolean comp, boolean useComp) + throws Exception { ++ InputStream is = CompressTest.class.getResourceAsStream(filename); + Fits f; + if (useComp) { + f = new Fits(is, comp); +@@ -190,8 +185,9 @@ public class CompressTest { + return total(data); + } + +- int fileRead(File is, boolean comp, boolean useComp) ++ int fileRead(String filename, boolean comp, boolean useComp) + throws Exception { ++ File is = new File(CompressTest.class.getResource(filename).getPath()); + Fits f; + if (useComp) { + f = new Fits(is, comp); +@@ -203,8 +199,9 @@ public class CompressTest { + return total(data); + } + +- int stringRead(String is, boolean comp, boolean useComp) ++ int stringRead(String filename, boolean comp, boolean useComp) + throws Exception { ++ String is = CompressTest.class.getResource(filename).getPath(); + Fits f; + if (useComp) { + f = new Fits(is, comp); diff --git a/dev-java/fits/files/02-Update-ArrayFuncsTest.java-to-JUnit-4.patch b/dev-java/fits/files/02-Update-ArrayFuncsTest.java-to-JUnit-4.patch new file mode 100644 index 0000000..c9cd02d --- /dev/null +++ b/dev-java/fits/files/02-Update-ArrayFuncsTest.java-to-JUnit-4.patch @@ -0,0 +1,223 @@ +From b9edd6a86e66d354b0c1d010125246d8359cbb37 Mon Sep 17 00:00:00 2001 +From: W. Trevor King +Date: Fri, 7 Oct 2011 03:44:18 -0400 +Subject: [PATCH 7/8] Update ArrayFuncsTest.java to JUnit-4. + +--- + src/nom/tam/util/test/ArrayFuncsTest.java | 44 +++++++++++++++++++--------- + 1 files changed, 30 insertions(+), 14 deletions(-) + +diff --git a/src/nom/tam/util/test/ArrayFuncsTest.java b/src/nom/tam/util/test/ArrayFuncsTest.java +index df5efb0..7ad8e51 100644 +--- a/src/nom/tam/util/test/ArrayFuncsTest.java ++++ b/src/nom/tam/util/test/ArrayFuncsTest.java +@@ -6,6 +6,12 @@ + */ + package nom.tam.util.test; + ++import org.junit.Test; ++import static org.junit.Assert.assertEquals; ++import static org.junit.Assert.assertTrue; ++import static org.junit.Assert.assertFalse; ++import static org.junit.Assert.assertSame; ++import static org.junit.Assert.assertNotSame; + import junit.framework.*; + import java.lang.reflect.*; + import java.util.Arrays; +@@ -15,21 +21,12 @@ import nom.tam.util.ArrayFuncs; + * + * @author Thomas McGlynn + */ +-public class ArrayFuncsTest extends TestCase { +- +- public ArrayFuncsTest(String testName) { +- super(testName); +- } +- +- protected void setUp() throws Exception { +- } +- +- protected void tearDown() throws Exception { +- } ++public class ArrayFuncsTest { + + /** + * Test of computeSize method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testComputeSize() { + System.out.println("computeSize"); + +@@ -58,6 +55,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of nElements method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testNElements() { + System.out.println("nElements"); + +@@ -72,6 +70,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of deepClone method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testDeepClone() { + int[][] test = {{0, 1}, {2, 3}, {4, 5}}; + int[][] result = (int[][]) nom.tam.util.ArrayFuncs.deepClone(test); +@@ -96,6 +95,7 @@ public class ArrayFuncsTest extends TestCase { + } + + public boolean equals(Object x) { ++ System.out.println("checking equality"); + return (x instanceof CloneTest) + && (((CloneTest) x).value == this.value); + } +@@ -104,6 +104,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of genericClone method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGenericClone() { + System.out.println("genericClone"); + +@@ -126,6 +127,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of copyArray method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testCopyArray() { + System.out.println("copyArray"); + +@@ -138,6 +140,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of getDimensions method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGetDimensions() { + System.out.println("getDimensions"); + +@@ -157,6 +160,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of getBaseArray method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGetBaseArray() { + + int[][][] test = new int[2][3][4]; +@@ -169,6 +173,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of getBaseClass method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGetBaseClass() { + System.out.println("getBaseClass"); + +@@ -179,6 +184,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of getBaseLength method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGetBaseLength() { + + assertEquals(ArrayFuncs.getBaseLength(new int[2][3]), 4); +@@ -195,6 +201,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of generateArray method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testGenerateArray() { + System.out.println("generateArray"); + +@@ -213,6 +220,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of testPattern method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testTestPattern() { + System.out.println("testPattern"); + +@@ -229,6 +237,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of flatten method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testFlatten() { + System.out.println("flatten"); + +@@ -241,6 +250,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of curl method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testCurl() { + System.out.println("curl"); + +@@ -259,6 +269,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of mimicArray method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testMimicArray() { + System.out.println("mimicArray"); + +@@ -273,6 +284,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of convertArray method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testConvertArray() { + System.out.println("convertArray"); + +@@ -286,7 +298,7 @@ public class ArrayFuncsTest extends TestCase { + + newType = int.class; + int[][] ires = (int[][]) ArrayFuncs.convertArray(array, newType, true); +- assertEquals(array, ires); ++ assertSame(array, ires); + + ires = (int[][]) ArrayFuncs.convertArray(array, newType, false); + assertNotSame(array, ires); +@@ -296,6 +308,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of copyInto method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testCopyInto() { + System.out.println("copyInto"); + +@@ -304,13 +317,14 @@ public class ArrayFuncsTest extends TestCase { + + ArrayFuncs.copyInto(x, y); + +- assertEquals((double) x[0][0], y[0][0]); +- assertEquals((double) x[1][2], y[1][2]); ++ assertEquals((double) x[0][0], y[0][0], 0.01); ++ assertEquals((double) x[1][2], y[1][2], 0.01); + } + + /** + * Test of arrayEquals method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testArrayEquals() { + System.out.println("arrayEquals"); + +@@ -331,6 +345,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of doubleArrayEquals method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testDoubleArrayEquals() { + + double x[] = {1, 2, 3}; +@@ -349,6 +364,7 @@ public class ArrayFuncsTest extends TestCase { + /** + * Test of floatArrayEquals method, of class nom.tam.util.ArrayFuncs. + */ ++ @Test + public void testFloatArrayEquals() { + float x[] = {1f, 2f, 3f}; + float y[] = {1f, 2f, 3f}; +-- +1.7.3.1.104.gc752e + diff --git a/dev-java/fits/files/build.xml b/dev-java/fits/files/build.xml index 285e43c..b38e8d2 100644 --- a/dev-java/fits/files/build.xml +++ b/dev-java/fits/files/build.xml @@ -4,10 +4,15 @@ + + + + + + + + - - - @@ -15,9 +20,30 @@ description="Compiles the classes"> + deprecation="true" includeantruntime="false"> + + + + + + + + + + + + + + + + + + + + + @@ -41,6 +67,11 @@ description="Erase all generated files and dirs"> - + + + + + + diff --git a/dev-java/fits/fits-1.06.0.ebuild b/dev-java/fits/fits-1.06.0.ebuild index 75763cf..491c1ec 100644 --- a/dev-java/fits/fits-1.06.0.ebuild +++ b/dev-java/fits/fits-1.06.0.ebuild @@ -3,10 +3,10 @@ # $Header: $ EAPI=4 -JAVA_PKG_IUSE="doc source" +JAVA_PKG_IUSE="doc source test" inherit eutils java-pkg-2 java-ant-2 -DESCRIPTION="Java library for FITS (image format) input/output library" +DESCRIPTION="Java library for FITS (image format) input/output" HOMEPAGE="http://fits.gsfc.nasa.gov/fits_libraries.html#java_tam" SRC_URI="http://heasarc.gsfc.nasa.gov/docs/heasarc/${PN}/java/v1.0/v${PV}/fits_src.jar -> ${P}_src.jar" @@ -21,6 +21,10 @@ RDEPEND=">=virtual/jre-1.5 ${COMMON_DEP}" DEPEND=">=virtual/jdk-1.5 + test? ( + dev-java/ant-junit4 + dev-java/hamcrest-core + ) ${COMMON_DEP}" src_unpack() { @@ -36,11 +40,17 @@ java_prepare() { cp "${FILESDIR}"/build.xml . || die sed -i "s/VERSION/${PV}/" build.xml || die sed -i "s:JUNIT.JAR:${junit}:" build.xml || die + epatch "${FILESDIR}"/01-Use-getResource-to-access-CompressTest-data-for-unit.patch + epatch "${FILESDIR}"/02-Update-ArrayFuncsTest.java-to-JUnit-4.patch +} + +src_test() { + ANT_TASKS="ant-junit4" eant test || die } src_install() { java-pkg_newjar ${PN}.jar ${PN}.jar use doc && java-pkg_dojavadoc doc/api - use source && java-pkg_dosrc src/nom + use source && java-pkg_dosrc src/* #use examples && java-pkg_doexamples src/java/examples } -- 2.26.2