Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 13574 invoked from network); 31 May 2009 22:18:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 May 2009 22:18:33 -0000 Received: (qmail 46430 invoked by uid 500); 31 May 2009 22:18:45 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 46336 invoked by uid 500); 31 May 2009 22:18:44 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 46327 invoked by uid 99); 31 May 2009 22:18:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 May 2009 22:18:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 May 2009 22:18:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1E29B23888BD; Sun, 31 May 2009 22:18:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r780521 - /commons/proper/math/trunk/src/test/org/apache/commons/math/linear/ Date: Sun, 31 May 2009 22:18:18 -0000 To: commits@commons.apache.org From: billbarker@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090531221819.1E29B23888BD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: billbarker Date: Sun May 31 22:18:18 2009 New Revision: 780521 URL: http://svn.apache.org/viewvc?rev=780521&view=rev Log: Clean up linear serialization tests Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseFieldMatrixTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldMatrixImplTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseFieldMatrixTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseFieldMatrixTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseFieldMatrixTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseFieldMatrixTest.java Sun May 31 22:18:18 2009 @@ -1252,27 +1252,11 @@ } - @SuppressWarnings("unchecked") public void testSerial() { - try { - File test = File.createTempFile("DFM",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - DenseFieldMatrix m = new DenseFieldMatrix(testData); - out.writeObject(m); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - DenseFieldMatrix nm = (DenseFieldMatrix)in.readObject(); - in.close(); - test.delete(); - assertEquals(m,nm); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + DenseFieldMatrix m = new DenseFieldMatrix(testData); + assertEquals(m,TestUtils.serializeAndRecover(m)); } - + private static class SetVisitor extends DefaultFieldMatrixChangingVisitor { public SetVisitor() { super(Fraction.ZERO); Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/DenseRealMatrixTest.java Sun May 31 22:18:18 2009 @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Random; +import org.apache.commons.math.TestUtils; import org.apache.commons.math.linear.decomposition.LUDecompositionImpl; import org.apache.commons.math.linear.decomposition.NonSquareMatrixException; @@ -1163,25 +1164,10 @@ } public void testSerial() { - try { - File test = File.createTempFile("DRM",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - DenseRealMatrix m = new DenseRealMatrix(testData); - out.writeObject(m); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - DenseRealMatrix nm = (DenseRealMatrix)in.readObject(); - in.close(); - test.delete(); - assertEquals(m,nm); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + DenseRealMatrix m = new DenseRealMatrix(testData); + assertEquals(m,TestUtils.serializeAndRecover(m)); } - + private static class SetVisitor extends DefaultRealMatrixChangingVisitor { @Override public double visit(int i, int j, double value) { Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldMatrixImplTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldMatrixImplTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldMatrixImplTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldMatrixImplTest.java Sun May 31 22:18:18 2009 @@ -939,25 +939,9 @@ } - @SuppressWarnings("unchecked") public void testSerial() { - try { - File test = File.createTempFile("FMI",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - FieldMatrixImpl m = new FieldMatrixImpl(testData); - out.writeObject(m); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - FieldMatrixImpl nm = (FieldMatrixImpl)in.readObject(); - in.close(); - test.delete(); - assertEquals(m,nm); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + FieldMatrixImpl m = new FieldMatrixImpl(testData); + assertEquals(m,TestUtils.serializeAndRecover(m)); } private static class SetVisitor extends DefaultFieldMatrixChangingVisitor { Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/FieldVectorImplTest.java Sun May 31 22:18:18 2009 @@ -31,6 +31,7 @@ import org.apache.commons.math.Field; import org.apache.commons.math.FieldElement; +import org.apache.commons.math.TestUtils; import org.apache.commons.math.fraction.Fraction; import org.apache.commons.math.fraction.FractionField; @@ -618,25 +619,9 @@ } - @SuppressWarnings("unchecked") public void testSerial() { - try { - File test = File.createTempFile("FVI",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - FieldVectorImpl v = new FieldVectorImpl(vec1); - out.writeObject(v); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - FieldVectorImpl nv = (FieldVectorImpl)in.readObject(); - in.close(); - test.delete(); - assertEquals(v,nv); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + FieldVectorImpl v = new FieldVectorImpl(vec1); + assertEquals(v,TestUtils.serializeAndRecover(v)); } /** verifies that two vectors are equals */ Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java Sun May 31 22:18:18 2009 @@ -942,23 +942,8 @@ } public void testSerial() { - try { - File test = File.createTempFile("RMI",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - RealMatrixImpl m = new RealMatrixImpl(testData); - out.writeObject(m); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - RealMatrixImpl nm = (RealMatrixImpl)in.readObject(); - in.close(); - test.delete(); - assertEquals(m,nm); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + RealMatrixImpl m = new RealMatrixImpl(testData); + assertEquals(m,TestUtils.serializeAndRecover(m)); } Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/RealVectorImplTest.java Sun May 31 22:18:18 2009 @@ -23,6 +23,9 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; + +import org.apache.commons.math.TestUtils; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -1176,23 +1179,8 @@ } public void testSerial() { - try { - File test = File.createTempFile("RVI",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - RealVectorImpl v = new RealVectorImpl(new double[] { 0, 1, 2 }); - out.writeObject(v); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - RealVectorImpl nv = (RealVectorImpl)in.readObject(); - in.close(); - test.delete(); - assertEquals(v,nv); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + RealVectorImpl v = new RealVectorImpl(new double[] { 0, 1, 2 }); + assertEquals(v,TestUtils.serializeAndRecover(v)); } Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealMatrixTest.java Sun May 31 22:18:18 2009 @@ -27,6 +27,7 @@ import junit.framework.TestCase; import junit.framework.TestSuite; +import org.apache.commons.math.TestUtils; import org.apache.commons.math.linear.decomposition.LUDecompositionImpl; import org.apache.commons.math.linear.decomposition.NonSquareMatrixException; @@ -649,23 +650,8 @@ } public void testSerial() { - try { - File test = File.createTempFile("OMRM",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - OpenMapRealMatrix m = createSparseMatrix(testData); - out.writeObject(m); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - OpenMapRealMatrix nm = (OpenMapRealMatrix)in.readObject(); - in.close(); - test.delete(); - assertEquals(m,nm); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + OpenMapRealMatrix m = createSparseMatrix(testData); + assertEquals(m,TestUtils.serializeAndRecover(m)); } // --------------- -----------------Protected methods Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java?rev=780521&r1=780520&r2=780521&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/linear/SparseRealVectorTest.java Sun May 31 22:18:18 2009 @@ -23,6 +23,9 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; + +import org.apache.commons.math.TestUtils; + import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -1100,23 +1103,8 @@ } public void testSerial() { - try { - File test = File.createTempFile("OMV",".ser"); - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(test)); - OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 }); - out.writeObject(v); - out.close(); - ObjectInputStream in = new ObjectInputStream(new FileInputStream(test)); - OpenMapRealVector nv = (OpenMapRealVector)in.readObject(); - in.close(); - test.delete(); - assertEquals(v,nv); - - } catch (IOException e) { - fail("IOException: "+e); - } catch (ClassNotFoundException e) { - fail("Can't happen: "+e); - } + OpenMapRealVector v = new OpenMapRealVector(new double[] { 0, 1, 2 }); + assertEquals(v,TestUtils.serializeAndRecover(v)); } /** verifies that two vectors are close (sup norm) */