You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/07/17 08:31:04 UTC
svn commit: r556825 [6/10] - in
/harmony/enhanced/classlib/branches/java6/modules:
archive/src/main/java/java/util/jar/ archive/src/main/java/java/util/zip/
archive/src/main/java/org/apache/harmony/archive/internal/nls/
archive/src/main/java/org/apache...
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=556825&r1=556824&r2=556825
==============================================================================
--- 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 Mon Jul 16 23:30:22 2007
@@ -26,72 +26,72 @@
public class DataTruncationTest extends TestCase {
- /*
- * ConstructorTest
- */
- public void testDataTruncationintbooleanbooleanintint() {
-
- int[] init1 = { -2147483648, 2147483647, 0, 329751502, 318587557,
- -1217247045, 329474146 };
- boolean[] init2 = { false, true, false, false, false, true, false };
- boolean[] init3 = { false, true, false, false, false, false, true };
- int[] init4 = { -2147483648, 2147483647, 0, 1761409290, -1331044048,
- -576231606, 661635011 };
- int[] init5 = { -2147483648, 2147483647, 0, 540816689, -1890783845,
- -105552912, -85923935 };
-
- String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
- "22001", "22001", "01004" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- DataTruncation aDataTruncation;
- int loopCount = init1.length;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- if (theExceptions[i] != null) {
+ /*
+ * ConstructorTest
+ */
+ public void testDataTruncationintbooleanbooleanintint() {
+
+ int[] init1 = { -2147483648, 2147483647, 0, 329751502, 318587557,
+ -1217247045, 329474146 };
+ boolean[] init2 = { false, true, false, false, false, true, false };
+ boolean[] init3 = { false, true, false, false, false, false, true };
+ int[] init4 = { -2147483648, 2147483647, 0, 1761409290, -1331044048,
+ -576231606, 661635011 };
+ int[] init5 = { -2147483648, 2147483647, 0, 540816689, -1890783845,
+ -105552912, -85923935 };
+
+ String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+ "22001", "22001", "01004" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ DataTruncation aDataTruncation;
+ int loopCount = init1.length;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ if (theExceptions[i] != null) {
fail();
}
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
- } // end method testDataTruncationintbooleanbooleanintint
+ } // end method testDataTruncationintbooleanbooleanintint
/**
* @tests {@link java.sql.DataTruncation#DataTruncation(int, boolean, boolean, int, int, Throwable)}
@@ -107,366 +107,366 @@
assertEquals("error message", dataTruncation.getCause().getMessage());
}
- /*
- * Method test for getIndex
- */
- public void testGetIndex() {
-
- DataTruncation aDataTruncation;
- int[] init1 = { -2147483648, 2147483647, 0, -2045829673, 1977156911,
- 478985827, 1687271915 };
- boolean[] init2 = { false, true, false, false, true, true, true };
- boolean[] init3 = { false, true, false, false, true, true, true };
- int[] init4 = { -2147483648, 2147483647, 0, -631377748, 21025030,
- 1215194589, 1064137121 };
- int[] init5 = { -2147483648, 2147483647, 0, -897998505, 997578180,
- 735015866, 264619424 };
-
- int theReturn;
- int[] theReturns = init1;
- String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
- "01004", "01004", "01004" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- theReturn = aDataTruncation.getIndex();
- if (theExceptions[i] != null) {
+ /*
+ * Method test for getIndex
+ */
+ public void testGetIndex() {
+
+ DataTruncation aDataTruncation;
+ int[] init1 = { -2147483648, 2147483647, 0, -2045829673, 1977156911,
+ 478985827, 1687271915 };
+ boolean[] init2 = { false, true, false, false, true, true, true };
+ boolean[] init3 = { false, true, false, false, true, true, true };
+ int[] init4 = { -2147483648, 2147483647, 0, -631377748, 21025030,
+ 1215194589, 1064137121 };
+ int[] init5 = { -2147483648, 2147483647, 0, -897998505, 997578180,
+ 735015866, 264619424 };
+
+ int theReturn;
+ int[] theReturns = init1;
+ String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+ "01004", "01004", "01004" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ theReturn = aDataTruncation.getIndex();
+ if (theExceptions[i] != null) {
fail(i + "Exception missed");
}
- assertEquals(i + "Return value mismatch", theReturn,
- theReturns[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + "Return value mismatch", theReturn,
+ theReturns[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testGetIndex
-
- /*
- * Method test for getParameter
- */
- public void testGetParameter() {
-
- DataTruncation aDataTruncation;
- int[] init1 = { -2147483648, 2147483647, 0, -492314242, 1637665948,
- -305785075, 258819883 };
- boolean[] init2 = { false, true, false, true, true, false, true };
- boolean[] init3 = { false, true, false, false, false, true, true };
- int[] init4 = { -2147483648, 2147483647, 0, 1134512579, 533874007,
- 1709608139, 990656593 };
- int[] init5 = { -2147483648, 2147483647, 0, -1566784226, -744009101,
- -444614454, 356465980 };
-
- boolean theReturn;
- boolean[] theReturns = init2;
- String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
- "22001", "01004", "01004" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- theReturn = aDataTruncation.getParameter();
- if (theExceptions[i] != null) {
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetIndex
+
+ /*
+ * Method test for getParameter
+ */
+ public void testGetParameter() {
+
+ DataTruncation aDataTruncation;
+ int[] init1 = { -2147483648, 2147483647, 0, -492314242, 1637665948,
+ -305785075, 258819883 };
+ boolean[] init2 = { false, true, false, true, true, false, true };
+ boolean[] init3 = { false, true, false, false, false, true, true };
+ int[] init4 = { -2147483648, 2147483647, 0, 1134512579, 533874007,
+ 1709608139, 990656593 };
+ int[] init5 = { -2147483648, 2147483647, 0, -1566784226, -744009101,
+ -444614454, 356465980 };
+
+ boolean theReturn;
+ boolean[] theReturns = init2;
+ String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+ "22001", "01004", "01004" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ theReturn = aDataTruncation.getParameter();
+ if (theExceptions[i] != null) {
fail(i + "Exception missed");
}
- assertEquals(i + "Return value mismatch", theReturn,
- theReturns[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + "Return value mismatch", theReturn,
+ theReturns[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testGetParameter
-
- /*
- * Method test for getRead
- */
- public void testGetRead() {
-
- DataTruncation aDataTruncation;
- int[] init1 = { -2147483648, 2147483647, 0, 2092420209, -1695764964,
- 1832837995, -80199594 };
- boolean[] init2 = { false, true, false, false, false, true, true };
- boolean[] init3 = { false, true, false, false, true, true, false };
- int[] init4 = { -2147483648, 2147483647, 0, 1762375167, -604897453,
- 1362491587, 1007466498 };
- int[] init5 = { -2147483648, 2147483647, 0, 1494407222, -1696982311,
- -940493360, -1777579868 };
-
- boolean theReturn;
- boolean[] theReturns = init3;
- String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
- "01004", "01004", "22001" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- theReturn = aDataTruncation.getRead();
- if (theExceptions[i] != null) {
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetParameter
+
+ /*
+ * Method test for getRead
+ */
+ public void testGetRead() {
+
+ DataTruncation aDataTruncation;
+ int[] init1 = { -2147483648, 2147483647, 0, 2092420209, -1695764964,
+ 1832837995, -80199594 };
+ boolean[] init2 = { false, true, false, false, false, true, true };
+ boolean[] init3 = { false, true, false, false, true, true, false };
+ int[] init4 = { -2147483648, 2147483647, 0, 1762375167, -604897453,
+ 1362491587, 1007466498 };
+ int[] init5 = { -2147483648, 2147483647, 0, 1494407222, -1696982311,
+ -940493360, -1777579868 };
+
+ boolean theReturn;
+ boolean[] theReturns = init3;
+ String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+ "01004", "01004", "22001" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ theReturn = aDataTruncation.getRead();
+ if (theExceptions[i] != null) {
fail(i + "Exception missed");
}
- assertEquals(i + "Return value mismatch", theReturn,
- theReturns[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + "Return value mismatch", theReturn,
+ theReturns[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testGetRead
-
- /*
- * Method test for getDataSize
- */
- public void testGetDataSize() {
-
- DataTruncation aDataTruncation;
- int[] init1 = { -2147483648, 2147483647, 0, 1146707040, -2020665632,
- 1268632617, -1595624039 };
- boolean[] init2 = { false, true, false, true, false, true, true };
- boolean[] init3 = { false, true, false, true, true, false, false };
- int[] init4 = { -2147483648, 2147483647, 0, -367493363, 328996907,
- -1581326731, 835022052 };
- int[] init5 = { -2147483648, 2147483647, 0, -886134194, 908213800,
- 1123419516, -429606389 };
-
- int theReturn;
- int[] theReturns = init4;
- String[] theFinalStates1 = { "22001", "01004", "22001", "01004",
- "01004", "22001", "22001" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- theReturn = aDataTruncation.getDataSize();
- if (theExceptions[i] != null) {
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetRead
+
+ /*
+ * Method test for getDataSize
+ */
+ public void testGetDataSize() {
+
+ DataTruncation aDataTruncation;
+ int[] init1 = { -2147483648, 2147483647, 0, 1146707040, -2020665632,
+ 1268632617, -1595624039 };
+ boolean[] init2 = { false, true, false, true, false, true, true };
+ boolean[] init3 = { false, true, false, true, true, false, false };
+ int[] init4 = { -2147483648, 2147483647, 0, -367493363, 328996907,
+ -1581326731, 835022052 };
+ int[] init5 = { -2147483648, 2147483647, 0, -886134194, 908213800,
+ 1123419516, -429606389 };
+
+ int theReturn;
+ int[] theReturns = init4;
+ String[] theFinalStates1 = { "22001", "01004", "22001", "01004",
+ "01004", "22001", "22001" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ theReturn = aDataTruncation.getDataSize();
+ if (theExceptions[i] != null) {
fail(i + "Exception missed");
}
- assertEquals(i + "Return value mismatch", theReturn,
- theReturns[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + "Return value mismatch", theReturn,
+ theReturns[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testGetDataSize
-
- /*
- * Method test for getTransferSize
- */
- public void testGetTransferSize() {
-
- DataTruncation aDataTruncation;
- int[] init1 = { -2147483648, 2147483647, 0, 78096124, 1719192600,
- -1661234694, -1205825753 };
- boolean[] init2 = { false, true, false, false, true, false, true };
- boolean[] init3 = { false, true, false, false, false, false, false };
- int[] init4 = { -2147483648, 2147483647, 0, -493779295, -2042560243,
- -217347438, 1357818664 };
- int[] init5 = { -2147483648, 2147483647, 0, -1647009002, -717544563,
- -1368171905, -918209633 };
-
- int theReturn;
- int[] theReturns = init5;
- String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
- "22001", "22001", "22001" };
- String state2 = "Data truncation";
- String[] theFinalStates2 = { state2, state2, state2, state2, state2,
- state2, state2 };
- int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
- int[] theFinalStates4 = init1;
- int[] theFinalStates5 = init4;
- int[] theFinalStates6 = init5;
- boolean[] theFinalStates7 = init2;
- boolean[] theFinalStates8 = init3;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aDataTruncation = new DataTruncation(init1[i], init2[i],
- init3[i], init4[i], init5[i]);
- theReturn = aDataTruncation.getTransferSize();
- if (theExceptions[i] != null) {
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetDataSize
+
+ /*
+ * Method test for getTransferSize
+ */
+ public void testGetTransferSize() {
+
+ DataTruncation aDataTruncation;
+ int[] init1 = { -2147483648, 2147483647, 0, 78096124, 1719192600,
+ -1661234694, -1205825753 };
+ boolean[] init2 = { false, true, false, false, true, false, true };
+ boolean[] init3 = { false, true, false, false, false, false, false };
+ int[] init4 = { -2147483648, 2147483647, 0, -493779295, -2042560243,
+ -217347438, 1357818664 };
+ int[] init5 = { -2147483648, 2147483647, 0, -1647009002, -717544563,
+ -1368171905, -918209633 };
+
+ int theReturn;
+ int[] theReturns = init5;
+ String[] theFinalStates1 = { "22001", "01004", "22001", "22001",
+ "22001", "22001", "22001" };
+ String state2 = "Data truncation";
+ String[] theFinalStates2 = { state2, state2, state2, state2, state2,
+ state2, state2 };
+ int[] theFinalStates3 = { 0, 0, 0, 0, 0, 0, 0 };
+ int[] theFinalStates4 = init1;
+ int[] theFinalStates5 = init4;
+ int[] theFinalStates6 = init5;
+ boolean[] theFinalStates7 = init2;
+ boolean[] theFinalStates8 = init3;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aDataTruncation = new DataTruncation(init1[i], init2[i],
+ init3[i], init4[i], init5[i]);
+ theReturn = aDataTruncation.getTransferSize();
+ if (theExceptions[i] != null) {
fail(i + "Exception missed");
}
- assertEquals(i + "Return value mismatch", theReturn,
- theReturns[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getSQLState(), theFinalStates1[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getMessage(), theFinalStates2[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getErrorCode(), theFinalStates3[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getIndex(), theFinalStates4[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getDataSize(), theFinalStates5[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getTransferSize(), theFinalStates6[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getParameter(), theFinalStates7[i]);
- assertEquals(i + " Final state mismatch", aDataTruncation
- .getRead(), theFinalStates8[i]);
+ assertEquals(i + "Return value mismatch", theReturn,
+ theReturns[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getSQLState(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getMessage(), theFinalStates2[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getErrorCode(), theFinalStates3[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getIndex(), theFinalStates4[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getDataSize(), theFinalStates5[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getTransferSize(), theFinalStates6[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getParameter(), theFinalStates7[i]);
+ assertEquals(i + " Final state mismatch", aDataTruncation
+ .getRead(), theFinalStates8[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetTransferSize
- } // end method testGetTransferSize
-
/**
* @tests serialization/deserialization compatibility.
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DatabaseMetaDataTest.java Mon Jul 16 23:30:22 2007
@@ -23,71 +23,70 @@
public class DatabaseMetaDataTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
- assertEquals(attributeNoNulls,0);
- assertEquals(attributeNullable,1);
- assertEquals(attributeNullableUnknown,2);
- assertEquals(bestRowNotPseudo,1);
- assertEquals(bestRowPseudo,2);
- assertEquals(bestRowSession,2);
- assertEquals(bestRowTemporary,0);
- assertEquals(bestRowTransaction,1);
- assertEquals(bestRowUnknown,0);
- assertEquals(columnNoNulls,0);
- assertEquals(columnNullable,1);
- assertEquals(columnNullableUnknown,2);
- assertEquals(functionColumnIn,1);
- assertEquals(functionColumnInOut,2);
- assertEquals(functionColumnOut,3);
- assertEquals(functionColumnResult,5);
- assertEquals(functionColumnUnknown,0);
- assertEquals(functionNoNulls,0);
- assertEquals(functionNoTable,1);
- assertEquals(functionNullable,1);
- assertEquals(functionNullableUnknown,2);
- assertEquals(functionResultUnknown,0);
- assertEquals(functionReturn,4);
- assertEquals(functionReturnsTable,2);
- assertEquals(importedKeyCascade,0);
- assertEquals(importedKeyInitiallyDeferred,5);
- assertEquals(importedKeyInitiallyImmediate,6);
- assertEquals(importedKeyNoAction,3);
- assertEquals(importedKeyNotDeferrable,7);
- assertEquals(importedKeyRestrict,1);
- assertEquals(importedKeySetDefault,4);
- assertEquals(importedKeySetNull,2);
- assertEquals(procedureColumnIn,1);
- assertEquals(procedureColumnInOut,2);
- assertEquals(procedureColumnOut,4);
- assertEquals(procedureColumnResult,3);
- assertEquals(procedureColumnReturn,5);
- assertEquals(procedureColumnUnknown,0);
- assertEquals(procedureNoNulls,0);
- assertEquals(procedureNoResult,1);
- assertEquals(procedureNullable,1);
- assertEquals(procedureNullableUnknown,2);
- assertEquals(procedureResultUnknown,0);
- assertEquals(procedureReturnsResult,2);
- assertEquals(sqlStateSQL,2);
- assertEquals(sqlStateSQL99,2);
- assertEquals(sqlStateXOpen,1);
- assertEquals(tableIndexClustered,1);
- assertEquals(tableIndexHashed,2);
- assertEquals(tableIndexOther,3);
- assertEquals(tableIndexStatistic,0);
- assertEquals(typeNoNulls,0);
- assertEquals(typeNullable,1);
- assertEquals(typeNullableUnknown,2);
- assertEquals(typePredBasic,2);
- assertEquals(typePredChar,1);
- assertEquals(typePredNone,0);
- assertEquals(typeSearchable,3);
- assertEquals(versionColumnNotPseudo,1);
- assertEquals(versionColumnPseudo,2);
- assertEquals(versionColumnUnknown,0);
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
+ assertEquals(attributeNoNulls,0);
+ assertEquals(attributeNullable,1);
+ assertEquals(attributeNullableUnknown,2);
+ assertEquals(bestRowNotPseudo,1);
+ assertEquals(bestRowPseudo,2);
+ assertEquals(bestRowSession,2);
+ assertEquals(bestRowTemporary,0);
+ assertEquals(bestRowTransaction,1);
+ assertEquals(bestRowUnknown,0);
+ assertEquals(columnNoNulls,0);
+ assertEquals(columnNullable,1);
+ assertEquals(columnNullableUnknown,2);
+ assertEquals(functionColumnIn,1);
+ assertEquals(functionColumnInOut,2);
+ assertEquals(functionColumnOut,3);
+ assertEquals(functionColumnResult,5);
+ assertEquals(functionColumnUnknown,0);
+ assertEquals(functionNoNulls,0);
+ assertEquals(functionNoTable,1);
+ assertEquals(functionNullable,1);
+ assertEquals(functionNullableUnknown,2);
+ assertEquals(functionResultUnknown,0);
+ assertEquals(functionReturn,4);
+ assertEquals(functionReturnsTable,2);
+ assertEquals(importedKeyCascade,0);
+ assertEquals(importedKeyInitiallyDeferred,5);
+ assertEquals(importedKeyInitiallyImmediate,6);
+ assertEquals(importedKeyNoAction,3);
+ assertEquals(importedKeyNotDeferrable,7);
+ assertEquals(importedKeyRestrict,1);
+ assertEquals(importedKeySetDefault,4);
+ assertEquals(importedKeySetNull,2);
+ assertEquals(procedureColumnIn,1);
+ assertEquals(procedureColumnInOut,2);
+ assertEquals(procedureColumnOut,4);
+ assertEquals(procedureColumnResult,3);
+ assertEquals(procedureColumnReturn,5);
+ assertEquals(procedureColumnUnknown,0);
+ assertEquals(procedureNoNulls,0);
+ assertEquals(procedureNoResult,1);
+ assertEquals(procedureNullable,1);
+ assertEquals(procedureNullableUnknown,2);
+ assertEquals(procedureResultUnknown,0);
+ assertEquals(procedureReturnsResult,2);
+ assertEquals(sqlStateSQL,2);
+ assertEquals(sqlStateSQL99,2);
+ assertEquals(sqlStateXOpen,1);
+ assertEquals(tableIndexClustered,1);
+ assertEquals(tableIndexHashed,2);
+ assertEquals(tableIndexOther,3);
+ assertEquals(tableIndexStatistic,0);
+ assertEquals(typeNoNulls,0);
+ assertEquals(typeNullable,1);
+ assertEquals(typeNullableUnknown,2);
+ assertEquals(typePredBasic,2);
+ assertEquals(typePredChar,1);
+ assertEquals(typePredNone,0);
+ assertEquals(typeSearchable,3);
+ assertEquals(versionColumnNotPseudo,1);
+ assertEquals(versionColumnPseudo,2);
+ assertEquals(versionColumnUnknown,0);
}
-
}
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java Mon Jul 16 23:30:22 2007
@@ -29,352 +29,351 @@
*/
public class DateTest extends TestCase {
- // A calendar object created in the GMT time zone
- static Calendar aCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ // A calendar object created in the GMT time zone
+ static Calendar aCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- // Some interesting millisecond time values
- // These millisecond times are all in GMT, effectively
- static long TIME_AN_HOUR = 3600000; // 1000 * 60 * 60 ms
+ // Some interesting millisecond time values
+ // These millisecond times are all in GMT, effectively
+ static long TIME_AN_HOUR = 3600000; // 1000 * 60 * 60 ms
- static long TIME_EPOCH = 0;
+ static long TIME_EPOCH = 0;
- static long TIME_NOW = System.currentTimeMillis();
+ static long TIME_NOW = System.currentTimeMillis();
- static long TIME_NEGATIVE = -3600001;
+ static long TIME_NEGATIVE = -3600001;
- static long TIME_TESTDATE1 = getTime(1999, Calendar.DECEMBER, 31, 23, 59,
- 59);
+ static long TIME_TESTDATE1 = getTime(1999, Calendar.DECEMBER, 31, 23, 59,
+ 59);
- static long TIME_TESTDATE2 = getTime(2010, Calendar.JUNE, 10, 20, 3, 16);
+ static long TIME_TESTDATE2 = getTime(2010, Calendar.JUNE, 10, 20, 3, 16);
- static long TIME_TESTDATE3 = getTime(1931, Calendar.APRIL, 21, 1, 25, 1);
+ static long TIME_TESTDATE3 = getTime(1931, Calendar.APRIL, 21, 1, 25, 1);
- static long TIME_LOWERLIMIT = Long.MIN_VALUE;
+ static long TIME_LOWERLIMIT = Long.MIN_VALUE;
- static long TIME_UPPERLIMIT = Long.MAX_VALUE;
+ static long TIME_UPPERLIMIT = Long.MAX_VALUE;
- // Date strings
- static String SQL_DATESTRING1 = "1999-12-31";
+ // Date strings
+ static String SQL_DATESTRING1 = "1999-12-31";
- static String SQL_DATESTRING2 = "2010-06-10";
+ static String SQL_DATESTRING2 = "2010-06-10";
- static String SQL_DATESTRING3 = "1931-04-21";
+ static String SQL_DATESTRING3 = "1931-04-21";
- static String SQL_EPOCHSTRING = "1970-01-01";
+ static String SQL_EPOCHSTRING = "1970-01-01";
- static String SQL_DATEDAY1 = "1970-01-02";
+ static String SQL_DATEDAY1 = "1970-01-02";
- static String SQL_NEGATIVE = "1969-12-31";
+ static String SQL_NEGATIVE = "1969-12-31";
- static long[] TIME_ARRAY = new long[] { TIME_TESTDATE1, TIME_TESTDATE2,
- TIME_TESTDATE3, TIME_NEGATIVE, TIME_EPOCH };
+ static long[] TIME_ARRAY = new long[] { TIME_TESTDATE1, TIME_TESTDATE2,
+ TIME_TESTDATE3, TIME_NEGATIVE, TIME_EPOCH };
- // Date string array for London (GMT)
- static String[] SQL_DATEARRAY = new String[] { SQL_DATESTRING1,
- SQL_DATESTRING2, SQL_DATESTRING3, SQL_NEGATIVE, SQL_EPOCHSTRING };
+ // Date string array for London (GMT)
+ static String[] SQL_DATEARRAY = new String[] { SQL_DATESTRING1,
+ SQL_DATESTRING2, SQL_DATESTRING3, SQL_NEGATIVE, SQL_EPOCHSTRING };
- // Date string array for New York - sometimes a day earlier than London
- static String[] SQL_NYARRAY = new String[] { "1999-12-31", "2010-06-10",
- "1931-04-20", "1969-12-31", "1969-12-31" };
+ // Date string array for New York - sometimes a day earlier than London
+ static String[] SQL_NYARRAY = new String[] { "1999-12-31", "2010-06-10",
+ "1931-04-20", "1969-12-31", "1969-12-31" };
- // Date string for Tokyo
- static String[] SQL_JAPANARRAY = new String[] { "2000-01-01", "2010-06-11",
- "1931-04-21", "1970-01-01", "1970-01-01" };
+ // Date string for Tokyo
+ static String[] SQL_JAPANARRAY = new String[] { "2000-01-01", "2010-06-11",
+ "1931-04-21", "1970-01-01", "1970-01-01" };
- static String[][] SQL_TZ_DATEARRAYS = new String[][] { SQL_DATEARRAY,
- SQL_NYARRAY, SQL_JAPANARRAY };
+ static String[][] SQL_TZ_DATEARRAYS = new String[][] { SQL_DATEARRAY,
+ SQL_NYARRAY, SQL_JAPANARRAY };
- // Timezones
- static String TZ_LONDON = "Europe/London"; // Note: != GMT
+ // Timezones
+ static String TZ_LONDON = "Europe/London"; // Note: != GMT
- static String TZ_PACIFIC = "America/Los_Angeles"; // GNT - 8
+ static String TZ_PACIFIC = "America/Los_Angeles"; // GNT - 8
- static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
+ static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
- static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
+ static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
- /*
- * Helper method to create a long milliseconds time from a supplied date and
- * time
- */
- static private long getTime(int year, int month, int date, int hour,
- int minute, int second) {
- aCal.set(year, month, date, hour, minute, second);
- return aCal.getTimeInMillis();
- } // end method getTime( int, int, int, int, int, int )
-
- /*
- * Test of the Date(int, int, int) constructor - now deprecated but still
- * functioning
- */
- @SuppressWarnings("deprecation")
+ /*
+ * Helper method to create a long milliseconds time from a supplied date and
+ * time
+ */
+ static private long getTime(int year, int month, int date, int hour,
+ int minute, int second) {
+ aCal.set(year, month, date, hour, minute, second);
+ return aCal.getTimeInMillis();
+ } // end method getTime( int, int, int, int, int, int )
+
+ /*
+ * Test of the Date(int, int, int) constructor - now deprecated but still
+ * functioning
+ */
+ @SuppressWarnings("deprecation")
public void testDateintintint() {
- int init1[] = { 99, 8099, 9000, 99999, 99, 99, -1, -100 };
- int init2[] = { 11, 0, 0, 0, 999, 0, 0, -111 };
- int init3[] = { 31, 0, 0, 0, 0, 999, 0, -999 };
+ int init1[] = { 99, 8099, 9000, 99999, 99, 99, -1, -100 };
+ int init2[] = { 11, 0, 0, 0, 999, 0, 0, -111 };
+ int init3[] = { 31, 0, 0, 0, 0, 999, 0, -999 };
- for (int i = 0; i < init1.length; i++) {
+ for (int i = 0; i < init1.length; i++) {
Date theDate = new Date(init1[i], init2[i], init3[i]);
assertNotNull(theDate);
} // end for
- } // end method testDateintintint
+ } // end method testDateintintint
+
+ /*
+ * Test of the Date( long ) constructor
+ */
+ public void testDatelong() {
- /*
- * Test of the Date( long ) constructor
- */
- public void testDatelong() {
-
- long init1[] = { TIME_TESTDATE1, TIME_TESTDATE2, TIME_TESTDATE3,
- TIME_NEGATIVE, TIME_LOWERLIMIT, TIME_UPPERLIMIT, TIME_EPOCH,
- TIME_NOW };
+ long init1[] = { TIME_TESTDATE1, TIME_TESTDATE2, TIME_TESTDATE3,
+ TIME_NEGATIVE, TIME_LOWERLIMIT, TIME_UPPERLIMIT, TIME_EPOCH,
+ TIME_NOW };
- for (long element : init1) {
+ for (long element : init1) {
Date theDate = new Date(element);
assertNotNull(theDate);
} // end for
- } // end method testDatelong
+ } // end method testDatelong
- /*
- * Test of the (deprecated) int Date.getHours() method - which always throws
- * an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ /*
+ * Test of the (deprecated) int Date.getHours() method - which always throws
+ * an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetHours() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getHours();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getHours();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetHours()
-
- /*
- * Test of the (deprecated) int Date.getMinutes() method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetHours()
+
+ /*
+ * Test of the (deprecated) int Date.getMinutes() method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetMinutes() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getMinutes();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getMinutes();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetMinutes()
-
- /*
- * Test of the (deprecated) int Date.getSeconds() method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetMinutes()
+
+ /*
+ * Test of the (deprecated) int Date.getSeconds() method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetSeconds() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getSeconds();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getSeconds();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetSeconds()
-
- /*
- * Test of the (deprecated) Date.setHours( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetSeconds()
+
+ /*
+ * Test of the (deprecated) Date.setHours( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetHours() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setHours(22);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setHours(22);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testSetHours( int )
-
- /*
- * Test of the (deprecated) Date.setMinutes( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testSetHours( int )
+
+ /*
+ * Test of the (deprecated) Date.setMinutes( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetMinutes() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setMinutes(54);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setMinutes(54);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
-
- } // end method testSetMinutes( int )
-
- /*
- * Test of the (deprecated) Date.setSeconds( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+
+ } // end method testSetMinutes( int )
+
+ /*
+ * Test of the (deprecated) Date.setSeconds( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetSeconds() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setSeconds(36);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setSeconds(36);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testSetSeconds( int )
-
- /*
- * Test of the String Date.toString() method This method is sensitive to the
- * time zone setting and this test sets the time zone before calling the
- * toString() method.
- */
- public void testToString() {
- // This test is set up for GMT time zone, so need to set the time zone
- // to GMT first
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-
- for (int i = 0; i < TIME_ARRAY.length; i++) {
- Date theDate = new Date(TIME_ARRAY[i]);
- assertEquals(SQL_DATEARRAY[i], theDate.toString());
- } // end for
-
- } // end method testToString()
-
- /*
- * Test of the void setTime(int) method This does depend on the Time Zone
- * settings and sets up the time zone to one of a group of specific time
- * zones and tests the method using each of these time zones in turn.
- */
- public void testSetTimelong() {
-
- // Loop over the array of test timezones
- for (int i = 0; i < TIMEZONES.length; i++) {
- testSetTimelong(TIMEZONES[i], SQL_TZ_DATEARRAYS[i]);
- } // end for
-
- } // end method testSetTimelong()
-
- /*
- * Internal method for testing Date.setTime with a specific time zone
- */
- private void testSetTimelong(String timeZoneName, String[] dateArray) {
-
- if (timeZoneName != null) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZoneName));
- } // end if
-
- Date theDate = new Date(TIME_TESTDATE1);
-
- // Loop over the array of test times & dates
- for (int i = 0; i < dateArray.length; i++) {
- theDate.setTime(TIME_ARRAY[i]);
- assertEquals(dateArray[i], theDate.toString());
- } // end for
-
- } // end method testSetTimelong()
-
- /*
- * Test of the Date.valueOf( String ) method This test is not dependent on
- * the default Time Zone setting
- */
- public void testValueOf() {
- String SQL_NOTVALID1 = "ABCDEF"; // Invalid date string
- String SQL_NOTVALID2 = "12321.43.56"; // Invalid date string
- String SQL_NOTVALID3 = null; // Invalid date string
- String[] SQL_INVALIDARRAY = { SQL_NOTVALID1, SQL_NOTVALID2,
- SQL_NOTVALID3 };
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testSetSeconds( int )
+
+ /*
+ * Test of the String Date.toString() method This method is sensitive to the
+ * time zone setting and this test sets the time zone before calling the
+ * toString() method.
+ */
+ public void testToString() {
+ // This test is set up for GMT time zone, so need to set the time zone
+ // to GMT first
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+
+ for (int i = 0; i < TIME_ARRAY.length; i++) {
+ Date theDate = new Date(TIME_ARRAY[i]);
+ assertEquals(SQL_DATEARRAY[i], theDate.toString());
+ } // end for
+
+ } // end method testToString()
+
+ /*
+ * Test of the void setTime(int) method This does depend on the Time Zone
+ * settings and sets up the time zone to one of a group of specific time
+ * zones and tests the method using each of these time zones in turn.
+ */
+ public void testSetTimelong() {
+
+ // Loop over the array of test timezones
+ for (int i = 0; i < TIMEZONES.length; i++) {
+ testSetTimelong(TIMEZONES[i], SQL_TZ_DATEARRAYS[i]);
+ } // end for
+
+ } // end method testSetTimelong()
- Date theDate;
+ /*
+ * Internal method for testing Date.setTime with a specific time zone
+ */
+ private void testSetTimelong(String timeZoneName, String[] dateArray) {
+
+ if (timeZoneName != null) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZoneName));
+ } // end if
+
+ Date theDate = new Date(TIME_TESTDATE1);
+
+ // Loop over the array of test times & dates
+ for (int i = 0; i < dateArray.length; i++) {
+ theDate.setTime(TIME_ARRAY[i]);
+ assertEquals(dateArray[i], theDate.toString());
+ } // end for
+
+ } // end method testSetTimelong()
+
+ /*
+ * Test of the Date.valueOf( String ) method This test is not dependent on
+ * the default Time Zone setting
+ */
+ public void testValueOf() {
+ String SQL_NOTVALID1 = "ABCDEF"; // Invalid date string
+ String SQL_NOTVALID2 = "12321.43.56"; // Invalid date string
+ String SQL_NOTVALID3 = null; // Invalid date string
+ String[] SQL_INVALIDARRAY = { SQL_NOTVALID1, SQL_NOTVALID2,
+ SQL_NOTVALID3 };
+
+ Date theDate;
- for (String element : SQL_DATEARRAY) {
- theDate = Date.valueOf(element);
+ for (String element : SQL_DATEARRAY) {
+ theDate = Date.valueOf(element);
assertEquals(element, theDate.toString());
- } // end for
+ } // end for
- for (String element : SQL_INVALIDARRAY) {
- try {
- theDate = Date.valueOf(element);
+ for (String element : SQL_INVALIDARRAY) {
+ try {
+ theDate = Date.valueOf(element);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- //expected
- } // end try
- } // end for
+ } catch (IllegalArgumentException e) {
+ // expected
+ } // end try
+ } // end for
+
+ } // end method testValueOf()
- } // end method testValueOf()
-
/**
* @tests java.sql.Date#valueOf(String )
*/
public void test_valueOf_IllegalArgumentException() {
- try{
+ try {
Date.valueOf("1996-10-07-01");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-10-07-01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("--01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1991--");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-01-");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-10-w2-01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("07-w2-");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1997-w2-w2");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1996--01");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
}
} // end class DateTest
-