OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeavyAIColumnTypeTest.java
Go to the documentation of this file.
1 package ai.heavy.jdbc;
2 
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotEquals;
5 
6 import org.junit.Test;
7 
8 import java.sql.*;
9 import java.util.Properties;
10 
11 public class HeavyAIColumnTypeTest {
12  static Properties PROPERTIES = new Property_loader("type_test.properties");
13  static final String url = PROPERTIES.getProperty("default_db_connection_url");
14  static final String user = PROPERTIES.getProperty("default_super_user");
15  static final String password = PROPERTIES.getProperty("default_user_password");
16  private class Answer {
17  public Answer(int t, String n) {
18  type = t;
19  name = n;
20  }
21  public int type;
22  public String name;
23  }
24  private Answer[] answers = {new Answer(java.sql.Types.INTEGER, "INT"),
25  new Answer(java.sql.Types.FLOAT, "FLOAT"),
26  new Answer(java.sql.Types.OTHER, "POINT"),
27  new Answer(java.sql.Types.OTHER, "LINESTRING"),
28  new Answer(java.sql.Types.OTHER, "POLYGON"),
29  new Answer(java.sql.Types.OTHER, "MULTIPOLYGON")};
30  /* Test the basic connection and methods functionality */
31  @Test
32  public void tst1_types() throws Exception {
33  Connection conn = DriverManager.getConnection(url, user, password);
34  assertNotEquals(null, conn);
35  Statement statement = conn.createStatement();
36  try {
37  statement.executeUpdate(PROPERTIES.getProperty("drop_base_db"));
38  } catch (SQLException sQ) {
39  }
40 
41  statement.executeUpdate(PROPERTIES.getProperty("create_base_db"));
42  statement.close();
43  conn.close();
44  conn = DriverManager.getConnection(
45  PROPERTIES.getProperty("base_db_connection_url"), user, password);
46  statement = conn.createStatement();
47  statement.executeUpdate(PROPERTIES.getProperty("drop_base_table1"));
48  statement.executeUpdate(PROPERTIES.getProperty("create_base_table1"));
49 
50  ResultSet rs = statement.executeQuery(PROPERTIES.getProperty("select_base_table1"));
51  ResultSetMetaData rs_md = rs.getMetaData();
52  int col_cnt = rs_md.getColumnCount();
53  while (col_cnt > 0) {
54  int type = rs_md.getColumnType(col_cnt);
55  String name = rs_md.getColumnTypeName(col_cnt--);
56  assertEquals(type, answers[col_cnt].type);
57  assertEquals(name, answers[col_cnt].name);
58  }
59  statement.executeUpdate(PROPERTIES.getProperty("drop_base_table1"));
60  statement.executeUpdate(PROPERTIES.getProperty("drop_base_db"));
61  }
62 }
tuple conn
Definition: report.py:41
string name
Definition: setup.in.py:72
constexpr double n
Definition: Utm.h:38