db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r575364 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/BinaryDecimal.java testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java testing/org/apache/derbyTesting/junit/JDBC.java
Date Thu, 13 Sep 2007 16:41:33 GMT
Author: myrnavl
Date: Thu Sep 13 09:41:26 2007
New Revision: 575364

URL: http://svn.apache.org/viewvc?rev=575364&view=rev
Log:
DERBY-3057 - enabling test TableFunctionTest.java to run with j2ME/CDC/JSR169.
- adjusted method equals(Object) in junit.JDBC$GeneratedID to implement
  a similar check for JSR169 as is achieved with String.matches() (which is
  not available with JSR169)
- implemented method BinaryDecimal.setValueFromResultSet() which gets executed
  by the test (also adjusted javadoc referring to non-existing CDCDecimal)
- adjusted test TableFunctionTest to call an appropriate method instead of
  ResultSet.getBigDecimal() (which is not available with JSR169).


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java?rev=575364&r1=575363&r2=575364&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BinaryDecimal.java Thu Sep
13 09:41:26 2007
@@ -36,7 +36,7 @@
 
 /**
  * SQL DECIMAL using raw data. Provides the basis for the
- * CDCDecimal implementation.
+ * BigIntegerDecimal implementation.
  * <P>
  * The on-disk format must match the SQLDecimal format so that
  * databases are portable across J2ME and J2SE environments.
@@ -372,7 +372,7 @@
 	 * @param result	The result of a previous call to this method, null
 	 *					if not called yet
 	 *
-	 * @return	A SQLDecimal containing the result of the addition
+	 * @return	A BinaryDecimal containing the result of the addition
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
@@ -686,9 +686,9 @@
 	 * @see org.apache.derby.iapi.types.DataValueDescriptor#setValueFromResultSet(java.sql.ResultSet,
int, boolean)
 	 */
 	public void setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable)
throws StandardException, SQLException {
-		// TODO Auto-generated method stub
-		throw StandardException.newException(SQLState.NOT_IMPLEMENTED);
-		
+		// using DataType.setValue(String), which should be implemented
+		// by the implementing class.
+		setValue(resultSet.getString(colNumber));
 	}
 
 	/* (non-Javadoc)

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java?rev=575364&r1=575363&r2=575364&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TableFunctionTest.java
Thu Sep 13 09:41:26 2007
@@ -1404,10 +1404,17 @@
 
                 case Types.DECIMAL:
                 case Types.NUMERIC:
-                    actualValue = squeezeString(  rs.getBigDecimal( column ) );
-                    actualValueByName = squeezeString(  rs.getBigDecimal( columnName ) );
-                    break;
-
+                    // with JSR169, we cannot execute resultSet.getBigDecimal...
+                    if (JDBC.vmSupportsJDBC3()) {
+                        actualValue = squeezeString(  rs.getBigDecimal( column ) );
+                        actualValueByName = squeezeString(  rs.getBigDecimal( columnName
) );
+                        break;
+                    }
+                    else {
+                        actualValue = squeezeString(  rs.getString( column ) );
+                        actualValueByName = squeezeString(  rs.getString( columnName ) );
+                        break;
+                    }
                 case Types.DATE:
                     actualValue = squeezeString(  rs.getDate( column ) );
                     actualValueByName = squeezeString(  rs.getDate( columnName ) );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?rev=575364&r1=575363&r2=575364&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Thu Sep 13 09:41:26
2007
@@ -46,8 +46,34 @@
      */
     public static class GeneratedId {
         public boolean equals(Object o) {
-            return o instanceof String &&
+            // unless JSR169, use String.matches...
+            if (JDBC.vmSupportsJDBC3()) 
+            {
+                return o instanceof String &&
                 ((String) o).matches("SQL[0-9]{15}");
+            }
+            else
+            {
+                String tmpstr = (String)o;
+                boolean b = true;
+                if (!(o instanceof String))
+                    b = false;
+                if (!(tmpstr.startsWith("SQL")))
+                    b = false;
+                if (tmpstr.length() != 18)
+                    b = false;
+                for (int i=3 ; i<18 ; i++)
+                {
+                    if (Character.isDigit(tmpstr.charAt(i)))
+                        continue;
+                    else
+                    {
+                        b = false;
+                        break;
+                    }
+                }
+            return b;
+            }
         }
         public String toString() {
             return "xxxxGENERATED-IDxxxx";



Mime
View raw message