db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1199392 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Tue, 08 Nov 2011 19:16:46 GMT
Author: rhillegas
Date: Tue Nov  8 19:16:46 2011
New Revision: 1199392

URL: http://svn.apache.org/viewvc?rev=1199392&view=rev
Log:
DERBY-5488: Eliminate some NPEs in ParameterMappingTest when run on OJEC.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java?rev=1199392&r1=1199391&r2=1199392&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/BigIntegerDecimal.java Tue
Nov  8 19:16:46 2011
@@ -21,6 +21,7 @@
 
 package org.apache.derby.iapi.types;
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Types;
 
@@ -195,6 +196,12 @@ public final class BigIntegerDecimal ext
 	}
 	
 	
+	public Object	getObject() throws StandardException
+	{
+		if ( isNull() ) { return null; }
+        else { return new BigDecimal( getString() ); }
+	}
+
 	/* (non-Javadoc)
 	 * @see org.apache.derby.iapi.types.DataValueDescriptor#getString()
 	 */
@@ -526,6 +533,16 @@ public final class BigIntegerDecimal ext
 		}
 		return bi;
 	}
+    
+	public void setBigDecimal(Number theValue) throws StandardException
+	{
+        if ( theValue == null ) { setToNull(); }
+		else
+        {
+            setValue( theValue.toString() );
+        }
+	}
+    
 	/*
 	 * String display of value
 	 */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java?rev=1199392&r1=1199391&r2=1199392&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/J2SEDataValueFactory.java
Tue Nov  8 19:16:46 2011
@@ -39,9 +39,6 @@ public class J2SEDataValueFactory extend
 
    	public void boot(boolean create, Properties properties) throws StandardException {
    		
-   		NumberDataType.MINLONG_MINUS_ONE = SQLDecimal.MINLONG_MINUS_ONE;
-   		NumberDataType.MAXLONG_PLUS_ONE = SQLDecimal.MAXLONG_PLUS_ONE;
-
     	super.boot(create, properties);
    	}
 	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java?rev=1199392&r1=1199391&r2=1199392&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/NumberDataType.java Tue Nov
 8 19:16:46 2011
@@ -21,6 +21,8 @@
 
 package org.apache.derby.iapi.types;
 
+import java.math.BigDecimal;
+
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.types.NumberDataValue;
 import org.apache.derby.iapi.services.sanity.SanityManager;
@@ -48,14 +50,10 @@ public abstract class NumberDataType ext
 	 */
 	static DataValueDescriptor ZERO_DECIMAL;
 	
-	/**
-	 * Set by the booting DataValueFactory implementation.
-	 */
-	static Comparable MINLONG_MINUS_ONE;
-	/**
-	 * Set by the booting DataValueFactory implementation.
-	 */
-	static Comparable MAXLONG_PLUS_ONE;
+	static final BigDecimal ZERO = BigDecimal.valueOf(0L);
+	static final BigDecimal ONE = BigDecimal.valueOf(1L);
+	static final BigDecimal MAXLONG_PLUS_ONE = BigDecimal.valueOf(Long.MAX_VALUE).add(ONE);
+	static final BigDecimal MINLONG_MINUS_ONE = BigDecimal.valueOf(Long.MIN_VALUE).subtract(ONE);
 
     /**
      * Numbers check for isNegative first and negate it if negative.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java?rev=1199392&r1=1199391&r2=1199392&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLDecimal.java Tue Nov  8
19:16:46 2011
@@ -67,13 +67,6 @@ import java.sql.Types;
  */
 public final class SQLDecimal extends NumberDataType implements VariableSizeDataValue
 {
-	private static final BigDecimal ZERO = BigDecimal.valueOf(0L);
-	private static final BigDecimal ONE = BigDecimal.valueOf(1L);
-	static final BigDecimal MAXLONG_PLUS_ONE = BigDecimal.valueOf(Long.MAX_VALUE).add(ONE);
-	static final BigDecimal MINLONG_MINUS_ONE = BigDecimal.valueOf(Long.MIN_VALUE).subtract(ONE);
-
-
-
 	/**
 	 * object state.  Note that scale and precision are 
 	 * always determined dynamically from value when
@@ -236,8 +229,8 @@ public final class SQLDecimal extends Nu
 		// e.g. 9223372036854775807.1  converts to 9223372036854775807
 		// this matches DB2 UDB behaviour
 
-		if (   (localValue.compareTo(SQLDecimal.MINLONG_MINUS_ONE) == 1)
-			&& (localValue.compareTo(SQLDecimal.MAXLONG_PLUS_ONE) == -1)) {
+		if (   (localValue.compareTo(MINLONG_MINUS_ONE) == 1)
+			&& (localValue.compareTo(MAXLONG_PLUS_ONE) == -1)) {
 
 			return localValue.longValue();
 		}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java?rev=1199392&r1=1199391&r2=1199392&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
Tue Nov  8 19:16:46 2011
@@ -563,7 +563,7 @@ public class ParameterMappingTest extend
             try {
                 if (!HAVE_BIG_DECIMAL && SQLTypes[type].equals("DECIMAL(10,5)"))
                     continue;
-                //System.out.println(procSQL);
+                println(procSQL);
                 s.execute(procSQL);
             } catch (SQLException sqle) {
                 // may get error that column is not allowed
@@ -1090,7 +1090,8 @@ public class ParameterMappingTest extend
         }
         catch (SQLException se )
         {
-            assertEquals( errorState, se.getSQLState() );
+            assertEquals
+                ( "Expecting failure for seed = " + seed + " and insertText = '" + insertText
+ "'" , errorState, se.getSQLState() );
         }
     }
 
@@ -4292,11 +4293,7 @@ public class ParameterMappingTest extend
     
     public static Test suite() {
         
-        // Don't run for JSR169 until DERBY-2403 is resolved.
-        if (JDBC.vmSupportsJDBC3())
-            return TestConfiguration.defaultSuite(ParameterMappingTest.class);
-        else
-            return  new TestSuite("ParameterMapping");
+        return TestConfiguration.defaultSuite(ParameterMappingTest.class);
     }
         /*
         ** Procedures for parameter mapping testing.



Mime
View raw message