[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    svn commit: r780521 -
From:       billbarker () apache ! org
Date:       2009-05-31 22:18:18
Message-ID: 20090531221819.1E29B23888BD () eris ! apache ! org
[Download RAW message or body]

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<Fraction> m = new DenseFieldMatrix<Fraction>(testData);
-            out.writeObject(m);
-            out.close();
-            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
-            DenseFieldMatrix<Fraction> nm = \
                (DenseFieldMatrix<Fraction>)in.readObject();
-            in.close();
-            test.delete();
-            assertEquals(m,nm);
-            
-        } catch (IOException e) {
-            fail("IOException: "+e);
-        } catch (ClassNotFoundException e) {
-            fail("Can't happen: "+e);
-        }
+        DenseFieldMatrix<Fraction> m = new DenseFieldMatrix<Fraction>(testData);
+        assertEquals(m,TestUtils.serializeAndRecover(m));
     }
-  
+
     private static class SetVisitor extends \
DefaultFieldMatrixChangingVisitor<Fraction> {  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<Fraction> m = new FieldMatrixImpl<Fraction>(testData);
-            out.writeObject(m);
-            out.close();
-            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
-            FieldMatrixImpl<Fraction> nm = \
                (FieldMatrixImpl<Fraction>)in.readObject();
-            in.close();
-            test.delete();
-            assertEquals(m,nm);
-            
-        } catch (IOException e) {
-            fail("IOException: "+e);
-        } catch (ClassNotFoundException e) {
-            fail("Can't happen: "+e);
-        }
+        FieldMatrixImpl<Fraction> m = new FieldMatrixImpl<Fraction>(testData);
+        assertEquals(m,TestUtils.serializeAndRecover(m));
     }
   
     private static class SetVisitor extends \
DefaultFieldMatrixChangingVisitor<Fraction> {

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<Fraction> v = new FieldVectorImpl<Fraction>(vec1);
-            out.writeObject(v);
-            out.close();
-            ObjectInputStream in = new ObjectInputStream(new FileInputStream(test));
-            FieldVectorImpl<Fraction> nv = \
                (FieldVectorImpl<Fraction>)in.readObject();
-            in.close();
-            test.delete();
-            assertEquals(v,nv);
-            
-        } catch (IOException e) {
-            fail("IOException: "+e);
-        } catch (ClassNotFoundException e) {
-            fail("Can't happen: "+e);
-        }
+        FieldVectorImpl<Fraction> v = new FieldVectorImpl<Fraction>(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) */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic