hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r916412 - in /httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http: TestHttpHost.java TestHttpVersion.java
Date Thu, 25 Feb 2010 19:31:21 GMT
Author: olegk
Date: Thu Feb 25 19:31:21 2010
New Revision: 916412

URL: http://svn.apache.org/viewvc?rev=916412&view=rev
Log:
Serialization test cases for Serializable classes

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java?rev=916412&r1=916411&r2=916412&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpHost.java
Thu Feb 25 19:31:21 2010
@@ -27,6 +27,11 @@
 
 package org.apache.http;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -141,4 +146,17 @@
         assertEquals(orig, clone);
     }
     
+    public void testSerialization() throws Exception {
+        HttpHost orig = new HttpHost("somehost", 8080, "https");
+        ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
+        ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
+        outstream.writeObject(orig);
+        outstream.close();
+        byte[] raw = outbuffer.toByteArray();
+        ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
+        ObjectInputStream instream = new ObjectInputStream(inbuffer);
+        HttpHost clone = (HttpHost) instream.readObject();
+        assertEquals(orig, clone);
+    }
+    
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java?rev=916412&r1=916411&r2=916412&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/TestHttpVersion.java
Thu Feb 25 19:31:21 2010
@@ -27,6 +27,11 @@
 
 package org.apache.http;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -118,5 +123,18 @@
         assertEquals(orig, clone);
     }
     
+    public void testSerialization() throws Exception {
+        HttpVersion orig = HttpVersion.HTTP_1_1;
+        ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
+        ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
+        outstream.writeObject(orig);
+        outstream.close();
+        byte[] raw = outbuffer.toByteArray();
+        ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
+        ObjectInputStream instream = new ObjectInputStream(inbuffer);
+        HttpVersion clone = (HttpVersion) instream.readObject();
+        assertEquals(orig, clone);
+    }
+    
 }
 



Mime
View raw message