Search in sources :

Example 46 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class ConcurrentModTest method test_addILjava_lang_Object.

public void test_addILjava_lang_Object() {
    AbstractList abstr = new AbstractList() {

        @Override
        public Object get(int arg0) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    try {
        abstr.add(1, null);
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException e) {
    //ecpected
    }
    abstr = new AbstractList<Double>() {

        @Override
        public void add(int index, Double value) {
        }

        @Override
        public Double get(int index) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    try {
        abstr.add(1, 1);
        fail("ClassCastException expected");
    } catch (ClassCastException ee) {
    //expected
    }
    abstr = new AbstractList<Integer>() {

        final int forbiddenValue = 33;

        @Override
        public void add(int index, Integer value) {
            if (value == forbiddenValue) {
                throw new IllegalArgumentException();
            }
        }

        @Override
        public Integer get(int index) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    abstr.add(1, 1);
    try {
        abstr.add(1, 33);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ee) {
    //expected
    }
    abstr = new ArrayList();
    abstr.add(0, "element");
    abstr.add(1, null);
    abstr.add(2, 1);
    abstr.add(3, new Double(33));
    try {
        abstr.add(-3, new Double(33));
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
    try {
        abstr.add(abstr.size() + 1, new Double(33));
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList)

Example 47 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class ConcurrentModTest method test_equalsLjava_lang_Object.

public void test_equalsLjava_lang_Object() {
    Collection c = new Vector();
    c.add(new Double(33));
    c.add(10);
    c.add("String");
    AbstractList abstr = new ArrayList();
    AbstractList abstr1 = new ArrayList();
    assertFalse(abstr.equals(this));
    abstr.add(new Double(33));
    abstr.add(10);
    abstr.add("String");
    assertTrue(abstr.equals(c));
    abstr1.addAll(c);
    assertTrue(abstr.equals(abstr1));
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Vector(java.util.Vector)

Example 48 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class ConcurrentModTest method testRemove.

/*
     * Test method for 'java.util.AbstractList.subList(int, int)'
     */
public void testRemove() {
    AbstractList al = new ArrayList();
    Double one = new Double(1.0);
    Double two = new Double(2.0);
    Double three = new Double(3.0);
    Double four = new Double(4.0);
    al.add(one);
    al.add(two);
    al.add(three);
    al.add(four);
    List sub = al.subList(1, 3);
    assertEquals(2, sub.size());
    // the sub.get(1) is 3.0
    assertTrue(((Double) sub.get(1)).doubleValue() <= 3.0);
    assertTrue(((Double) sub.get(1)).doubleValue() > 2.0);
    // remove the 2.0
    al.remove(1);
    try {
        // illegal call the subList's method remove(int).
        sub.remove(1);
        fail("It should throws ConcurrentModificationException.");
    } catch (ConcurrentModificationException e) {
        return;
    }
    try {
        sub.remove(-1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
    try {
        sub.remove(sub.size() + 1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
    al = new AbstractList() {

        @Override
        public Object get(int index) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public int size() {
            // TODO Auto-generated method stub
            return 0;
        }
    };
    try {
        al.remove(1);
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException ee) {
    //expected
    }
}
Also used : AbstractList(java.util.AbstractList) ConcurrentModificationException(java.util.ConcurrentModificationException) ArrayList(java.util.ArrayList) List(java.util.List) AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList)

Example 49 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class ConcurrentModTest method test_setILjava_lang_Object.

public void test_setILjava_lang_Object() {
    Collection c = new Vector();
    c.add(new Double(33));
    c.add(10);
    c.add("String");
    AbstractList abstr1 = new ArrayList();
    AbstractList abstr2 = new ArrayList();
    abstr1.addAll(c);
    abstr2.addAll(c);
    assertTrue(abstr1.equals(abstr2));
    abstr1.set(1, 1);
    assertFalse(abstr1.equals(abstr2));
    try {
        abstr1.set(abstr1.size() + 1, 1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
    try {
        abstr1.set(-1, 1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException ee) {
    //expected
    }
    AbstractList abstr = new AbstractList() {

        @Override
        public Object get(int index) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    try {
        abstr.set(0, null);
        fail("UnsupportedOperationException expected");
    } catch (UnsupportedOperationException ee) {
    //expected
    }
    abstr = new AbstractList<Double>() {

        @Override
        public Double set(int index, Double value) {
            return value;
        }

        @Override
        public Double get(int index) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    try {
        abstr.set(0, 1);
        fail("ClassCastException expected");
    } catch (ClassCastException ee) {
    //expected
    }
    abstr = new AbstractList<Integer>() {

        final int forbiddenValue = 33;

        @Override
        public Integer set(int index, Integer value) {
            if (value == forbiddenValue) {
                throw new IllegalArgumentException();
            }
            return value;
        }

        @Override
        public Integer get(int index) {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }
    };
    try {
        abstr.set(0, 33);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException ee) {
    //expected
    }
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Vector(java.util.Vector)

Example 50 with AbstractList

use of java.util.AbstractList in project robovm by robovm.

the class AbstractListTest method test_lastIndexOfLjava_lang_Object.

public void test_lastIndexOfLjava_lang_Object() {
    AbstractList al = new ArrayList();
    al.add(0);
    al.add(1);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(2);
    al.add(3);
    al.add(4);
    assertEquals(-1, al.lastIndexOf(5));
    assertEquals(6, al.lastIndexOf(2));
}
Also used : AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList)

Aggregations

AbstractList (java.util.AbstractList)76 ArrayList (java.util.ArrayList)30 List (java.util.List)17 HashMap (java.util.HashMap)10 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 QName (org.alfresco.service.namespace.QName)9 UserInfo (org.alfresco.rest.api.model.UserInfo)8 FileInfo (org.alfresco.service.cmr.model.FileInfo)8 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)7 RexNode (org.apache.calcite.rex.RexNode)7 Collection (java.util.Collection)6 ConcurrentModificationException (java.util.ConcurrentModificationException)6 Iterator (java.util.Iterator)6 Paging (org.alfresco.rest.framework.resource.parameters.Paging)6 IOException (java.io.IOException)5 Set (java.util.Set)5 FilterProp (org.alfresco.repo.node.getchildren.FilterProp)5 Test (org.junit.Test)5 ListIterator (java.util.ListIterator)4 RandomAccess (java.util.RandomAccess)4