コード例 #1
0
 @Test(expected = NullPointerException.class)
 public void testAddNull() throws Exception {
   RetainLinkedList<String> list = new RetainLinkedList<String>(3);
   Field field = FieldUtil.getField(RetainLinkedList.class, "tail");
   FieldUtil.setFieldValue(list, field, null);
   list.add("hello");
 }
コード例 #2
0
 /**
  * Test method for {@link org.apache.niolex.commons.collection.RetainLinkedList#handleRetain()}.
  */
 @Test(expected = NullPointerException.class)
 public void testHandleRetainCover() throws Exception {
   RetainLinkedList<String> list = new RetainLinkedList<String>(3);
   Field field = FieldUtil.getField(RetainLinkedList.class, "headPointerSize");
   FieldUtil.setFieldValue(list, field, 2);
   list.handleRetain();
 }
コード例 #3
0
 /** Test method for {@link org.apache.niolex.commons.collection.RetainLinkedList#handleNext()}. */
 @Test(expected = NullPointerException.class)
 public void testHandleNextCover() throws Exception {
   RetainLinkedList<String> other = new RetainLinkedList<String>(3);
   other.add("It ");
   other.add("is ");
   other.add("a ");
   other.add("big ");
   other.add("world!");
   RetainLinkedList<String> list = new RetainLinkedList<String>(3);
   Field field = FieldUtil.getField(RetainLinkedList.class, "headPointerSize");
   FieldUtil.setFieldValue(list, field, 5);
   // ---
   field = FieldUtil.getField(RetainLinkedList.class, "pointer");
   Object ppt = FieldUtil.getFieldValue(other, field);
   FieldUtil.setFieldValue(list, field, ppt);
   list.handleNext();
 }