1 25 package testsuite.simple; 26 27 import testsuite.BaseTestCase; 28 29 import java.sql.SQLException ; 30 31 36 public class NumbersTest extends BaseTestCase { 37 40 private static final long TEST_BIGINT_VALUE = 6147483647L; 41 42 45 51 public NumbersTest(String name) { 52 super(name); 53 } 54 55 58 63 public static void main(String [] args) { 64 junit.textui.TestRunner.run(NumbersTest.class); 65 } 66 67 73 public void setUp() throws Exception { 74 super.setUp(); 75 createTestTable(); 76 } 77 78 84 public void testNumbers() throws SQLException { 85 this.rs = this.stmt.executeQuery("SELECT * from number_test"); 86 87 while (this.rs.next()) { 88 long minBigInt = this.rs.getLong(1); 89 long maxBigInt = this.rs.getLong(2); 90 long testBigInt = this.rs.getLong(3); 91 assertTrue("Minimum bigint not stored correctly", 92 (minBigInt == Long.MIN_VALUE)); 93 assertTrue("Maximum bigint not stored correctly", 94 (maxBigInt == Long.MAX_VALUE)); 95 assertTrue("Test bigint not stored correctly", 96 (TEST_BIGINT_VALUE == testBigInt)); 97 } 98 } 99 100 private void createTestTable() throws SQLException { 101 try { 102 this.stmt.executeUpdate("DROP TABLE number_test"); 103 } catch (SQLException sqlEx) { 104 ; 105 } 106 107 this.stmt 108 .executeUpdate("CREATE TABLE number_test (minBigInt bigint, maxBigInt bigint, testBigInt bigint)"); 109 this.stmt 110 .executeUpdate("INSERT INTO number_test (minBigInt,maxBigInt,testBigInt) values (" 111 + Long.MIN_VALUE 112 + "," 113 + Long.MAX_VALUE 114 + "," 115 + TEST_BIGINT_VALUE + ")"); 116 } 117 } 118 | Popular Tags |