assertNull(context.beginTransaction());
Metaclass testFPA = metadata.getMetaclass("TestFPA");
Instance a = (Instance)testFPA.invoke("new");
a.setValue("data", new Binary("Creation data.".getBytes("utf-8")));
commit(context);
OID oidA = a.getOID();
String sOidName = (String)oidA.getValue(0);
// Read
assertNull(context.beginTransaction());
a.invoke("read", new Object[]{
parse("(data)"),
parse("(= (@ id) \"" + sOidName + "\")"), null, null, null, null
});
assertEquals(new Binary("Creation data.".getBytes("utf-8")), a.getValue("data"));
// Update
a.setValue("data", new Binary("Update data.".getBytes("utf-8")));
commit(context);
// Read
assertNull(context.beginTransaction());
a.invoke("read", new Object[]{
parse("(data)"),
parse("(= (@ id) \"" + sOidName + "\")"), null, null, null, null
});
assertEquals(new Binary("Update data.".getBytes("utf-8")), a.getValue("data"));
// Delete
a.invoke("delete");
commit(context);
// Read (NOT FOUND)
assertNull(context.beginTransaction());
Query query = Query.createRead(testFPA, null, parse("(= (@ id) \"" + sOidName + "\")"), null, 10, 0, false, Query.SEC_NONE, context);
InstanceList resultList = query.read();
assertEquals(0, resultList.getCount());
commit(context);
// Create it (test that the read operation doesn't add the not-found instance to the invocation context)
assertNull(context.beginTransaction());
a = (Instance)testFPA.invoke("new");
a.setOID(oidA);
a.setValue("data", new Binary("Creation data #2.".getBytes("utf-8")));
commit(context);
}
finally
{