harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548886 - in /harmony/enhanced/classlib/branches/java6/modules/sql/src: main/java/java/sql/ test/java/org/apache/harmony/sql/tests/java/sql/
Date Wed, 20 Jun 2007 01:33:59 GMT
Author: tonywu
Date: Tue Jun 19 18:33:58 2007
New Revision: 548886

URL: http://svn.apache.org/viewvc?view=rev&rev=548886
Log:
Apply patch HARMONY-4225 ([classlib][sql][java6] a new constructor in java.sql.DataTruncation
and 4 new constructors in java.sql.SQLWarning)

Modified:
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/DataTruncation.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLWarning.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/DataTruncation.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/DataTruncation.java?view=diff&rev=548886&r1=548885&r2=548886
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/DataTruncation.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/DataTruncation.java
Tue Jun 19 18:33:58 2007
@@ -41,7 +41,9 @@
 
     private static final String THE_REASON = "Data truncation"; //$NON-NLS-1$
 
-    private static final String THE_SQLSTATE = "01004"; //$NON-NLS-1$
+    private static final String THE_SQLSTATE_READ = "01004"; //$NON-NLS-1$
+    
+    private static final String THE_SQLSTATE_WRITE = "22001"; //$NON-NLS-1$
 
     private static final int THE_ERROR_CODE = 0;
 
