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

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

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

revision 1.16, Tue Dec 1 09:56:28 2009 UTC revision 1.22, Wed Dec 31 19:05:42 2014 UTC
# Line 1  Line 1 
1  /*  /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain   * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.   * Pat Fisher, Mike Judd.
7   */   */
8    
9  import junit.framework.*;  import java.util.concurrent.atomic.AtomicBoolean;
10  import java.util.concurrent.atomic.*;  
11  import java.io.*;  import junit.framework.Test;
12    import junit.framework.TestSuite;
13    
14  public class AtomicBooleanTest extends JSR166TestCase {  public class AtomicBooleanTest extends JSR166TestCase {
15      public static void main (String[] args) {      public static void main (String[] args) {
# Line 119  Line 120 
120       * a deserialized serialized atomic holds same value       * a deserialized serialized atomic holds same value
121       */       */
122      public void testSerialization() throws Exception {      public void testSerialization() throws Exception {
123          AtomicBoolean l = new AtomicBoolean();          AtomicBoolean x = new AtomicBoolean();
124            AtomicBoolean y = serialClone(x);
125          l.set(true);          x.set(true);
126          ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);          AtomicBoolean z = serialClone(x);
127          ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));          assertTrue(x.get());
128          out.writeObject(l);          assertFalse(y.get());
129          out.close();          assertTrue(z.get());
   
         ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());  
         ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));  
         AtomicBoolean r = (AtomicBoolean) in.readObject();  
         assertEquals(l.get(), r.get());  
130      }      }
131    
132      /**      /**
# Line 138  Line 134 
134       */       */
135      public void testToString() {      public void testToString() {
136          AtomicBoolean ai = new AtomicBoolean();          AtomicBoolean ai = new AtomicBoolean();
137          assertEquals(ai.toString(), Boolean.toString(false));          assertEquals(Boolean.toString(false), ai.toString());
138          ai.set(true);          ai.set(true);
139          assertEquals(ai.toString(), Boolean.toString(true));          assertEquals(Boolean.toString(true), ai.toString());
140      }      }
141    
142  }  }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.22

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8