phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Taylor <jamestay...@apache.org>
Subject Re: Trying to setup unittests to query phoenix test db but getting UnsupportedOperationException
Date Fri, 15 May 2015 16:24:45 GMT
You'll want to derive from BaseHBaseManagedTimeIT. The
BaseConnectionlessQueryTest class is for compile-time only or negative
tests as it doesn't spin up any mini cluster.

Thanks,
James

On Fri, May 15, 2015 at 5:41 AM, Ron van der Vegt
<ron.van.der.vegt@openindex.io> wrote:
> Hello everyone,
>
> I'm currently developing an Rest API which should query a phoenix table, and
> return it in JSON. Currently have no issues with building this API, but it
> would be really nice if I could write unittests with dummy data to test our
> created API calls.
>
> I was getting into the right direction, I hope, by extending the
> BaseConnectionlessQueryTest class and setup a test database:
>
> String ddl = "CREATE TABLE test (id VARCHAR not null primary key, test_value
> CHAR(16)";
> createTestTable(getUrl(), ddl, (byte[][]) null, (Long) null);
>
> And it looks like I could also upsert some data:
>
> Properties props = new Properties();
> PhoenixConnection conn =
> (PhoenixConnection)DriverManager.getConnection("jdbc:phoenix:none;test=true",
> props);
> PreparedStatement statement = conn.prepareStatement("UPSERT INTO test(id)
> VALUES ('meh')");
> statement.execute();
>
> But when I want to select data:
>
> PreparedStatement statement = conn.prepareStatement("SELECT * FROM test");
> ResultSet rs = statement.executeQuery();
> while (rs.next()) {
>   System.out.println(rs.getString("ID"));
> }
>
> I am get an UnsupportedOperationException. Could someone please explain to
> me what I'm doing wrong, or that my use case is possible somehow?
>
> Thanks in advice!
>
> Ron

Mime
View raw message