@@ -65,14 +67,50 @@
      *            the size of the data after truncation
      */
     public DataTruncation(int index, boolean parameter, boolean read,
-            int dataSize, int transferSize) {
-        super(THE_REASON, THE_SQLSTATE, THE_ERROR_CODE);
-        this.index = index;
-        this.parameter = parameter;
-        this.read = read;
-        this.dataSize = dataSize;
-        this.transferSize = transferSize;
-    }
+			int dataSize, int transferSize) {
+		super(THE_REASON, read ? THE_SQLSTATE_READ : THE_SQLSTATE_WRITE,
+				THE_ERROR_CODE);
+		this.index = index;
+		this.parameter = parameter;
+		this.read = read;
+		this.dataSize = dataSize;
+		this.transferSize = transferSize;
+	}
+
+    /**
+	 * Creates a DataTruncation. The Reason is set to "Data truncation", the
+	 * ErrorCode is set to the SQLException default value and other fields are
+	 * set to the values supplied on this method.
+	 * 
+	 * @param index
+	 *            the Index value of the column value or parameter that was
+	 *            truncated
+	 * @param parameter
+	 *            true if it was a Parameter value that was truncated, false
+	 *            otherwise
+	 * @param read
+	 *            true if the truncation occurred on a read operation, false
+	 *            otherwise
+	 * @param dataSize
+	 *            the original size of the truncated data
+	 * @param transferSize
+	 *            the size of the data after truncation
+	 * @param cause
+	 *            the root reason for this DataTruncation
+	 * 
+	 * @since 1.6
+	 */
+	public DataTruncation(int index, boolean parameter, boolean read,
+			int dataSize, int transferSize, Throwable cause) {
+		super(THE_REASON, read ? THE_SQLSTATE_READ : THE_SQLSTATE_WRITE,
+				THE_ERROR_CODE, cause);
+		this.index = index;
+		this.parameter = parameter;
+		this.read = read;
+		this.dataSize = dataSize;
+		this.transferSize = transferSize;
+	}
+            
 
     /**
      * Gets the number of bytes of data that should have been read/written.

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLWarning.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLWarning.java?view=diff&rev=548886&r1=548885&r2=548886
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLWarning.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLWarning.java
Tue Jun 19 18:33:58 2007
@@ -90,6 +90,51 @@
         }
         throw new Error(Messages.getString("sql.8")); //$NON-NLS-1$
     }
+    
+    /**
+     * Creates an SQLWarning object. The Reason string is set to null, the
+     * SQLState string is set to null and the Error Code is set to 0, cause is
+     * set to cause.
+     * 
+     * @since 1.6
+     */
+    public SQLWarning(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Creates an SQLWarning object. The Reason string is set to reason, the
+     * SQLState string is set to null and the Error Code is set to 0, cause is
+     * set to the given cause
+     * 
+     * @since 1.6
+     */
+    public SQLWarning(String reason, Throwable cause) {
+        super(reason, cause);
+    }
+
+    /**
+     * Creates an SQLWarning object. The Reason string is set to reason, the
+     * SQLState string is set to given SQLState and the Error Code is set to 0,
+     * cause is set to the given cause
+     * 
+     * @since 1.6
+     */
+    public SQLWarning(String reason, String SQLState, Throwable cause) {
+        super(reason, SQLState, cause);
+    }
+
+    /**
+     * Creates an SQLWarning object. The Reason string is set to reason, the
+     * SQLState string is set to given SQLState and the Error Code is set to
+     * vendorCode, cause is set to the given cause
+     * 
+     * @since 1.6
+     */
+    public SQLWarning(String reason, String SQLState, int vendorCode,
+            Throwable cause) {
+        super(reason, SQLState, vendorCode, cause);
+    }
 
     /**
      * Chains a supplied SQLWarning to this SQLWarning.

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java?view=diff&rev=548886&r1=548885&r2=548886
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DataTruncationTest.java
Tue Jun 19 18:33:58 2007
@@ -40,8 +40,8 @@
 		int[] init5 = { -2147483648, 2147483647, 0, 540816689, -1890783845,
 				-105552912, -85923935 };
 
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
-				"01004", "01004", "01004" };
+		String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+				"22001", "22001", "01004" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
 				state2, state2 };
@@ -92,6 +92,20 @@
 		} // end for
 
 	} // end method testDataTruncationintbooleanbooleanintint
+	
+	/**
+	 * @tests {@link java.sql.DataTruncation#DataTruncation(int, boolean, boolean, int, int,
Throwable)}
+	 * 
+	 * @since 1.6
+	 */
+	public void testConstructor_IBBIILjava_lang_Throwable() {
+		Exception e = new Exception("error message");
+		DataTruncation dataTruncation = new DataTruncation(2147483647, true,
+				false, 0, 2147483647, e);
+		assertNotNull(dataTruncation);
+		assertEquals(e, dataTruncation.getCause());
+		assertEquals("error message", dataTruncation.getCause().getMessage());
+	}
 
 	/*
 	 * Method test for getIndex
@@ -110,7 +124,7 @@
 
 		int theReturn;
 		int[] theReturns = init1;
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
+		String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
 				"01004", "01004", "01004" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
@@ -182,8 +196,8 @@
 
 		boolean theReturn;
 		boolean[] theReturns = init2;
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
-				"01004", "01004", "01004" };
+		String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+				"22001", "01004", "01004" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
 				state2, state2 };
@@ -254,8 +268,8 @@
 
 		boolean theReturn;
 		boolean[] theReturns = init3;
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
-				"01004", "01004", "01004" };
+		String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+				"01004", "01004", "22001" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
 				state2, state2 };
@@ -326,8 +340,8 @@
 
 		int theReturn;
 		int[] theReturns = init4;
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
-				"01004", "01004", "01004" };
+		String[] theFinalStates1 = { "22001", "01004", "22001", "01004",
+				"01004", "22001", "22001" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
 				state2, state2 };
@@ -398,8 +412,8 @@
 
 		int theReturn;
 		int[] theReturns = init5;
-		String[] theFinalStates1 = { "01004", "01004", "01004", "01004",
-				"01004", "01004", "01004" };
+		String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+				"22001", "22001", "22001" };
 		String state2 = "Data truncation";
 		String[] theFinalStates2 = { state2, state2, state2, state2, state2,
 				state2, state2 };

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java?view=diff&rev=548886&r1=548885&r2=548886
==============================================================================
Binary files /tmp/tmppg-Ddo and /tmp/tmpCJLKLa differ



Mime
View raw message