You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2009/06/07 21:13:17 UTC

svn commit: r782435 - /commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java

Author: luc
Date: Sun Jun  7 19:13:17 2009
New Revision: 782435

URL: http://svn.apache.org/viewvc?rev=782435&view=rev
Log:
added serialization test
changed tests to Junit 4

Modified:
    commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java?rev=782435&r1=782434&r2=782435&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java Sun Jun  7 19:13:17 2009
@@ -17,7 +17,10 @@
 
 package org.apache.commons.math.ode.sampling;
 
-import junit.framework.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ObjectOutputStream;
@@ -27,15 +30,12 @@
 import org.apache.commons.math.ode.DerivativeException;
 import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
 import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
+import org.junit.Test;
 
-public class DummyStepInterpolatorTest
-  extends TestCase {
-
-  public DummyStepInterpolatorTest(String name) {
-    super(name);
-  }
+public class DummyStepInterpolatorTest {
 
-  public void testNoReset() {
+  @Test
+  public void testNoReset() throws DerivativeException {
 
     double[]   y    =   { 0.0, 1.0, -2.0 };
     DummyStepInterpolator interpolator = new DummyStepInterpolator(y, true);
@@ -50,6 +50,7 @@
 
   }
 
+  @Test
   public void testFixedState()
     throws DerivativeException {
 
@@ -73,6 +74,7 @@
 
   }
 
+  @Test
   public void testSerialization()
   throws DerivativeException, IOException, ClassNotFoundException {
 
@@ -101,6 +103,7 @@
 
   }
 
+  @Test
   public void testImpossibleSerialization()
   throws IOException {
 
@@ -138,55 +141,4 @@
       }
   }
 
-
-  public void testSerializationError()
-  throws IOException {
-
-    double[] y = { 0.0, 1.0, -2.0 };
-    ErrorGeneratingInterpolator interpolator =
-        new ErrorGeneratingInterpolator(y, true);
-    interpolator.storeTime(0);
-    interpolator.shift();
-    interpolator.storeTime(1);
-
-    ByteArrayOutputStream bos = new ByteArrayOutputStream();
-    ObjectOutputStream    oos = new ObjectOutputStream(bos);
-    oos.writeObject(interpolator);
-
-    assertTrue(bos.size () > 300);
-    assertTrue(bos.size () < 350);
-
-    ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
-    ObjectInputStream     ois = new ObjectInputStream(bis);
-    try {
-        ois.readObject();
-        fail("an exception should have been thrown");
-    } catch (IOException ioe) {
-        // expected behavior
-        assertEquals(0, ioe.getMessage().length());
-    } catch (Exception e) {
-        fail("wrong exception caught");
-    }
-
-  }
-
-  private static class ErrorGeneratingInterpolator extends DummyStepInterpolator {
-      public ErrorGeneratingInterpolator() {
-          super();
-      }
-      protected ErrorGeneratingInterpolator(double[] y, boolean forward) {
-          super(y, forward);
-      }
-      @Override
-      public void computeInterpolatedState(double theta, double oneMinusThetaH)
-      throws DerivativeException {
-          throw new DerivativeException(null);
-      }
-      private static final long serialVersionUID = 0x3f6ab636f0c93571L;
-  }
-
-  public static Test suite() {
-    return new TestSuite(DummyStepInterpolatorTest.class);
-  }
-
 }