harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r514992 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/rowset/serial/ main/java/org/apache/harmony/sql/internal/nls/ test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/
Date Tue, 06 Mar 2007 05:50:55 GMT
Author: smishura
Date: Mon Mar  5 21:50:55 2007
New Revision: 514992

URL: http://svn.apache.org/viewvc?view=rev&rev=514992
Log:
Apply patch for HARMONY-3271:
[classlib][sql] Implementation for SerialClob.getSubString(long, int)

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java?view=diff&rev=514992&r1=514991&r2=514992
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
Mon Mar  5 21:50:55 2007
@@ -102,9 +102,14 @@
         return new CharArrayReader(buf);
     }
 
-    public String getSubString(long pos, int length) throws SerialException,
-            NotImplementedException {
-        throw new NotImplementedException();
+    public String getSubString(long pos, int length) throws SerialException {
+        if (pos < 1 || pos > len) {
+            throw new SerialException(Messages.getString("sql.21")); // $NON-NLS-1$
+        }
+        if (length < 0 || length > len) {
+            throw new SerialException(Messages.getString("sql.22")); // $NON-NLS-1$
+        }
+        return new String(buf, (int) (pos - 1), length);
     }
 
     public long position(Clob searchstr, long start) throws SerialException,

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties?view=diff&rev=514992&r1=514991&r2=514992
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
Mon Mar  5 21:50:55 2007
@@ -34,4 +34,6 @@
 sql.17=javax.sql.rowset.serial.SerialException: Length more than what can be truncated
 sql.18=Unsupported operation. SerialBlob cannot return a writable binary stream, unless instantiated
with a Blob object that provides a setBinaryStream() implementation
 sql.19=Cannot instantiate a SerialClob object with a null Clob object
-sql.20=Invalid Clob object. Calls to getCharacterStream or getAsciiStream return null which
cannot be serialized.
\ No newline at end of file
+sql.20=Invalid Clob object. Calls to getCharacterStream or getAsciiStream return null which
cannot be serialized.
+sql.21=Invalid position in BLOB object set
+sql.22=Invalid position and substring length

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java?view=diff&rev=514992&r1=514991&r2=514992
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
Mon Mar  5 21:50:55 2007
@@ -105,8 +105,45 @@
         // TODO: Not yet implemented
     }
 
-    public void testGetSubString() {
-        // TODO: Not yet implemented
+    public void testGetSubString() throws Exception {
+        String s = "hello";
+        char[] buf = s.toCharArray();
+        SerialClob serialClob = new SerialClob(buf);
+
+        String sub = serialClob.getSubString(1, 5);
+        assertEquals("hello", sub);
+
+        sub = serialClob.getSubString(2, 3);
+        assertEquals("ell", sub);
+
+        try {
+            sub = serialClob.getSubString(0, 6);
+            fail("should throw SerialException");
+        } catch (SerialException e) {
+            // expected
+        }
+        
+        try {
+            sub = serialClob.getSubString(7, 1);
+            fail("should throw SerialException");
+        } catch (SerialException e) {
+            // expected
+        }
+        
+        try {
+            sub = serialClob.getSubString(1, 7);
+            fail("should throw SerialException");
+        } catch (SerialException e) {
+            // expected
+        }
+        
+        try {
+            sub = serialClob.getSubString(1, -2);
+            fail("should throw SerialException");
+        } catch (SerialException e) {
+            // expected
+        }
+
     }
 
     public void testPositionLClobJ() {



Mime
View raw message