incubator-river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r935431 - in /incubator/river/jtsk/trunk/test/src/net/jini/io: ConvertTest.java MiToMoOutputStreamTest.java MoToMiInputStreamTest.java ToMOOutputStreamTest.java
Date Mon, 19 Apr 2010 00:59:54 GMT
Author: peter_firmstone
Date: Mon Apr 19 00:59:53 2010
New Revision: 935431

URL: http://svn.apache.org/viewvc?rev=935431&view=rev
Log:
Test Cases for new io utilities for converting between net.jini.io.MarshalledInstance and
java.rmi.MarshalledObject Object and Serialized Forms.

Added:
    incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java   (with props)
    incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java   (with props)
Removed:
    incubator/river/jtsk/trunk/test/src/net/jini/io/ToMOOutputStreamTest.java
Modified:
    incubator/river/jtsk/trunk/test/src/net/jini/io/ConvertTest.java

Modified: incubator/river/jtsk/trunk/test/src/net/jini/io/ConvertTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/io/ConvertTest.java?rev=935431&r1=935430&r2=935431&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/io/ConvertTest.java (original)
+++ incubator/river/jtsk/trunk/test/src/net/jini/io/ConvertTest.java Mon Apr 19 00:59:53 2010
@@ -48,7 +48,7 @@ public class ConvertTest {
     public void toRmiMarshalledObject() {
         try {
             System.out.println("toRmiMarshalledObject");
-            CDCMarshalledObject<String> instance_2 = new CDCMarshalledObject<String>(strObject);
+            MarshalledInstance<String> instance_2 = new MarshalledInstance<String>(strObject);
             Convert<String> convert = new Convert<String>();
             MarshalledObject<String> expResult = new MarshalledObject<String>(strObject);
             MarshalledObject<String> result = convert.toRmiMarshalledObject(instance_2);
@@ -78,26 +78,4 @@ public class ConvertTest {
             fail("The test threw an exception: " + ex.getMessage());
         }
     }
-
-    /**
-     * Test of toCDCMarshalledObject method, of class Convert.
-     */
-    @org.junit.Test
-    public void toCDCMarshalledObject() {
-        try {
-            System.out.println("toCDCMarshalledObject");
-            MarshalledObject<String> instance_2 = new MarshalledObject<String>(strObject);
-            Convert<String> instance = new Convert<String>();
-            CDCMarshalledObject<String> expResult = new CDCMarshalledObject<String>(strObject);
-            CDCMarshalledObject<String> result = instance.toCDCMarshalledObject(instance_2);
-            assertEquals(expResult, result);
-            // TODO review the generated test code and remove the default call to fail.
-            //fail("The test case is a prototype.");
-        } catch (Exception ex) {
-            fail("The test threw an exception: " + ex.getMessage());
-        }
-        // TODO review the generated test code and remove the default call to fail.
-        //fail("The test case is a prototype.");
-    }
-
 }
\ No newline at end of file

Added: incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java?rev=935431&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java Mon Apr 19
00:59:53 2010
@@ -0,0 +1,83 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.rmi.MarshalledObject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class MiToMoOutputStreamTest {
+    public MiToMoOutputStreamTest(){}
+    String strObject;
+    MarshalledInstance mi;
+    MarshalledObject mo;
+    @org.junit.BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @org.junit.AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @org.junit.Before
+    public void setUp() throws Exception {
+        strObject = "Test String";
+        mi = new MarshalledInstance(strObject);
+        mo = new MarshalledObject(strObject);
+    }
+
+    @org.junit.After
+    public void tearDown() throws Exception {
+    }
+
+    /**
+     * Test of toRmiMarshalledObject method, of class Convert.
+     */
+    @org.junit.Test
+    public void toMarshalledObject() {
+        try {
+            System.out.println("MarshalledInstancetoMarshalledObject");
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new MiToMoOutputStream(baos);
+            oos.writeObject(mi);
+            oos.flush();
+            
+            byte[] bytes = baos.toByteArray();
+            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+            ObjectInputStream ois = new ObjectInputStream(bais);
+            MarshalledObject mo = (MarshalledObject) ois.readObject();
+            if (mo == null) {
+                fail("MarshalledObject returned was null");
+            }
+            String result = (String) mo.get();
+            System.out.println(result);
+            assertEquals(mo, this.mo);
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (ClassNotFoundException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (NullPointerException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        }
+    }
+}

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/io/MiToMoOutputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java?rev=935431&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java Mon Apr 19
00:59:53 2010
@@ -0,0 +1,83 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.rmi.MarshalledObject;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class MoToMiInputStreamTest {
+    public MoToMiInputStreamTest(){}
+    String strObject;
+    MarshalledInstance mi;
+    MarshalledObject mo;
+    @org.junit.BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @org.junit.AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @org.junit.Before
+    public void setUp() throws Exception {
+        strObject = "Test String";
+        mi = new MarshalledInstance(strObject);
+        mo = new MarshalledObject(strObject);
+    }
+
+    @org.junit.After
+    public void tearDown() throws Exception {
+    }
+
+    /**
+     * Test of toRmiMarshalledObject method, of class Convert.
+     */
+    @org.junit.Test
+    public void toMarshalledInstance() {
+        System.out.println("toMarshalledInstance");
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(mo);
+            oos.flush();
+            
+            byte[] bytes = baos.toByteArray();
+            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+            ObjectInputStream ois = new MoToMiInputStream(bais);
+            MarshalledInstance mi = (MarshalledInstance) ois.readObject();
+            if (mi == null) {
+                fail("MarshalledObject returned was null");
+            }
+            String result = (String) mi.get(false);
+            System.out.println(result);
+            assertEquals(mi, this.mi);
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (ClassNotFoundException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        } catch (NullPointerException ex) {
+            ex.printStackTrace();
+            fail("The test threw an exception: " + ex.getMessage());
+        }
+    }
+}

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/io/MoToMiInputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message