Exemplo n.º 1
0
  @Test
  public void testPostgresExtensions() throws Exception {
    jOOQAbstractTest.reset = false;

    // [#2267] Try to execute some basic CRUD operations on PostGIS data
    // types. Even without formal support, jOOQ should allow to pass these
    // objects through to JDBC
    Point point = new Point(0, 0);
    point.setSrid(4326);
    PGgeometry geometry = new PGgeometry(point);

    // [#2267] Non-PostGIS geometry objects should work, too
    PGbox box = new PGbox(1.0, 1.0, 2.0, 2.0);
    PGInterval interval = new PGInterval(1, 2, 3, 4, 5, 6);

    TPgExtensionsRecord r1 = create().newRecord(T_PG_EXTENSIONS);
    r1.setPgGeometry(geometry);
    r1.setPgInterval(interval);
    r1.setPgBox(box);
    assertEquals(1, r1.store());
    assertEquals(1, (int) create().selectCount().from(T_PG_EXTENSIONS).fetchOne(0, int.class));

    TPgExtensionsRecord r2 = create().selectFrom(T_PG_EXTENSIONS).fetchOne();
    assertEquals(r1, r2);

    assertEquals(box, r2.getPgBox());
    assertEquals(geometry, r2.getPgGeometry());
    assertEquals(interval, r2.getPgInterval());
  }