@Test
 public void testRemoteColumns() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .metaData(GET_COLUMNS)
       .returns(CalciteAssert.checkResultContains("COLUMN_NAME=EMPNO"));
 }
 @Test
 public void testRemoteTypeInfo() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .metaData(GET_TYPEINFO)
       .returns(CalciteAssert.checkResultCount(30));
 }
 @Test
 public void testRemoteExecuteQuery() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .query("values (1, 'a'), (cast(null as integer), 'b')")
       .returnsUnordered("EXPR$0=1; EXPR$1=a", "EXPR$0=null; EXPR$1=b");
 }
 @Test
 public void testRemoteTableTypes() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .metaData(GET_TABLE_TYPES)
       .returns("TABLE_TYPE=TABLE\n" + "TABLE_TYPE=VIEW\n");
 }
 @Test
 public void testRemoteCatalogs() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .metaData(GET_CATALOGS)
       .returns("TABLE_CAT=null\n");
 }
 @Test
 public void testMetaFunctionsLocal() throws Exception {
   final Connection connection = CalciteAssert.hr().connect();
   assertThat(connection.isClosed(), is(false));
   for (Meta.DatabaseProperty p : Meta.DatabaseProperty.values()) {
     switch (p) {
       case GET_NUMERIC_FUNCTIONS:
         assertThat(connection.getMetaData().getNumericFunctions(), not(equalTo("")));
         break;
       case GET_SYSTEM_FUNCTIONS:
         assertThat(connection.getMetaData().getSystemFunctions(), CoreMatchers.notNullValue());
         break;
       case GET_TIME_DATE_FUNCTIONS:
         assertThat(connection.getMetaData().getTimeDateFunctions(), not(equalTo("")));
         break;
       case GET_S_Q_L_KEYWORDS:
         assertThat(connection.getMetaData().getSQLKeywords(), not(equalTo("")));
         break;
       case GET_STRING_FUNCTIONS:
         assertThat(connection.getMetaData().getStringFunctions(), not(equalTo("")));
         break;
       default:
     }
   }
   connection.close();
   assertThat(connection.isClosed(), is(true));
 }
 public Meta create(List<String> args) {
   try {
     final Connection connection = CalciteAssert.hr().connect();
     return new CalciteMetaImpl((CalciteConnectionImpl) connection);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
 public Service create(AvaticaConnection connection) {
   try {
     Connection localConnection = CalciteAssert.hr().connect();
     final Meta meta =
         CalciteConnectionImpl.TROJAN.getMeta((CalciteConnectionImpl) localConnection);
     return new LocalJsonService(new LocalService(meta));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
 @Test
 public void testRemoteSchemas() throws Exception {
   CalciteAssert.hr()
       .with(REMOTE_CONNECTION_FACTORY)
       .metaData(GET_SCHEMAS)
       .returns(
           "TABLE_SCHEM=POST; TABLE_CATALOG=null\n"
               + "TABLE_SCHEM=foodmart; TABLE_CATALOG=null\n"
               + "TABLE_SCHEM=hr; TABLE_CATALOG=null\n"
               + "TABLE_SCHEM=metadata; TABLE_CATALOG=null\n");
 }
  @BeforeClass
  public static void beforeClass() throws Exception {
    localConnection = CalciteAssert.hr().connect();

    // Make sure we pick an ephemeral port for the server
    start =
        Main.start(
            new String[] {Factory.class.getName()},
            0,
            new HandlerFactory() {
              public AvaticaJsonHandler createHandler(Service service) {
                return new AvaticaJsonHandler(service);
              }
            });
    final int port = start.getPort();
    remoteConnection =
        DriverManager.getConnection("jdbc:avatica:remote:url=http://localhost:" + port);
  }
Пример #11
0
 private CalciteAssert.AssertThat with(boolean enable) {
   return CalciteAssert.model(TPCH_MODEL).enable(enable);
 }