Search in sources :

Example 1 with Object

use of java.lang.Object in project hive by apache.

the class TestJdbcDriver2 method getTablesTest.

/**
   * Test the type returned for pre-created table type table and view type table
   * @param tableTypeNames expected table types
   * @param viewTypeName expected view type
   * @throws SQLException
   */
private void getTablesTest(Set<String> tableTypeNames, String viewTypeName) throws SQLException {
    String[] ALL = null;
    String[] VIEW_ONLY = { viewTypeName };
    String[] TABLE_ONLY = tableTypeNames.toArray(new String[tableTypeNames.size()]);
    Set<String> viewOrTableArray = new HashSet<String>();
    viewOrTableArray.addAll(tableTypeNames);
    viewOrTableArray.add(viewTypeName);
    String testTblWithDb = testDbName + "." + tableName;
    String testPartTblWithDb = testDbName + "." + partitionedTableName;
    String testDataTypeTblWithDb = testDbName + "." + dataTypeTableName;
    String testViewWithDb = testDbName + "." + viewName;
    String testExtTblWithDb = testDbName + "." + externalTableName;
    Map<Object[], String[]> tests = new IdentityHashMap<Object[], String[]>();
    tests.put(new Object[] { null, "testjdbc%", ALL }, new String[] { testTblWithDb, testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "test%", "testjdbc%", ALL }, new String[] { testTblWithDb, testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "test%", "testjdbc%", VIEW_ONLY }, new String[] { testViewWithDb });
    tests.put(new Object[] { null, "testjdbcdrivertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbcdrivertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbc%", ALL }, new String[] { testTblWithDb, testPartTblWithDb, testViewWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    tests.put(new Object[] { "%jdbc%", "testjdbcdrivertbl", TABLE_ONLY }, new String[] { testTblWithDb });
    tests.put(new Object[] { null, "test_dbcdri_ertbl", ALL }, new String[] { testTblWithDb });
    tests.put(new Object[] { null, "%jdbc%", ALL }, new String[] { testTblWithDb, testPartTblWithDb, testViewWithDb, testDataTypeTblWithDb, testExtTblWithDb });
    tests.put(new Object[] { "%", "%jdbc%", VIEW_ONLY }, new String[] { testViewWithDb });
    tests.put(new Object[] { null, "%jdbc%", TABLE_ONLY }, new String[] { testTblWithDb, testPartTblWithDb, testExtTblWithDb, testDataTypeTblWithDb });
    for (Map.Entry<Object[], String[]> entry : tests.entrySet()) {
        Object[] checkPattern = entry.getKey();
        String debugString = checkPattern[0] + ", " + checkPattern[1] + ", " + Arrays.toString((String[]) checkPattern[2]);
        Set<String> expectedTables = new HashSet<String>(Arrays.asList(entry.getValue()));
        ResultSet rs = con.getMetaData().getTables(null, (String) checkPattern[0], (String) checkPattern[1], (String[]) checkPattern[2]);
        ResultSetMetaData resMeta = rs.getMetaData();
        assertEquals(10, resMeta.getColumnCount());
        assertEquals("TABLE_CAT", resMeta.getColumnName(1));
        assertEquals("TABLE_SCHEM", resMeta.getColumnName(2));
        assertEquals("TABLE_NAME", resMeta.getColumnName(3));
        assertEquals("TABLE_TYPE", resMeta.getColumnName(4));
        assertEquals("REMARKS", resMeta.getColumnName(5));
        int cnt = 0;
        while (rs.next()) {
            String resultDbName = rs.getString("TABLE_SCHEM");
            String resultTableName = rs.getString("TABLE_NAME");
            assertTrue("Invalid table " + resultDbName + "." + resultTableName + " for test " + debugString, expectedTables.contains(resultDbName + "." + resultTableName));
            String resultTableComment = rs.getString("REMARKS");
            assertTrue("Missing comment on the table.", resultTableComment.length() > 0);
            String tableType = rs.getString("TABLE_TYPE");
            if (resultTableName.endsWith("view")) {
                assertEquals("Expected a tabletype view but got something else.", viewTypeName, tableType);
            } else {
                assertTrue("Expected one of " + tableTypeNames + " table but got something else: " + tableType, tableTypeNames.contains(tableType));
            }
            cnt++;
        }
        rs.close();
        assertEquals("Received an incorrect number of tables for test " + debugString, expectedTables.size(), cnt);
    }
}
Also used : IdentityHashMap(java.util.IdentityHashMap) String(java.lang.String) ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) Object(java.lang.Object) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 2 with Object

use of java.lang.Object in project hive by apache.

the class TestJdbcDriver2 method assertPreparedStatementResultAsExpected.

private void assertPreparedStatementResultAsExpected(ResultSet res) throws SQLException {
    assertNotNull(res);
    assertTrue("ResultSet contained no rows", res.next());
    do {
        assertEquals("2011-03-25", res.getString("ddate"));
        assertEquals("10", res.getString("num"));
        assertEquals((byte) 10, res.getByte("num"));
        assertEquals("2011-03-25", res.getDate("ddate").toString());
        assertEquals(Double.valueOf(10).doubleValue(), res.getDouble("num"), 0.1);
        assertEquals(10, res.getInt("num"));
        assertEquals(Short.valueOf("10").shortValue(), res.getShort("num"));
        assertEquals(10L, res.getLong("num"));
        assertEquals(true, res.getBoolean("bv"));
        Object o = res.getObject("ddate");
        assertNotNull(o);
        o = res.getObject("num");
        assertNotNull(o);
    } while (res.next());
}
Also used : Object(java.lang.Object)

Example 3 with Object

use of java.lang.Object in project clojure by clojure.

the class LispReader method interpretToken.

private static Object interpretToken(String s) {
    if (s.equals("nil")) {
        return null;
    } else if (s.equals("true")) {
        return RT.T;
    } else if (s.equals("false")) {
        return RT.F;
    }
    Object ret = null;
    ret = matchSymbol(s);
    if (ret != null)
        return ret;
    throw Util.runtimeException("Invalid token: " + s);
}
Also used : Object(java.lang.Object)

Example 4 with Object

use of java.lang.Object in project clojure by clojure.

the class LispReader method installPlatformFeature.

private static Object installPlatformFeature(Object opts) {
    if (opts == null)
        return RT.mapUniqueKeys(LispReader.OPT_FEATURES, PLATFORM_FEATURES);
    else {
        IPersistentMap mopts = (IPersistentMap) opts;
        Object features = mopts.valAt(OPT_FEATURES);
        if (features == null)
            return mopts.assoc(LispReader.OPT_FEATURES, PLATFORM_FEATURES);
        else
            return mopts.assoc(LispReader.OPT_FEATURES, RT.conj((IPersistentSet) features, PLATFORM_KEY));
    }
}
Also used : Object(java.lang.Object)

Example 5 with Object

use of java.lang.Object in project clojure by clojure.

the class LispReader method readNumber.

private static Object readNumber(PushbackReader r, char initch) {
    StringBuilder sb = new StringBuilder();
    sb.append(initch);
    for (; ; ) {
        int ch = read1(r);
        if (ch == -1 || isWhitespace(ch) || isMacro(ch)) {
            unread(r, ch);
            break;
        }
        sb.append((char) ch);
    }
    String s = sb.toString();
    Object n = matchNumber(s);
    if (n == null)
        throw new NumberFormatException("Invalid number: " + s);
    return n;
}
Also used : StringBuilder(java.lang.StringBuilder) NumberFormatException(java.lang.NumberFormatException) Object(java.lang.Object) String(java.lang.String)

Aggregations

Object (java.lang.Object)26 String (java.lang.String)7 IOException (java.io.IOException)4 NumberFormatException (java.lang.NumberFormatException)4 Override (java.lang.Override)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 List (java.util.List)3 File (java.io.File)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Exception (java.lang.Exception)2 IllegalArgumentException (java.lang.IllegalArgumentException)2 IllegalStateException (java.lang.IllegalStateException)2 RuntimeException (java.lang.RuntimeException)2 StringBuilder (java.lang.StringBuilder)2 UnsupportedOperationException (java.lang.UnsupportedOperationException)2 SeekableByteChannel (java.nio.channels.SeekableByteChannel)2 FileSystem (java.nio.file.FileSystem)2 Path (java.nio.file.Path)2