[cvs] / jsr166 / src / test / tck / AtomicIntegerArrayTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AtomicIntegerArrayTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Sun Aug 31 19:24:52 2003 UTC revision 1.2, Sun Sep 7 20:39:11 2003 UTC
# Line 7  Line 7 
7    
8  import junit.framework.*;  import junit.framework.*;
9  import java.util.concurrent.atomic.*;  import java.util.concurrent.atomic.*;
10    import java.io.*;
11    
12  public class AtomicIntegerArrayTest extends TestCase  public class AtomicIntegerArrayTest extends TestCase
13  {  {
# Line 144  Line 145 
145          }          }
146      }      }
147    
148        public void testSerialization() {
149            AtomicIntegerArray l = new AtomicIntegerArray(N);
150            for (int i = 0; i < N; ++i)
151                l.set(i, -i);
152    
153            try {
154                ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
155                ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
156                out.writeObject(l);
157                out.close();
158    
159                ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
160                ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
161                AtomicIntegerArray r = (AtomicIntegerArray) in.readObject();
162                for (int i = 0; i < N; ++i) {
163                    assertEquals(l.get(i), r.get(i));
164                }
165            } catch(Exception e){
166                e.printStackTrace();
167                fail("unexpected exception");
168            }
169        }
170    
171  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8