You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2008/05/31 10:59:06 UTC
svn commit: r661980 - in
/harmony/enhanced/classlib/branches/java6/modules/sql/src:
main/java/org/apache/harmony/sql/internal/rowset/
test/java/org/apache/harmony/sql/tests/internal/rowset/
Author: qiuxx
Date: Sat May 31 01:59:06 2008
New Revision: 661980
URL: http://svn.apache.org/viewvc?rev=661980&view=rev
Log:
Apply patch for HARMONY-5849,([java6][classlib][sql][rowset] - implement new API in CachedRowSetImpl)
Added:
harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java (with props)
harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java (with props)
Modified:
harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java?rev=661980&r1=661979&r2=661980&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/org/apache/harmony/sql/internal/rowset/CachedRowSetImpl.java Sat May 31 01:59:06 2008
@@ -38,6 +38,7 @@
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
@@ -77,7 +78,6 @@
import javax.sql.rowset.spi.SyncProvider;
import javax.sql.rowset.spi.SyncProviderException;
-import org.apache.harmony.luni.util.NotImplementedException;
import org.apache.harmony.sql.internal.nls.Messages;
public class CachedRowSetImpl extends BaseRowSet implements CachedRowSet,
@@ -271,7 +271,8 @@
conn = connection;
if (conn == null) {
- throw new SyncProviderException();
+ // rowset.31=No current connection
+ throw new SyncProviderException(Messages.getString("rowset.31")); //$NON-NLS-1$
}
boolean isShowDeleted = false;
@@ -2510,11 +2511,13 @@
}
public void updateBlob(int columnIndex, Blob x) throws SQLException {
- updateByType(columnIndex, x);
+ // sql.37=Operation not supported
+ throw new SQLException(Messages.getString("sql.37")); //$NON-NLS-1$
}
public void updateBlob(String columnName, Blob x) throws SQLException {
- updateBlob(getIndexByName(columnName), x);
+ // sql.37=Operation not supported
+ throw new SQLException(Messages.getString("sql.37")); //$NON-NLS-1$
}
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
@@ -2582,11 +2585,13 @@
}
public void updateClob(int columnIndex, Clob x) throws SQLException {
- updateByType(columnIndex, x);
+ // sql.37=Operation not supported
+ throw new SQLException(Messages.getString("sql.37")); //$NON-NLS-1$
}
public void updateClob(String columnName, Clob x) throws SQLException {
- updateClob(getIndexByName(columnName), x);
+ // sql.37=Operation not supported
+ throw new SQLException(Messages.getString("sql.37")); //$NON-NLS-1$
}
public void updateDate(int columnIndex, Date x) throws SQLException {
@@ -3052,209 +3057,235 @@
return currentRow;
}
- public void updateNCharacterStream(String columnLabel, Reader reader){
- throw new NotImplementedException();
+ public void updateNCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateNCharacterStream(int columnIndex, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
}
-
- public void updateNCharacterStream(int columnIndex, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateNCharacterStream(String columnLabel, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateNCharacterStream(int columnIndex, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateCharacterStream(int columnIndex, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateCharacterStream(String columnLabel, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateCharacterStream(int columnIndex, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateBinaryStream(String columnLabel, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateBinaryStream(int columnIndex, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateBinaryStream(String columnLabel, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateBinaryStream(int columnIndex, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateRowId(String columnLabel, RowId x){
- throw new NotImplementedException();
- }
-
- public void updateRowId(int columnIndex, RowId x){
- throw new NotImplementedException();
- }
-
- public void updateNClob(String columnLabel, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateNClob(int columnIndex, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateNClob(String columnLabel, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateNClob(int columnIndex, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateNClob(String columnLabel, NClob nClob){
- throw new NotImplementedException();
- }
-
- public void updateNClob(int columnIndex, NClob nClob){
- throw new NotImplementedException();
- }
-
- public void updateNString(String columnLabel, String nString){
- throw new NotImplementedException();
- }
-
- public void updateNString(int columnIndex, String nString){
- throw new NotImplementedException();
- }
-
- public void updateAsciiStream(String columnLabel, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateAsciiStream(int columnIndex, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateAsciiStream(String columnLabel, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateAsciiStream(int columnIndex, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateSQLXML(String columnLabel, SQLXML xmlObject){
- throw new NotImplementedException();
- }
-
- public void updateSQLXML(int columnIndex, SQLXML xmlObject){
- throw new NotImplementedException();
- }
-
- public void updateBlob(String columnLabel, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateBlob(int columnIndex, InputStream stream){
- throw new NotImplementedException();
- }
-
- public void updateBlob(String columnLabel, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateBlob(int columnIndex, InputStream stream, long x){
- throw new NotImplementedException();
- }
-
- public void updateClob(String columnLabel, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateClob(int columnIndex, Reader reader){
- throw new NotImplementedException();
- }
-
- public void updateClob(String columnLabel, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public void updateClob(int columnIndex, Reader reader, long x){
- throw new NotImplementedException();
- }
-
- public String getNString(int columnIndex){
- throw new NotImplementedException();
- }
-
- public String getNString(String columnLabel){
- throw new NotImplementedException();
- }
-
- public RowId getRowId(int columnIndex){
- throw new NotImplementedException();
- }
-
- public RowId getRowId(String columnLabel){
- throw new NotImplementedException();
- }
-
- public boolean isWrapperFor(Class<?> iface){
- throw new NotImplementedException();
- }
-
- public Reader getNCharacterStream(int columnIndex){
- throw new NotImplementedException();
- }
-
- public Reader getNCharacterStream(String columnLabel){
- throw new NotImplementedException();
- }
-
- public <T> T unwrap(Class<T> iface){
- throw new NotImplementedException();
- }
-
- public int getHoldability(){
- throw new NotImplementedException();
+
+ public void updateNCharacterStream(String columnLabel, Reader reader, long x) {
+ throw new UnsupportedOperationException();
}
- public NClob getNClob(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
+ public void updateNCharacterStream(int columnIndex, Reader reader, long x)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateCharacterStream(int columnIndex, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateCharacterStream(String columnLabel, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateCharacterStream(int columnIndex, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBinaryStream(String columnLabel, InputStream stream)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBinaryStream(int columnIndex, InputStream stream)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBinaryStream(String columnLabel, InputStream stream,
+ long x) throws SQLException {
+ updateBinaryStream(getIndexByName(columnLabel), stream, x);
+ }
+
+ public void updateBinaryStream(int columnIndex, InputStream stream, long x)
+ throws SQLException {
+ // do nothing. Follow RI.
+ }
+
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(String columnLabel, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(String columnLabel, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(int columnIndex, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateNClob(String columnLabel, NClob nClob)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNString(String columnLabel, String nString)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNString(int columnIndex, String nString)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(String columnLabel, InputStream stream)
+ throws SQLException {
+ // do nothing. Follow RI.
+ }
+
+ public void updateAsciiStream(int columnIndex, InputStream stream)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateAsciiStream(String columnLabel, InputStream stream, long x)
+ throws SQLException {
+ updateAsciiStream(getIndexByName(columnLabel), stream, x);
+ }
+
+ public void updateAsciiStream(int columnIndex, InputStream stream, long x)
+ throws SQLException {
+ // RI doesn't implement this method, and it doesn't throw any exception
+ // either.
+ }
+
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject)
+ throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(String columnLabel, InputStream stream)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBlob(int columnIndex, InputStream stream)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBlob(String columnLabel, InputStream stream, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateBlob(int columnIndex, InputStream stream, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(String columnLabel, Reader reader)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(String columnLabel, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public void updateClob(int columnIndex, Reader reader, long x)
+ throws SQLException {
+ throw new SQLFeatureNotSupportedException();
+ }
+
+ public String getNString(int columnIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNString(String columnLabel) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
}
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
public NClob getNClob(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException();
}
public SQLXML getSQLXML(int columnIndex) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException();
}
public SQLXML getSQLXML(String columnLabel) throws SQLException {
- // TODO Auto-generated method stub
- return null;
+ throw new UnsupportedOperationException();
}
public boolean isClosed() throws SQLException {
- // TODO Auto-generated method stub
- return false;
+ throw new UnsupportedOperationException();
}
@Override
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java?rev=661980&r1=661979&r2=661980&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetImplTest.java Sat May 31 01:59:06 2008
@@ -1551,7 +1551,7 @@
noInitialCrset.insertRow();
}
noInitialCrset.moveToCurrentRow();
- crset.setTableName("USER_INFO");
+ noInitialCrset.setTableName("USER_INFO");
noInitialCrset.acceptChanges(conn);
// check the new rows in CachedRowSet
assertEquals(20, noInitialCrset.size());
Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java?rev=661980&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java (added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java Sat May 31 01:59:06 2008
@@ -0,0 +1,279 @@
+/*
+ * 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.harmony.sql.tests.internal.rowset;
+
+import java.io.StringReader;
+import java.sql.ResultSet;
+import java.sql.SQLFeatureNotSupportedException;
+
+public class CachedRowSetNewFeatureTest extends CachedRowSetTestCase {
+
+ public void testGetHoldability() throws Exception {
+ assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, rs.getHoldability());
+
+ try {
+ crset.getHoldability();
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetNCharacterStream() throws Exception {
+ try {
+ crset.getNCharacterStream(100);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getNCharacterStream(2);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetNCharacterStream_StringParam() throws Exception {
+ try {
+ crset.getNCharacterStream("Invalid");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getNCharacterStream("NAME");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetNClob() throws Exception {
+ try {
+ crset.getNClob(100);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getNClob(2);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetNString() throws Exception {
+ try {
+ crset.getNString(100);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getNString(2);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetRowId() throws Exception {
+ try {
+ crset.getRowId(100);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getRowId(2);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetSQLXML() throws Exception {
+ try {
+ crset.getSQLXML(100);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getSQLXML(2);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testGetSQLXML_StringParam() throws Exception {
+ try {
+ crset.getSQLXML("invalid");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.first());
+ try {
+ crset.getSQLXML("NAME");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testIsClosed() throws Exception {
+ assertFalse(rs.isClosed());
+ rs.close();
+ assertTrue(rs.isClosed());
+
+ assertTrue(crset.first());
+ try {
+ crset.isClosed();
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testUpdateNCharacterStream() throws Exception {
+ try {
+ crset.updateNCharacterStream(2, null);
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+
+ try {
+ crset.updateNCharacterStream(2, null, 100L);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.absolute(3));
+
+ try {
+ crset.updateNCharacterStream(2, new StringReader("readstr"));
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+ try {
+ crset.updateNCharacterStream(2, new StringReader("readstr"), 100L);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testUpdateNClob() throws Exception {
+ try {
+ crset.updateNClob(2, new StringReader("readstr"));
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+ try {
+ crset.updateNClob(100, new StringReader("readstr"), 1000L);
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+
+ assertTrue(crset.absolute(3));
+ try {
+ crset.updateNClob(2, new StringReader("readstr"));
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+ try {
+ crset.updateNClob(100, new StringReader("readstr"), 1000L);
+ fail("should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // expected
+ }
+ }
+
+ public void testUpdateNString() throws Exception {
+ try {
+ crset.updateNString(2, "nstring");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.absolute(3));
+ try {
+ crset.updateNString(2, "nstring");
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testUpdateRowId() throws Exception {
+ try {
+ crset.updateRowId(2, null);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.absolute(3));
+ try {
+ crset.updateRowId(2, null);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ public void testUpdateSQLXML() throws Exception {
+ try {
+ crset.updateSQLXML(2, null);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+
+ assertTrue(crset.absolute(3));
+ try {
+ crset.updateSQLXML(2, null);
+ fail("should throw UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+}
Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetNewFeatureTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java?rev=661980&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java (added)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java Sat May 31 01:59:06 2008
@@ -0,0 +1,280 @@
+/*
+ * 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.harmony.sql.tests.internal.rowset;
+
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+
+public class CachedRowSetXlobTest extends JoinRowSetTestCase {
+
+ public void setUp() throws Exception {
+ super.setUp();
+ createBlobTable();
+ }
+
+ public void createBlobTable() throws SQLException {
+ st = conn.createStatement();
+ rs = conn.getMetaData().getTables(null, "APP", "LOBTABLE", null);
+ String createTableSQL = "create table LOBTABLE (ID INTEGER NOT NULL, blobValue blob, clobValue clob)";
+
+ if (rs.next()) {
+ st.execute("drop table LOBTABLE");
+ }
+
+ st.execute(createTableSQL);
+ }
+
+ public void testUpdateBlob_NullParameter() throws Exception {
+ try {
+ crset.updateBlob(100, null, 10);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob(100, null, 10);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ }
+
+ public void testUpdateBlob_CachedRowSet() throws Exception {
+ crset = newNoInitialInstance();
+ byte[] buf = { 1, 2, 3, 4 };
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(buf);
+
+ try {
+ crset.updateBlob(2, inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob(2, inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ try {
+ crset.updateBlob(100, inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob(100, inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ try {
+ crset.updateBlob("blobValue", inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob("invalidName", inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ try {
+ crset.updateBlob("invalidName", inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob("blobValue", inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ rs = st.executeQuery("select * from LobTable");
+ crset.populate(rs);
+ crset.moveToInsertRow();
+ crset.updateInt(1, 1);
+
+ try {
+ crset.updateBlob(2, inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob(2, inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ try {
+ crset.updateBlob(100, inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob(100, inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+
+ try {
+ crset.updateBlob("blobValue", inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob("blobValue", inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob("invalidName", inputStream);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateBlob("invalidName", inputStream, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ crset.insertRow();
+ crset.moveToCurrentRow();
+ crset.first();
+
+ assertEquals(1, crset.getInt(1));
+ assertNull(crset.getBlob(2));
+ }
+
+ public void testUpdateClob_CachedRowSet() throws Exception {
+ crset = newNoInitialInstance();
+ char[] buf = { 1, 2, 3, 4 };
+ CharArrayReader reader = new CharArrayReader(buf);
+ try {
+ crset.updateClob(3, reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob(3, reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob(100, reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob(100, reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("clobValue", reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("clobValue", reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("invalidValue", reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("invalidValue", reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ rs = st.executeQuery("select * from LobTable");
+ crset.populate(rs);
+ crset.moveToInsertRow();
+ crset.updateInt(1, 1);
+
+ try {
+ crset.updateClob(3, reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob(3, reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("clobValue", reader);
+ fail("Should throw SQLFeatureNotSupportedException");
+
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ try {
+ crset.updateClob("clobValue", reader, 2);
+ fail("Should throw SQLFeatureNotSupportedException");
+ } catch (SQLFeatureNotSupportedException e) {
+ // Expected.
+ }
+ crset.insertRow();
+ crset.moveToCurrentRow();
+ crset.first();
+
+ assertEquals(1, crset.getInt(1));
+ assertNull(crset.getClob(3));
+ }
+}
Propchange: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/internal/rowset/CachedRowSetXlobTest.java
------------------------------------------------------------------------------
svn:eol-style = native