cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [18/48] Installing Maven Failsafe Plugin
Date Sun, 02 Nov 2014 07:10:06 GMT
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
deleted file mode 100644
index b673fe6..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
+++ /dev/null
@@ -1,858 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.access;
-
-import java.math.BigDecimal;
-import java.sql.Time;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.query.NamedQuery;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.testdo.testmap.DateTestEntity;
-import org.apache.cayenne.testdo.testmap.ReturnTypesMap1;
-import org.apache.cayenne.testdo.testmap.ReturnTypesMap2;
-import org.apache.cayenne.testdo.testmap.ReturnTypesMapLobs1;
-import org.apache.cayenne.unit.UnitDbAdapter;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-/**
- * Test Types mapping for selected columns
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class ReturnTypesMappingTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-    
-    @Inject
-    private DBHelper dbHelper;
-    
-    @Inject
-    private UnitDbAdapter unitDbAdapter;
-    
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            dbHelper.deleteAll("TYPES_MAPPING_LOBS_TEST1");
-            dbHelper.deleteAll("TYPES_MAPPING_TEST2");
-        }
-        dbHelper.deleteAll("TYPES_MAPPING_TEST1");
-        dbHelper.deleteAll("DATE_TEST");
-    }
-
-    /*
-     * TODO: olga: We need divided TYPES_MAPPING_TES2 to 2 schemas with lobs columns and not lobs columns 
-     */
-    
-    public void testBIGINT() throws Exception {
-        String columnName = "BIGINT_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Long bigintValue = 5326457654783454355l;
-        test.setBigintColumn(bigintValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Long.class, columnValue.getClass());
-        assertEquals(bigintValue, columnValue);
-    }
-
-    public void testBIGINT2() throws Exception {
-       ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-    
-        Long bigintValue = 5326457654783454355l;
-        test.setBigintColumn(bigintValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Long columnValue = testRead.getBigintColumn();
-        assertNotNull(columnValue);
-        assertEquals(Long.class, columnValue.getClass());
-        assertEquals(bigintValue, columnValue);
-    }
-
-    public void testBINARY() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            String columnName = "BINARY_COLUMN";
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] binaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setBinaryColumn(binaryValue);
-            context.commitChanges();
-    
-            NamedQuery q = new NamedQuery("SelectReturnTypesMap2");
-            DataRow testRead = (DataRow) context.performQuery(q).get(0);
-            Object columnValue = testRead.get(columnName);
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(binaryValue, (byte[]) columnValue));
-        }
-    }
-
-    public void testBINARY2() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] binaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setBinaryColumn(binaryValue);
-            context.commitChanges();
-    
-            SelectQuery q = new SelectQuery(ReturnTypesMap2.class);
-            ReturnTypesMap2 testRead = (ReturnTypesMap2) context.performQuery(q).get(0);
-            byte[] columnValue = testRead.getBinaryColumn();
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(binaryValue, columnValue));
-        }
-    }
-
-    public void testBIT() throws Exception {
-        String columnName = "BIT_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Boolean bitValue = true;
-        test.setBitColumn(bitValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertTrue(Boolean.class.equals(columnValue.getClass())
-                || Short.class.equals(columnValue.getClass()));
-        assertTrue(bitValue.equals(columnValue) || ((Number) columnValue).intValue() == 1);
-    }
-
-    public void testBIT2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Boolean bitValue = true;
-        test.setBitColumn(bitValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Boolean columnValue = testRead.getBitColumn();
-        assertNotNull(columnValue);
-        assertEquals(Boolean.class, columnValue.getClass());
-        assertEquals(bitValue, columnValue);
-    }
-
-    public void testBLOB() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            String columnName = "BLOB_COLUMN";
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] blobValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setBlobColumn(blobValue);
-            context.commitChanges();
-    
-            NamedQuery q = new NamedQuery("SelectReturnTypesMap2");
-            DataRow testRead = (DataRow) context.performQuery(q).get(0);
-            Object columnValue = testRead.get(columnName);
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(blobValue, (byte[]) columnValue));
-        }
-    }
-
-    public void testBLOB2() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] blobValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setBlobColumn(blobValue);
-            context.commitChanges();
-    
-            SelectQuery q = new SelectQuery(ReturnTypesMap2.class);
-            ReturnTypesMap2 testRead = (ReturnTypesMap2) context.performQuery(q).get(0);
-            byte[] columnValue = testRead.getBlobColumn();
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(blobValue, columnValue));
-        }
-    }
-
-    public void testBOOLEAN() throws Exception {
-        String columnName = "BOOLEAN_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Boolean booleanValue = true;
-        test.setBooleanColumn(booleanValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertTrue(Boolean.class.equals(columnValue.getClass())
-                || Short.class.equals(columnValue.getClass()));
-        assertTrue(booleanValue.equals(columnValue)
-                || ((Number) columnValue).intValue() == 1);
-    }
-
-    public void testBOOLEAN2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Boolean booleanValue = true;
-        test.setBooleanColumn(booleanValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Boolean columnValue = testRead.getBooleanColumn();
-        assertNotNull(columnValue);
-        assertEquals(Boolean.class, columnValue.getClass());
-        assertEquals(booleanValue, columnValue);
-    }
-
-    public void testCHAR() throws Exception {
-        String columnName = "CHAR_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        String charValue = "Char string for tests!";
-        test.setCharColumn(charValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(charValue, columnValue);
-    }
-
-    public void testCHAR2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        String charValue = "Char string for tests!";
-        test.setCharColumn(charValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        String columnValue = testRead.getCharColumn();
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(charValue, columnValue);
-    }
-
-    public void testCLOB() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            String columnName = "CLOB_COLUMN";
-            ReturnTypesMapLobs1 test = context.newObject(ReturnTypesMapLobs1.class);
-    
-            StringBuffer buffer = new StringBuffer();
-            for (int i = 0; i < 10000; i++) {
-                buffer.append("CLOB very large string for tests!!!!\n");
-            }
-            String clobValue = buffer.toString();
-            test.setClobColumn(clobValue);
-            context.commitChanges();
-    
-            NamedQuery q = new NamedQuery("SelectReturnTypesLobsMap1");
-            DataRow testRead = (DataRow) context.performQuery(q).get(0);
-            Object columnValue = testRead.get(columnName);
-            if (columnValue == null && testRead.containsKey(columnName.toLowerCase())) {
-                columnValue = testRead.get(columnName.toLowerCase());
-            }
-            assertNotNull(columnValue);
-            assertEquals(String.class, columnValue.getClass());
-            assertEquals(clobValue, columnValue);
-        }
-    }
-
-    public void testCLOB2() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMapLobs1 test = context.newObject(ReturnTypesMapLobs1.class);
-    
-            StringBuffer buffer = new StringBuffer();
-            for (int i = 0; i < 10000; i++) {
-                buffer.append("CLOB very large string for tests!!!!\n");
-            }
-            String clobValue = buffer.toString();
-            test.setClobColumn(clobValue);
-            context.commitChanges();
-    
-            SelectQuery q = new SelectQuery(ReturnTypesMapLobs1.class);
-            ReturnTypesMapLobs1 testRead = (ReturnTypesMapLobs1) context.performQuery(q).get(0);
-            String columnValue = testRead.getClobColumn();
-            assertNotNull(columnValue);
-            assertEquals(String.class, columnValue.getClass());
-            assertEquals(clobValue, columnValue);
-        }
-    }
-
-    public void testDATE() throws Exception {
-        String columnName = "DATE_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2002, 1, 1);
-        Date dateValue = cal.getTime();
-        test.setDateColumn(dateValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        assertEquals(dateValue.toString(), columnValue.toString());
-    }
-
-    public void testDATE2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2002, 1, 1);
-        Date dateValue = cal.getTime();
-        test.setDateColumn(dateValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Date columnValue = testRead.getDateColumn();
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        assertEquals(dateValue.toString(), columnValue.toString());
-    }
-
-    public void testDECIMAL() throws Exception {
-        String columnName = "DECIMAL_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        BigDecimal decimalValue = new BigDecimal("578438.57843");
-        test.setDecimalColumn(decimalValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(BigDecimal.class, columnValue.getClass());
-        assertEquals(decimalValue, columnValue);
-    }
-
-    public void testDECIMAL2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        BigDecimal decimalValue = new BigDecimal("578438.57843");
-        test.setDecimalColumn(decimalValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        BigDecimal columnValue = testRead.getDecimalColumn();
-        assertNotNull(columnValue);
-        assertEquals(BigDecimal.class, columnValue.getClass());
-        assertEquals(decimalValue, columnValue);
-    }
-
-    public void testDOUBLE() throws Exception {
-        String columnName = "DOUBLE_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Double doubleValue = 3298.4349783d;
-        test.setDoubleColumn(doubleValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Double.class, columnValue.getClass());
-        assertEquals(doubleValue, columnValue);
-    }
-
-    public void testDOUBLE2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Double doubleValue = 3298.4349783d;
-        test.setDoubleColumn(doubleValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Double columnValue = testRead.getDoubleColumn();
-        assertNotNull(columnValue);
-        assertEquals(Double.class, columnValue.getClass());
-        assertEquals(doubleValue, columnValue);
-    }
-
-    public void testFLOAT() throws Exception {
-        String columnName = "FLOAT_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Float floatValue = 375.437f;
-        test.setFloatColumn(floatValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertTrue(Float.class.equals(columnValue.getClass())
-                || Double.class.equals(columnValue.getClass()));
-        assertEquals(floatValue.floatValue(), ((Number)columnValue).floatValue());
-    }
-
-    public void testFLOAT2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Float floatValue = 375.437f;
-        test.setFloatColumn(floatValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Float columnValue = testRead.getFloatColumn();
-        assertNotNull(columnValue);
-        assertEquals(Float.class, columnValue.getClass());
-        assertEquals(floatValue, columnValue);
-    }
-
-    public void testINTEGER() throws Exception {
-        String columnName = "INTEGER_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Integer integerValue = 54235;
-        test.setIntegerColumn(integerValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Integer.class, columnValue.getClass());
-        assertEquals(integerValue, columnValue);
-    }
-
-    public void testINTEGER2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Integer integerValue = 54235;
-        test.setIntegerColumn(integerValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Integer columnValue = testRead.getIntegerColumn();
-        assertNotNull(columnValue);
-        assertEquals(Integer.class, columnValue.getClass());
-        assertEquals(integerValue, columnValue);
-    }
-
-    public void testLONGVARBINARY() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            String columnName = "LONGVARBINARY_COLUMN";
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] longvarbinaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setLongvarbinaryColumn(longvarbinaryValue);
-            context.commitChanges();
-    
-            NamedQuery q = new NamedQuery("SelectReturnTypesMap2");
-            DataRow testRead = (DataRow) context.performQuery(q).get(0);
-            Object columnValue = testRead.get(columnName);
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(longvarbinaryValue, (byte[]) columnValue));
-        }
-    }
-
-    public void testLONGVARBINARY2() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] longvarbinaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setLongvarbinaryColumn(longvarbinaryValue);
-            context.commitChanges();
-    
-            SelectQuery q = new SelectQuery(ReturnTypesMap2.class);
-            ReturnTypesMap2 testRead = (ReturnTypesMap2) context.performQuery(q).get(0);
-            byte[] columnValue = testRead.getLongvarbinaryColumn();
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(longvarbinaryValue, columnValue));
-        }
-    }
-
-    public void testLONGVARCHAR() throws Exception {
-        String columnName = "LONGVARCHAR_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        StringBuffer buffer = new StringBuffer();
-        for (int i = 0; i < 500; i++) {
-            buffer.append("LONGVARCHAR large string for tests!!!!\n");
-        }
-        String longvarcharValue = buffer.toString();
-        test.setLongvarcharColumn(longvarcharValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(longvarcharValue, columnValue);
-    }
-
-    public void testLONGVARCHAR2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        StringBuffer buffer = new StringBuffer();
-        for (int i = 0; i < 500; i++) {
-            buffer.append("LONGVARCHAR large string for tests!!!!\n");
-        }
-        String longvarcharValue = buffer.toString();
-        test.setLongvarcharColumn(longvarcharValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        String columnValue = testRead.getLongvarcharColumn();
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(longvarcharValue, columnValue);
-    }
-
-    public void testNUMERIC() throws Exception {
-        String columnName = "NUMERIC_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        BigDecimal numericValue = new BigDecimal("578438.57843");
-        test.setNumericColumn(numericValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(BigDecimal.class, columnValue.getClass());
-        assertEquals(numericValue, columnValue);
-    }
-
-    public void testNUMERIC2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        BigDecimal numericValue = new BigDecimal("578438.57843");
-        test.setNumericColumn(numericValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        BigDecimal columnValue = testRead.getNumericColumn();
-        assertNotNull(columnValue);
-        assertEquals(BigDecimal.class, columnValue.getClass());
-        assertEquals(numericValue, columnValue);
-    }
-
-    public void testREAL() throws Exception {
-        String columnName = "REAL_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Float realValue = 5788.57843f;
-        test.setRealColumn(realValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-
-        // MySQL can treat REAL as either DOUBLE or FLOAT depending on the
-        // engine settings
-        if (unitDbAdapter.realAsDouble()) {
-            assertEquals(Double.class, columnValue.getClass());
-            assertEquals(Double.valueOf(realValue), (Double) columnValue, 0.0001);
-        } else {
-            assertEquals(Float.class, columnValue.getClass());
-            assertEquals(realValue, columnValue);
-        }
-    }
-
-    public void testREAL2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Float realValue = 5788.57843f;
-        test.setRealColumn(realValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Float columnValue = testRead.getRealColumn();
-        assertNotNull(columnValue);
-        assertEquals(Float.class, columnValue.getClass());
-        assertEquals(realValue, columnValue);
-    }
-
-    public void testSMALLINT() throws Exception {
-        String columnName = "SMALLINT_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Short smallintValue = 32564;
-        test.setSmallintColumn(smallintValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Short.class, columnValue.getClass());
-        assertEquals(smallintValue, columnValue);
-    }
-
-    public void testSMALLINT2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Short smallintValue = 32564;
-        test.setSmallintColumn(smallintValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Short columnValue = testRead.getSmallintColumn();
-        assertNotNull(columnValue);
-        assertEquals(Short.class, columnValue.getClass());
-        assertEquals(smallintValue, columnValue);
-    }
-
-    public void testTIME() throws Exception {
-        String columnName = "TIME_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2003, 1, 1, 1, 20, 30);
-        Date timeValue = new Time(cal.getTime().getTime());
-        test.setTimeColumn(timeValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        assertEquals(timeValue.toString(), new Time(((Date) columnValue).getTime())
-                .toString());
-    }
-
-    public void testTIME2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2003, 1, 1, 1, 20, 30);
-        Date timeValue = new Time(cal.getTime().getTime());
-        test.setTimeColumn(timeValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Date columnValue = testRead.getTimeColumn();
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        assertEquals(timeValue.toString(), new Time(columnValue.getTime()).toString());
-    }
-
-    public void testSQLTemplateTime() throws Exception {
-        DateTestEntity test = (DateTestEntity) context.newObject("DateTestEntity");
-
-        Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2003, 1, 1, 1, 20, 30);
-
-        // most databases fail millisecond accuracy
-        // cal.set(Calendar.MILLISECOND, 55);
-
-        Time now = new Time(cal.getTime().getTime());
-        test.setTimeColumn(now);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectDateTest");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Date columnValue = (Date) testRead.get("TIME_COLUMN");
-        assertNotNull(testRead.toString(), columnValue);
-        assertEquals(now.toString(), new Time(columnValue.getTime()).toString());
-    }
-
-    public void testTIMESTAMP() throws Exception {
-        String columnName = "TIMESTAMP_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Date timestampValue = Calendar.getInstance().getTime();
-        test.setTimestampColumn(timestampValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        
-        // some DB's, noteably MySQL, strip the milliseconds from timestamps,
-        // so comparing within 1 second precision
-        long delta = timestampValue.getTime() - ((Date) columnValue).getTime();
-        assertTrue(delta < 1000);
-    }
-
-    public void testTIMESTAMP2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Date timestampValue = Calendar.getInstance().getTime();
-        test.setTimestampColumn(timestampValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Date columnValue = testRead.getTimestampColumn();
-        assertNotNull(columnValue);
-        assertEquals(Date.class, columnValue.getClass());
-        
-        // some DB's, noteably MySQL, strip the milliseconds from timestamps,
-        // so comparing within 1 second precision
-        long delta = timestampValue.getTime() - ((Date) columnValue).getTime();
-        assertTrue(delta < 1000);    }
-
-    public void testTINYINT() throws Exception {
-        String columnName = "TINYINT_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Byte tinyintValue = 89;
-        test.setTinyintColumn(tinyintValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertTrue(Short.class.equals(columnValue.getClass()));
-        assertEquals(tinyintValue.intValue(), ((Number)columnValue).intValue());
-    }
-
-    public void testTINYINT2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        Byte tinyintValue = 89;
-        test.setTinyintColumn(tinyintValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        Byte columnValue = testRead.getTinyintColumn();
-        assertNotNull(columnValue);
-        assertEquals(Byte.class, columnValue.getClass());
-        assertEquals(tinyintValue, columnValue);
-    }
-
-    public void testVARBINARY() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            String columnName = "VARBINARY_COLUMN";
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] varbinaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setVarbinaryColumn(varbinaryValue);
-            context.commitChanges();
-    
-            NamedQuery q = new NamedQuery("SelectReturnTypesMap2");
-            DataRow testRead = (DataRow) context.performQuery(q).get(0);
-            Object columnValue = testRead.get(columnName);
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(varbinaryValue, (byte[]) columnValue));
-        }
-    }
-
-    public void testVARBINARY2() throws Exception {
-        if (unitDbAdapter.supportsLobs()) {
-            ReturnTypesMap2 test = context.newObject(ReturnTypesMap2.class);
-    
-            byte[] varbinaryValue = {
-                    3, 4, 5, -6, 7, 0, 2, 9, 45, 64, 3, 127, -128, -60
-            };
-            test.setVarbinaryColumn(varbinaryValue);
-            context.commitChanges();
-    
-            SelectQuery q = new SelectQuery(ReturnTypesMap2.class);
-            ReturnTypesMap2 testRead = (ReturnTypesMap2) context.performQuery(q).get(0);
-            byte[] columnValue = testRead.getVarbinaryColumn();
-            assertNotNull(columnValue);
-            assertEquals(byte[].class, columnValue.getClass());
-            assertTrue(Arrays.equals(varbinaryValue, columnValue));
-        }
-    }
-
-    public void testVARCHAR() throws Exception {
-        String columnName = "VARCHAR_COLUMN";
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        String varcharValue = "VARChar string for tests!";
-        test.setVarcharColumn(varcharValue);
-        context.commitChanges();
-
-        NamedQuery q = new NamedQuery("SelectReturnTypesMap1");
-        DataRow testRead = (DataRow) context.performQuery(q).get(0);
-        Object columnValue = testRead.get(columnName);
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(varcharValue, columnValue);
-    }
-
-    public void testVARCHAR2() throws Exception {
-        ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
-
-        String varcharValue = "VARChar string for tests!";
-        test.setVarcharColumn(varcharValue);
-        context.commitChanges();
-
-        SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
-        ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
-        String columnValue = testRead.getVarcharColumn();
-        assertNotNull(columnValue);
-        assertEquals(String.class, columnValue.getClass());
-        assertEquals(varcharValue, columnValue);
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsIT.java
new file mode 100644
index 0000000..1c84092
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsIT.java
@@ -0,0 +1,219 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.cayenne.DataRow;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+/**
+ * Tests IncrementalFaultList behavior when fetching data rows.
+ */
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SimpleIdIncrementalFaultListDataRowsIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DataContext context1;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tArtist;
+    private SimpleIdIncrementalFaultList<?> list;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+        createArtistsDataSet();
+
+        SelectQuery q = new SelectQuery("Artist");
+        q.setPageSize(6);
+        q.setFetchingDataRows(true);
+        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
+
+        list = new SimpleIdIncrementalFaultList<Object>(context, q, 10000);
+    }
+
+    protected void createArtistsDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tArtist.insert(33003, "artist3");
+        tArtist.insert(33004, "artist4");
+        tArtist.insert(33005, "artist5");
+        tArtist.insert(33006, "artist6");
+        tArtist.insert(33007, "artist7");
+        tArtist.insert(33008, "artist8");
+        tArtist.insert(33009, "artist9");
+        tArtist.insert(33010, "artist10");
+        tArtist.insert(33011, "artist11");
+        tArtist.insert(33012, "artist12");
+        tArtist.insert(33013, "artist13");
+        tArtist.insert(33014, "artist14");
+        tArtist.insert(33015, "artist15");
+        tArtist.insert(33016, "artist16");
+        tArtist.insert(33017, "artist17");
+        tArtist.insert(33018, "artist18");
+        tArtist.insert(33019, "artist19");
+        tArtist.insert(33020, "artist20");
+        tArtist.insert(33021, "artist21");
+        tArtist.insert(33022, "artist22");
+        tArtist.insert(33023, "artist23");
+        tArtist.insert(33024, "artist24");
+        tArtist.insert(33025, "artist25");
+    }
+
+    public void testGet1() throws Exception {
+        assertEquals(1, list.idWidth);
+        assertTrue(list.elements.get(0) instanceof Long);
+        assertTrue(list.elements.get(19) instanceof Long);
+
+        Object a = list.get(19);
+
+        assertNotNull(a);
+        assertTrue(a instanceof DataRow);
+        assertEquals(3, ((DataRow) a).size());
+        assertEquals("artist20", ((DataRow) a).get("ARTIST_NAME"));
+    }
+
+    public void testIndexOf1() throws Exception {
+
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        query.setFetchingDataRows(true);
+        List<?> artists = context1.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        DataRow row = (DataRow) artists.get(0);
+        assertEquals(19, list.indexOf(row));
+
+        DataRow clone = new DataRow(row);
+        assertEquals(19, list.indexOf(clone));
+
+        row.remove("ARTIST_ID");
+        assertEquals(-1, list.indexOf(row));
+    }
+
+    public void testIndexOf2() throws Exception {
+
+        // resolve first page
+        list.get(0);
+
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist2");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        query.setFetchingDataRows(true);
+        List<?> artists = context1.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        DataRow row = (DataRow) artists.get(0);
+        assertEquals(1, list.indexOf(row));
+
+        row.remove("ARTIST_NAME");
+        assertEquals(-1, list.indexOf(row));
+    }
+
+    public void testLastIndexOf1() throws Exception {
+
+        // resolve first page
+        list.get(0);
+
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist3");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        query.setFetchingDataRows(true);
+        List<?> artists = context1.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        DataRow row = (DataRow) artists.get(0);
+        assertEquals(2, list.lastIndexOf(row));
+
+        row.remove("ARTIST_NAME");
+        assertEquals(-1, list.lastIndexOf(row));
+    }
+
+    public void testLastIndexOf2() throws Exception {
+
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        query.setFetchingDataRows(true);
+        List<?> artists = context1.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        DataRow row = (DataRow) artists.get(0);
+        assertEquals(19, list.lastIndexOf(row));
+
+        row.remove("ARTIST_ID");
+        assertEquals(-1, list.lastIndexOf(row));
+    }
+
+    public void testIterator() throws Exception {
+        assertEquals(1, list.idWidth);
+
+        Iterator<?> it = list.iterator();
+        int counter = 0;
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertNotNull(obj);
+            assertTrue(
+                    "Unexpected object class: " + obj.getClass().getName(),
+                    obj instanceof DataRow);
+            assertEquals(3, ((DataRow) obj).size());
+
+            // iterator must be resolved page by page
+            int expectedResolved = list.pageIndex(counter)
+                    * list.getPageSize()
+                    + list.getPageSize();
+            if (expectedResolved > list.size()) {
+                expectedResolved = list.size();
+            }
+
+            assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects());
+
+            if (list.getUnfetchedObjects() >= list.getPageSize()) {
+                assertTrue(list.elements.get(list.size() - 1) instanceof Long);
+            }
+
+            counter++;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
deleted file mode 100644
index a1262e0..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListDataRowsTest.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.cayenne.DataRow;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.query.SortOrder;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-/**
- * Tests IncrementalFaultList behavior when fetching data rows.
- */
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class SimpleIdIncrementalFaultListDataRowsTest extends ServerCase {
-
-    @Inject
-    private DataContext context;
-
-    @Inject
-    private DataContext context1;
-
-    @Inject
-    private DBHelper dbHelper;
-
-    private TableHelper tArtist;
-    private SimpleIdIncrementalFaultList<?> list;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-        createArtistsDataSet();
-
-        SelectQuery q = new SelectQuery("Artist");
-        q.setPageSize(6);
-        q.setFetchingDataRows(true);
-        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
-
-        list = new SimpleIdIncrementalFaultList<Object>(context, q, 10000);
-    }
-
-    protected void createArtistsDataSet() throws Exception {
-        tArtist.insert(33001, "artist1");
-        tArtist.insert(33002, "artist2");
-        tArtist.insert(33003, "artist3");
-        tArtist.insert(33004, "artist4");
-        tArtist.insert(33005, "artist5");
-        tArtist.insert(33006, "artist6");
-        tArtist.insert(33007, "artist7");
-        tArtist.insert(33008, "artist8");
-        tArtist.insert(33009, "artist9");
-        tArtist.insert(33010, "artist10");
-        tArtist.insert(33011, "artist11");
-        tArtist.insert(33012, "artist12");
-        tArtist.insert(33013, "artist13");
-        tArtist.insert(33014, "artist14");
-        tArtist.insert(33015, "artist15");
-        tArtist.insert(33016, "artist16");
-        tArtist.insert(33017, "artist17");
-        tArtist.insert(33018, "artist18");
-        tArtist.insert(33019, "artist19");
-        tArtist.insert(33020, "artist20");
-        tArtist.insert(33021, "artist21");
-        tArtist.insert(33022, "artist22");
-        tArtist.insert(33023, "artist23");
-        tArtist.insert(33024, "artist24");
-        tArtist.insert(33025, "artist25");
-    }
-
-    public void testGet1() throws Exception {
-        assertEquals(1, list.idWidth);
-        assertTrue(list.elements.get(0) instanceof Long);
-        assertTrue(list.elements.get(19) instanceof Long);
-
-        Object a = list.get(19);
-
-        assertNotNull(a);
-        assertTrue(a instanceof DataRow);
-        assertEquals(3, ((DataRow) a).size());
-        assertEquals("artist20", ((DataRow) a).get("ARTIST_NAME"));
-    }
-
-    public void testIndexOf1() throws Exception {
-
-        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
-        SelectQuery query = new SelectQuery(Artist.class, qual);
-        query.setFetchingDataRows(true);
-        List<?> artists = context1.performQuery(query);
-
-        assertEquals(1, artists.size());
-
-        DataRow row = (DataRow) artists.get(0);
-        assertEquals(19, list.indexOf(row));
-
-        DataRow clone = new DataRow(row);
-        assertEquals(19, list.indexOf(clone));
-
-        row.remove("ARTIST_ID");
-        assertEquals(-1, list.indexOf(row));
-    }
-
-    public void testIndexOf2() throws Exception {
-
-        // resolve first page
-        list.get(0);
-
-        Expression qual = ExpressionFactory.matchExp("artistName", "artist2");
-        SelectQuery query = new SelectQuery(Artist.class, qual);
-        query.setFetchingDataRows(true);
-        List<?> artists = context1.performQuery(query);
-
-        assertEquals(1, artists.size());
-
-        DataRow row = (DataRow) artists.get(0);
-        assertEquals(1, list.indexOf(row));
-
-        row.remove("ARTIST_NAME");
-        assertEquals(-1, list.indexOf(row));
-    }
-
-    public void testLastIndexOf1() throws Exception {
-
-        // resolve first page
-        list.get(0);
-
-        Expression qual = ExpressionFactory.matchExp("artistName", "artist3");
-        SelectQuery query = new SelectQuery(Artist.class, qual);
-        query.setFetchingDataRows(true);
-        List<?> artists = context1.performQuery(query);
-
-        assertEquals(1, artists.size());
-
-        DataRow row = (DataRow) artists.get(0);
-        assertEquals(2, list.lastIndexOf(row));
-
-        row.remove("ARTIST_NAME");
-        assertEquals(-1, list.lastIndexOf(row));
-    }
-
-    public void testLastIndexOf2() throws Exception {
-
-        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
-        SelectQuery query = new SelectQuery(Artist.class, qual);
-        query.setFetchingDataRows(true);
-        List<?> artists = context1.performQuery(query);
-
-        assertEquals(1, artists.size());
-
-        DataRow row = (DataRow) artists.get(0);
-        assertEquals(19, list.lastIndexOf(row));
-
-        row.remove("ARTIST_ID");
-        assertEquals(-1, list.lastIndexOf(row));
-    }
-
-    public void testIterator() throws Exception {
-        assertEquals(1, list.idWidth);
-
-        Iterator<?> it = list.iterator();
-        int counter = 0;
-        while (it.hasNext()) {
-            Object obj = it.next();
-            assertNotNull(obj);
-            assertTrue(
-                    "Unexpected object class: " + obj.getClass().getName(),
-                    obj instanceof DataRow);
-            assertEquals(3, ((DataRow) obj).size());
-
-            // iterator must be resolved page by page
-            int expectedResolved = list.pageIndex(counter)
-                    * list.getPageSize()
-                    + list.getPageSize();
-            if (expectedResolved > list.size()) {
-                expectedResolved = list.size();
-            }
-
-            assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects());
-
-            if (list.getUnfetchedObjects() >= list.getPageSize()) {
-                assertTrue(list.elements.get(list.size() - 1) instanceof Long);
-            }
-
-            counter++;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListIT.java
new file mode 100644
index 0000000..ce4e4ea
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListIT.java
@@ -0,0 +1,292 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.cayenne.DataObject;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.Ordering;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SortOrder;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SimpleIdIncrementalFaultListIT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    private TableHelper tArtist;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+    }
+
+    protected void createArtistsDataSet() throws Exception {
+        tArtist.insert(33001, "artist1");
+        tArtist.insert(33002, "artist2");
+        tArtist.insert(33003, "artist3");
+        tArtist.insert(33004, "artist4");
+        tArtist.insert(33005, "artist5");
+        tArtist.insert(33006, "artist6");
+        tArtist.insert(33007, "artist7");
+        tArtist.insert(33008, "artist8");
+        tArtist.insert(33009, "artist9");
+        tArtist.insert(33010, "artist10");
+        tArtist.insert(33011, "artist11");
+        tArtist.insert(33012, "artist12");
+        tArtist.insert(33013, "artist13");
+        tArtist.insert(33014, "artist14");
+        tArtist.insert(33015, "artist15");
+        tArtist.insert(33016, "artist16");
+        tArtist.insert(33017, "artist17");
+        tArtist.insert(33018, "artist18");
+        tArtist.insert(33019, "artist19");
+        tArtist.insert(33020, "artist20");
+        tArtist.insert(33021, "artist21");
+        tArtist.insert(33022, "artist22");
+        tArtist.insert(33023, "artist23");
+        tArtist.insert(33024, "artist24");
+        tArtist.insert(33025, "artist25");
+    }
+
+    public void testRemoveDeleted() throws Exception {
+        createArtistsDataSet();
+
+        // DataContext context = createDataContext();
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.setPageSize(10);
+        SimpleIdIncrementalFaultList<Artist> list = new SimpleIdIncrementalFaultList<Artist>(
+                context,
+                query, 10000);
+
+        assertEquals(25, list.size());
+
+        Artist a1 = list.get(0);
+        context.deleteObjects(a1);
+        context.commitChanges();
+
+        list.remove(0);
+        assertEquals(24, list.size());
+    }
+
+    private SimpleIdIncrementalFaultList<?> prepareList(int pageSize) throws Exception {
+        createArtistsDataSet();
+
+        SelectQuery query = new SelectQuery(Artist.class);
+
+        // make sure total number of objects is not divisable
+        // by the page size, to test the last smaller page
+        query.setPageSize(pageSize);
+        query.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
+        return new SimpleIdIncrementalFaultList<Object>(context, query, 10000);
+    }
+
+    public void testSize() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        assertEquals(25, list.size());
+    }
+
+    public void testSmallList() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(49);
+        assertEquals(25, list.size());
+    }
+
+    public void testOnePageList() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(25);
+        assertEquals(25, list.size());
+    }
+
+    public void testIterator() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        Iterator<?> it = list.iterator();
+        int counter = 0;
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertNotNull(obj);
+            assertTrue(obj instanceof DataObject);
+
+            // iterator must be resolved page by page
+            int expectedResolved = list.pageIndex(counter)
+                    * list.getPageSize()
+                    + list.getPageSize();
+            if (expectedResolved > list.size()) {
+                expectedResolved = list.size();
+            }
+
+            assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects());
+
+            counter++;
+        }
+    }
+
+    public void testNewObject() throws Exception {
+
+        createArtistsDataSet();
+
+        Artist newArtist = context.newObject(Artist.class);
+        newArtist.setArtistName("x");
+        context.commitChanges();
+
+        SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class);
+        q.setPageSize(6);
+        q.addOrdering(Artist.ARTIST_NAME.asc());
+
+        SimpleIdIncrementalFaultList<?> list = new SimpleIdIncrementalFaultList<Object>(
+                context,
+                q, 10000);
+
+        assertSame(newArtist, list.get(25));
+    }
+
+    public void testListIterator() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        ListIterator<?> it = list.listIterator();
+        int counter = 0;
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertNotNull(obj);
+            assertTrue(obj instanceof DataObject);
+
+            // iterator must be resolved page by page
+            int expectedResolved = list.pageIndex(counter)
+                    * list.getPageSize()
+                    + list.getPageSize();
+            if (expectedResolved > list.size()) {
+                expectedResolved = list.size();
+            }
+
+            assertEquals(list.size() - expectedResolved, list.getUnfetchedObjects());
+
+            counter++;
+        }
+    }
+
+    public void testSort() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+
+        new Ordering(Artist.ARTIST_NAME_PROPERTY, SortOrder.DESCENDING).orderList(list);
+
+        Iterator<?> it = list.iterator();
+        Artist previousArtist = null;
+        while (it.hasNext()) {
+            Artist artist = (Artist) it.next();
+            if (previousArtist != null) {
+                assertTrue(previousArtist.getArtistName().compareTo(
+                        artist.getArtistName()) > 0);
+            }
+        }
+    }
+
+    public void testUnfetchedObjects() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        assertEquals(25, list.getUnfetchedObjects());
+        list.get(7);
+        assertEquals(25 - 6, list.getUnfetchedObjects());
+        list.resolveAll();
+        assertEquals(0, list.getUnfetchedObjects());
+    }
+
+    public void testPageIndex() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        assertEquals(0, list.pageIndex(0));
+        assertEquals(0, list.pageIndex(1));
+        assertEquals(1, list.pageIndex(6));
+
+        try {
+            assertEquals(13, list.pageIndex(82));
+            fail("Element index beyound array size must throw an IndexOutOfBoundsException.");
+        }
+        catch (IndexOutOfBoundsException ex) {
+            // exception expercted
+        }
+    }
+
+    public void testPagesRead1() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        assertTrue(list.elements.get(0) instanceof Long);
+        assertTrue(list.elements.get(8) instanceof Long);
+
+        list.resolveInterval(5, 10);
+        assertTrue(list.elements.get(7) instanceof Artist);
+
+        list.resolveAll();
+        assertTrue((list.elements.get(list.size() - 1)) instanceof Artist);
+    }
+
+    public void testGet1() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        assertTrue(list.elements.get(0) instanceof Long);
+        assertTrue(list.elements.get(8) instanceof Long);
+
+        Object a = list.get(8);
+
+        assertNotNull(a);
+        assertTrue(a instanceof Artist);
+        assertTrue(list.elements.get(8) instanceof Artist);
+    }
+
+    public void testIndexOf() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        List<?> artists = list.dataContext.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        Artist row = (Artist) artists.get(0);
+        assertEquals(19, list.indexOf(row));
+        assertEquals(-1, list.indexOf(list.dataContext.newObject("Artist")));
+    }
+
+    public void testLastIndexOf() throws Exception {
+        SimpleIdIncrementalFaultList<?> list = prepareList(6);
+        Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
+        SelectQuery query = new SelectQuery(Artist.class, qual);
+        List<?> artists = list.dataContext.performQuery(query);
+
+        assertEquals(1, artists.size());
+
+        Artist row = (Artist) artists.get(0);
+        assertEquals(19, list.lastIndexOf(row));
+        assertEquals(-1, list.lastIndexOf(list.dataContext.newObject("Artist")));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchIT.java
new file mode 100644
index 0000000..d0a1b6e
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchIT.java
@@ -0,0 +1,204 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+package org.apache.cayenne.access;
+
+import org.apache.cayenne.DataObject;
+import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.ValueHolder;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Painting;
+import org.apache.cayenne.unit.di.DataChannelInterceptor;
+import org.apache.cayenne.unit.di.UnitTestClosure;
+import org.apache.cayenne.unit.di.server.ServerCase;
+import org.apache.cayenne.unit.di.server.UseServerRuntime;
+
+import java.util.List;
+
+@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
+public class SimpleIdIncrementalFaultListPrefetchIT extends ServerCase {
+
+    @Inject
+    protected ObjectContext context;
+
+    @Inject
+    protected DBHelper dbHelper;
+
+    @Inject
+    protected DataChannelInterceptor queryInterceptor;
+
+    protected TableHelper tArtist;
+    protected TableHelper tPaining;
+
+    @Override
+    protected void setUpAfterInjection() throws Exception {
+        dbHelper.deleteAll("PAINTING_INFO");
+        dbHelper.deleteAll("PAINTING");
+        dbHelper.deleteAll("ARTIST_EXHIBIT");
+        dbHelper.deleteAll("ARTIST_GROUP");
+        dbHelper.deleteAll("ARTIST");
+
+        tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
+
+        tPaining = new TableHelper(dbHelper, "PAINTING");
+        tPaining.setColumns(
+                "PAINTING_ID",
+                "PAINTING_TITLE",
+                "ARTIST_ID",
+                "ESTIMATED_PRICE");
+    }
+
+    protected void createArtistsDataSet() throws Exception {
+        tArtist.insert(33001, "artist11");
+        tArtist.insert(33002, "artist12");
+        tArtist.insert(33003, "artist13");
+        tArtist.insert(33004, "artist14");
+        tArtist.insert(33005, "artist15");
+        tArtist.insert(33006, "artist16");
+        tArtist.insert(33007, "artist21");
+    }
+
+    protected void createArtistsAndPaintingsDataSet() throws Exception {
+        createArtistsDataSet();
+
+        tPaining.insert(33001, "P_artist11", 33001, 1000);
+        tPaining.insert(33002, "P_artist12", 33002, 2000);
+        tPaining.insert(33003, "P_artist13", 33003, 3000);
+        tPaining.insert(33004, "P_artist14", 33004, 4000);
+        tPaining.insert(33005, "P_artist15", 33005, 5000);
+        tPaining.insert(33006, "P_artist16", 33006, 11000);
+        tPaining.insert(33007, "P_artist21", 33007, 21000);
+    }
+
+    public void testListType() throws Exception {
+
+        createArtistsDataSet();
+
+        Expression e = ExpressionFactory.likeExp(Artist.ARTIST_NAME_PROPERTY, "artist1%");
+        SelectQuery q = new SelectQuery("Artist", e);
+        q.setPageSize(4);
+
+        List<?> result = context.performQuery(q);
+        assertTrue(result instanceof SimpleIdIncrementalFaultList);
+    }
+
+    /**
+     * Test that all queries specified in prefetch are executed with a single prefetch
+     * path.
+     */
+    public void testPrefetch1() throws Exception {
+
+        createArtistsAndPaintingsDataSet();
+
+        Expression e = ExpressionFactory.likeExp("artistName", "artist1%");
+        SelectQuery q = new SelectQuery("Artist", e);
+        q.addPrefetch("paintingArray");
+        q.setPageSize(3);
+
+        final IncrementalFaultList<?> result = (IncrementalFaultList) context
+                .performQuery(q);
+
+        assertEquals(6, result.size());
+
+        // currently queries with prefetch do not resolve their first page
+        assertEquals(result.size(), result.getUnfetchedObjects());
+
+        int count = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
+
+            public void execute() {
+                // go through the second page objects and count queries
+                for (int i = 3; i < 6; i++) {
+                    result.get(i);
+                }
+            }
+        });
+
+        // within the same page only one query should've been executed
+        assertEquals(1, count);
+    }
+
+    /**
+     * Test that a to-many relationship is initialized.
+     */
+    public void testPrefetch3() throws Exception {
+
+        createArtistsAndPaintingsDataSet();
+
+        Expression e = ExpressionFactory.likeExp("artistName", "artist1%");
+        SelectQuery q = new SelectQuery("Artist", e);
+        q.addPrefetch("paintingArray");
+        q.setPageSize(3);
+
+        IncrementalFaultList result = (IncrementalFaultList) context.performQuery(q);
+
+        assertEquals(6, result.size());
+
+        // currently queries with prefetch do not resolve their first page
+        assertEquals(result.size(), result.getUnfetchedObjects());
+
+        // go through the second page objects and check their to many
+        for (int i = 3; i < 6; i++) {
+            Artist a = (Artist) result.get(i);
+
+            List paintings = a.getPaintingArray();
+            assertFalse(((ValueHolder) paintings).isFault());
+            assertEquals(1, paintings.size());
+        }
+    }
+
+    /**
+     * Test that a to-one relationship is initialized.
+     */
+    public void testPrefetch4() throws Exception {
+
+        createArtistsAndPaintingsDataSet();
+
+        SelectQuery q = new SelectQuery(Painting.class);
+        q.setPageSize(3);
+        q.addPrefetch("toArtist");
+
+        IncrementalFaultList<?> result = (IncrementalFaultList) context.performQuery(q);
+
+        // get an objects from the second page
+        final DataObject p1 = (DataObject) result.get(q.getPageSize());
+
+        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+
+            public void execute() {
+                Object toOnePrefetch = p1.readNestedProperty("toArtist");
+                assertNotNull(toOnePrefetch);
+                assertTrue(
+                        "Expected DataObject, got: " + toOnePrefetch.getClass().getName(),
+                        toOnePrefetch instanceof DataObject);
+
+                DataObject a1 = (DataObject) toOnePrefetch;
+                assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
+            }
+        });
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e42c376c/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchTest.java
deleted file mode 100644
index bd73d0d..0000000
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/SimpleIdIncrementalFaultListPrefetchTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-
-package org.apache.cayenne.access;
-
-import java.util.List;
-
-import org.apache.cayenne.DataObject;
-import org.apache.cayenne.ObjectContext;
-import org.apache.cayenne.PersistenceState;
-import org.apache.cayenne.ValueHolder;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionFactory;
-import org.apache.cayenne.query.SelectQuery;
-import org.apache.cayenne.test.jdbc.DBHelper;
-import org.apache.cayenne.test.jdbc.TableHelper;
-import org.apache.cayenne.testdo.testmap.Artist;
-import org.apache.cayenne.testdo.testmap.Painting;
-import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
-import org.apache.cayenne.unit.di.server.ServerCase;
-import org.apache.cayenne.unit.di.server.UseServerRuntime;
-
-@UseServerRuntime(ServerCase.TESTMAP_PROJECT)
-public class SimpleIdIncrementalFaultListPrefetchTest extends ServerCase {
-
-    @Inject
-    protected ObjectContext context;
-
-    @Inject
-    protected DBHelper dbHelper;
-
-    @Inject
-    protected DataChannelInterceptor queryInterceptor;
-
-    protected TableHelper tArtist;
-    protected TableHelper tPaining;
-
-    @Override
-    protected void setUpAfterInjection() throws Exception {
-        dbHelper.deleteAll("PAINTING_INFO");
-        dbHelper.deleteAll("PAINTING");
-        dbHelper.deleteAll("ARTIST_EXHIBIT");
-        dbHelper.deleteAll("ARTIST_GROUP");
-        dbHelper.deleteAll("ARTIST");
-
-        tArtist = new TableHelper(dbHelper, "ARTIST");
-        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME");
-
-        tPaining = new TableHelper(dbHelper, "PAINTING");
-        tPaining.setColumns(
-                "PAINTING_ID",
-                "PAINTING_TITLE",
-                "ARTIST_ID",
-                "ESTIMATED_PRICE");
-    }
-
-    protected void createArtistsDataSet() throws Exception {
-        tArtist.insert(33001, "artist11");
-        tArtist.insert(33002, "artist12");
-        tArtist.insert(33003, "artist13");
-        tArtist.insert(33004, "artist14");
-        tArtist.insert(33005, "artist15");
-        tArtist.insert(33006, "artist16");
-        tArtist.insert(33007, "artist21");
-    }
-
-    protected void createArtistsAndPaintingsDataSet() throws Exception {
-        createArtistsDataSet();
-
-        tPaining.insert(33001, "P_artist11", 33001, 1000);
-        tPaining.insert(33002, "P_artist12", 33002, 2000);
-        tPaining.insert(33003, "P_artist13", 33003, 3000);
-        tPaining.insert(33004, "P_artist14", 33004, 4000);
-        tPaining.insert(33005, "P_artist15", 33005, 5000);
-        tPaining.insert(33006, "P_artist16", 33006, 11000);
-        tPaining.insert(33007, "P_artist21", 33007, 21000);
-    }
-
-    public void testListType() throws Exception {
-
-        createArtistsDataSet();
-
-        Expression e = ExpressionFactory.likeExp(Artist.ARTIST_NAME_PROPERTY, "artist1%");
-        SelectQuery q = new SelectQuery("Artist", e);
-        q.setPageSize(4);
-
-        List<?> result = context.performQuery(q);
-        assertTrue(result instanceof SimpleIdIncrementalFaultList);
-    }
-
-    /**
-     * Test that all queries specified in prefetch are executed with a single prefetch
-     * path.
-     */
-    public void testPrefetch1() throws Exception {
-
-        createArtistsAndPaintingsDataSet();
-
-        Expression e = ExpressionFactory.likeExp("artistName", "artist1%");
-        SelectQuery q = new SelectQuery("Artist", e);
-        q.addPrefetch("paintingArray");
-        q.setPageSize(3);
-
-        final IncrementalFaultList<?> result = (IncrementalFaultList) context
-                .performQuery(q);
-
-        assertEquals(6, result.size());
-
-        // currently queries with prefetch do not resolve their first page
-        assertEquals(result.size(), result.getUnfetchedObjects());
-
-        int count = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
-
-            public void execute() {
-                // go through the second page objects and count queries
-                for (int i = 3; i < 6; i++) {
-                    result.get(i);
-                }
-            }
-        });
-
-        // within the same page only one query should've been executed
-        assertEquals(1, count);
-    }
-
-    /**
-     * Test that a to-many relationship is initialized.
-     */
-    public void testPrefetch3() throws Exception {
-
-        createArtistsAndPaintingsDataSet();
-
-        Expression e = ExpressionFactory.likeExp("artistName", "artist1%");
-        SelectQuery q = new SelectQuery("Artist", e);
-        q.addPrefetch("paintingArray");
-        q.setPageSize(3);
-
-        IncrementalFaultList result = (IncrementalFaultList) context.performQuery(q);
-
-        assertEquals(6, result.size());
-
-        // currently queries with prefetch do not resolve their first page
-        assertEquals(result.size(), result.getUnfetchedObjects());
-
-        // go through the second page objects and check their to many
-        for (int i = 3; i < 6; i++) {
-            Artist a = (Artist) result.get(i);
-
-            List paintings = a.getPaintingArray();
-            assertFalse(((ValueHolder) paintings).isFault());
-            assertEquals(1, paintings.size());
-        }
-    }
-
-    /**
-     * Test that a to-one relationship is initialized.
-     */
-    public void testPrefetch4() throws Exception {
-
-        createArtistsAndPaintingsDataSet();
-
-        SelectQuery q = new SelectQuery(Painting.class);
-        q.setPageSize(3);
-        q.addPrefetch("toArtist");
-
-        IncrementalFaultList<?> result = (IncrementalFaultList) context.performQuery(q);
-
-        // get an objects from the second page
-        final DataObject p1 = (DataObject) result.get(q.getPageSize());
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Object toOnePrefetch = p1.readNestedProperty("toArtist");
-                assertNotNull(toOnePrefetch);
-                assertTrue(
-                        "Expected DataObject, got: " + toOnePrefetch.getClass().getName(),
-                        toOnePrefetch instanceof DataObject);
-
-                DataObject a1 = (DataObject) toOnePrefetch;
-                assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
-            }
-        });
-    }
-
-}


Mime
View raw message