private void doQueryEscapeTestHelper(String data, TableRequestOptions options)
      throws StorageException {
    Class1 ref = new Class1();
    ref.setA(data);
    ref.setPartitionKey(UUID.randomUUID().toString());
    ref.setRowKey("foo");

    this.table.execute(TableOperation.insert(ref), options, null);
    TableQuery<Class1> query =
        TableQuery.from(Class1.class)
            .where(
                String.format(
                    "(PartitionKey eq '%s') and (A eq '%s')", ref.getPartitionKey(), data));

    int count = 0;

    for (Class1 ent : this.table.execute(query, options, null)) {
      count++;
      assertEquals(ent.getA(), ref.getA());
      assertEquals(ent.getB(), ref.getB());
      assertEquals(ent.getC(), ref.getC());
      assertEquals(ent.getPartitionKey(), ref.getPartitionKey());
      assertEquals(ent.getRowKey(), ref.getRowKey());
    }

    assertEquals(count, 1);
  }
예제 #2
0
 public void asyncDisposeQuery(long nativePointer) {
   if (isFinalized) {
     TableQuery.nativeClose(nativePointer);
   } else {
     abandonedQueries.add(nativePointer);
   }
 }
예제 #3
0
  public void executeDelayedDisposal() {
    synchronized (this) {
      for (int i = 0; i < abandonedTables.size(); i++) {
        long nativePointer = abandonedTables.get(i);
        Table.nativeClose(nativePointer);
      }
      abandonedTables.clear();

      for (int i = 0; i < abandonedTableViews.size(); i++) {
        long nativePointer = abandonedTableViews.get(i);
        TableView.nativeClose(nativePointer);
      }
      abandonedTableViews.clear();

      for (int i = 0; i < abandonedQueries.size(); i++) {
        long nativePointer = abandonedQueries.get(i);
        TableQuery.nativeClose(nativePointer);
      }
      abandonedQueries.clear();

      cleanRows();
    }
  }
예제 #4
0
  @Test
  public void mustFailOnWriteInReadTransactions() {
    SharedGroup db = new SharedGroup(testFile, SharedGroup.Durability.FULL, null);

    writeOneTransaction(db, 1);

    ReadTransaction t = db.beginRead();
    Table table = t.getTable("EmployeeTable");

    try {
      table.addEmptyRow();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.addEmptyRows(1);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.clear();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.optimize();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.remove(0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.removeLast();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setBinaryByteArray(0, 0, null);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setBoolean(0, 0, false);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setDate(0, 0, new Date(0));
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.addSearchIndex(0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setLong(0, 0, 0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setMixed(0, 0, null);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      table.setString(0, 0, "");
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }

    TableQuery q = table.where();
    try {
      q.remove();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      q.remove(0, 0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }

    TableView v = q.findAll();
    try {
      v.clear();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.remove(0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.removeLast();
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setBinaryByteArray(0, 0, null);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setBoolean(0, 0, false);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setDate(0, 0, new Date());
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setLong(0, 0, 0);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setString(0, 0, "");
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }
    try {
      v.setMixed(0, 0, null);
      fail();
    } catch (IllegalStateException e) {
      assertNotNull(e);
    }

    t.endRead();
  }