Package org.apache.harmony.sql.internal.rowset

Examples of org.apache.harmony.sql.internal.rowset.SyncResolverImpl


    public void testGetConflictValue() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        // before call nextConflict
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid cursor position
        }

        try {
            resolver.getConflictValue(-1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column index
        }
        try {
            resolver.getConflictValue("not exist");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column name
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertFalse(resolver.nextConflict());
        assertEquals(0, resolver.getRow());

        /*
         * ri throw SQLException after call nextConflict again, it's not
         * reasonable
         */
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected Invalid cursor position
        }

View Full Code Here


    public void testNextPreviousConflict() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        assertTrue(resolver.nextConflict());
        assertTrue(resolver.nextConflict());
        assertFalse(resolver.nextConflict());
        assertFalse(resolver.nextConflict());

        assertTrue(resolver.previousConflict());
        assertTrue(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
    }
View Full Code Here

    public void testGetStatus() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertFalse(resolver.nextConflict());

        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
View Full Code Here

        // } catch (SyncProviderException e) {
        // ex = e;
        // }
        //
        // SyncResolver resolver = ex.getSyncResolver();
        SyncResolver resolver = new SyncResolverImpl(null);

        try {
            resolver.absolute(1);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.relative(1);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.next();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.previous();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.isAfterLast();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.isBeforeFirst();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.isFirst();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.isLast();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
        try {
            resolver.getMetaData();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.getString(2);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.getCursorName();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.updateString(2, "hello");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.rowDeleted();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.rowInserted();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.rowUpdated();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.getWarnings();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.getStatement();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.findColumn("ID");
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.wasNull();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.moveToCurrentRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.moveToInsertRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.refreshRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.execute();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.clearWarnings();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.deleteRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.insertRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.updateRow();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.cancelRowUpdates();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }

        try {
            resolver.close();
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }
View Full Code Here

    public void testGetConflictValue() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        // before call nextConflict
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid cursor position
        }

        try {
            resolver.getConflictValue(-1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column index
        }
        try {
            resolver.getConflictValue("not exist");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column name
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertFalse(resolver.nextConflict());
        assertEquals(0, resolver.getRow());

        /*
         * ri throw SQLException after call nextConflict again, it's not
         * reasonable
         */
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected Invalid cursor position
        }

View Full Code Here

    public void testNextPreviousConflict() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        assertTrue(resolver.nextConflict());
        assertTrue(resolver.nextConflict());
        assertFalse(resolver.nextConflict());
        assertFalse(resolver.nextConflict());

        assertTrue(resolver.previousConflict());
        assertTrue(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
    }
View Full Code Here

    public void testGetStatus() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);
       
        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertFalse(resolver.nextConflict());

        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
View Full Code Here

    public void testGetConflictValue() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        // before call nextConflict
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid cursor position
        }

        try {
            resolver.getConflictValue(-1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column index
        }
        try {
            resolver.getConflictValue("not exist");
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected, Invalid column name
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertTrue(resolver.nextConflict());

        for (int i = 1; i <= DEFAULT_COLUMN_COUNT; ++i) {
            assertNull(resolver.getConflictValue(i));
        }

        assertFalse(resolver.nextConflict());
        assertEquals(0, resolver.getRow());

        /*
         * ri throw SQLException after call nextConflict again, it's not
         * reasonable
         */
        try {
            resolver.getConflictValue(1);
            fail("Should throw SQLException");
        } catch (SQLException e) {
            // expected Invalid cursor position
        }

View Full Code Here

    public void testNextPreviousConflict() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        assertTrue(resolver.nextConflict());
        assertTrue(resolver.nextConflict());
        assertFalse(resolver.nextConflict());
        assertFalse(resolver.nextConflict());

        assertTrue(resolver.previousConflict());
        assertTrue(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
        assertFalse(resolver.previousConflict());
    }
View Full Code Here

    public void testGetStatus() throws Exception {

        RowSetMetaData metadata = new RowSetMetaDataImpl();
        metadata.setColumnCount(DEFAULT_COLUMN_COUNT);

        SyncResolverImpl resolver = new SyncResolverImpl(metadata);
        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1,
                SyncResolver.INSERT_ROW_CONFLICT);

        resolver.addConflictRow(
                new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2,
                SyncResolver.INSERT_ROW_CONFLICT);

        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }

        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertTrue(resolver.nextConflict());
        assertEquals(SyncResolver.INSERT_ROW_CONFLICT, resolver.getStatus());
        assertFalse(resolver.nextConflict());

        try {
            resolver.getStatus();
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
View Full Code Here

TOP

Related Classes of org.apache.harmony.sql.internal.rowset.SyncResolverImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.