ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/LinkedTransferQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/LinkedTransferQueueTest.java (file contents):
Revision 1.2 by jsr166, Fri Jul 31 23:37:31 2009 UTC vs.
Revision 1.3 by jsr166, Sat Aug 1 21:46:28 2009 UTC

# Line 1 | Line 1
1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
# Line 31 | Line 30 | public class LinkedTransferQueueTest ext
30          return new TestSuite(LinkedTransferQueueTest.class);
31      }
32  
33 <    /*
34 <     *Constructor builds new queue with size being zero and empty being true
33 >    /**
34 >     * Constructor builds new queue with size being zero and empty being true
35       */
36      public void testConstructor1() {
37          assertEquals(0, new LinkedTransferQueue().size());
38          assertTrue(new LinkedTransferQueue().isEmpty());
39      }
40  
41 <    /*
41 >    /**
42       * Initizialing constructor with null collection throws NPE
43       */
44      public void testConstructor2() {
# Line 61 | Line 60 | public class LinkedTransferQueueTest ext
60          } catch (NullPointerException success) {
61          }
62      }
63 <    /*
63 >
64 >    /**
65       * Initializing constructor with a collection containing some null elements
66       * throws NPE
67       */
68
68      public void testConstructor4() {
69          try {
70              Integer[] ints = new Integer[SIZE];
# Line 78 | Line 77 | public class LinkedTransferQueueTest ext
77          }
78      }
79  
80 <    /*
80 >    /**
81       * Queue contains all elements of the collection it is initialized by
82       */
83      public void testConstructor5() {
# Line 279 | Line 278 | public class LinkedTransferQueueTest ext
278              unexpectedException();
279          }
280      }
281 <    /*
281 >
282 >    /**
283       * Take removes existing elements until empty, then blocks interruptibly
284       */
285
285      public void testBlockingTake() {
286          Thread t = new Thread(new Runnable() {
287  
# Line 378 | Line 377 | public class LinkedTransferQueueTest ext
377      }
378  
379      /**
380 <     *  timed poll before a delayed offer fails; after offer succeeds;
381 <     *  on interruption throws
380 >     * timed poll before a delayed offer fails; after offer succeeds;
381 >     * on interruption throws
382       */
383      public void testTimedPollWithOffer() {
384          final LinkedTransferQueue q = new LinkedTransferQueue();
# Line 916 | Line 915 | public class LinkedTransferQueueTest ext
915          }
916      }
917  
918 <    /*
918 >    /**
919       * poll and take should decrement the waiting consumer count
920       */
921      public void testWaitingConsumer() {
# Line 942 | Line 941 | public class LinkedTransferQueueTest ext
941              this.unexpectedException();
942          }
943      }
944 <    /*
944 >
945 >    /**
946       * Inserts null into transfer throws NPE
947       */
948
948      public void testTransfer1() {
949          try {
950              LinkedTransferQueue q = new LinkedTransferQueue();
# Line 957 | Line 956 | public class LinkedTransferQueueTest ext
956          }
957      }
958  
959 <    /*
959 >    /**
960       * transfer attempts to insert into the queue then wait until that
961       * object is removed via take or poll.
962       */
# Line 984 | Line 983 | public class LinkedTransferQueueTest ext
983              this.unexpectedException();
984          }
985      }
987    /*
988     * transfer will attempt to transfer in fifo order and continue waiting if
989     * the element being transfered is not polled or taken
990     */
986  
987 +    /**
988 +     * transfer will attempt to transfer in fifo order and continue
989 +     * waiting if the element being transfered is not polled or taken
990 +     */
991      public void testTransfer3() {
992          final LinkedTransferQueue<Integer> q = new LinkedTransferQueue<Integer>();
993          new Thread(new Runnable() {
# Line 1053 | Line 1052 | public class LinkedTransferQueueTest ext
1052              this.unexpectedException();
1053          }
1054      }
1056    /*
1057     * Insert null into trTransfer throws NPE
1058     */
1055  
1056 +    /**
1057 +     * Insert null into tryTransfer throws NPE
1058 +     */
1059      public void testTryTransfer1() {
1060          try {
1061              final LinkedTransferQueue q = new LinkedTransferQueue();
# Line 1067 | Line 1066 | public class LinkedTransferQueueTest ext
1066              this.unexpectedException();
1067          }
1068      }
1069 <    /*
1069 >
1070 >    /**
1071       * tryTransfer returns false and does not enqueue if there are no consumers
1072       * waiting to poll or take.
1073       */
1074
1074      public void testTryTransfer2() {
1075          try {
1076              final LinkedTransferQueue q = new LinkedTransferQueue();
# Line 1081 | Line 1080 | public class LinkedTransferQueueTest ext
1080              this.unexpectedException();
1081          }
1082      }
1083 <    /*
1083 >
1084 >    /**
1085       * if there is a consumer waiting poll or take tryTransfer returns
1086       * true while enqueueing object
1087       */
1088
1088      public void testTryTransfer3() {
1089          try {
1090              final LinkedTransferQueue q = new LinkedTransferQueue();
# Line 1108 | Line 1107 | public class LinkedTransferQueueTest ext
1107          }
1108      }
1109  
1110 <    /*
1110 >    /**
1111       * tryTransfer waits the amount given if interrupted, show an
1112       * interrupted exception
1113       */
# Line 1133 | Line 1132 | public class LinkedTransferQueueTest ext
1132          }
1133      }
1134  
1135 <    /*
1135 >    /**
1136       * tryTransfer gives up after the timeout and return false
1137       */
1138      public void testTryTransfer5() {
# Line 1156 | Line 1155 | public class LinkedTransferQueueTest ext
1155          }
1156      }
1157  
1158 <    /*
1158 >    /**
1159       * tryTransfer waits for any elements previously in to be removed
1160       * before transfering to a poll or take
1161       */
# Line 1185 | Line 1184 | public class LinkedTransferQueueTest ext
1184          }
1185      }
1186  
1187 <    /*
1187 >    /**
1188       * tryTransfer attempts to enqueue into the q and fails returning false not
1189       * enqueueing and the successing poll is null
1190       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines